@@ -46,9 +46,8 @@
+
\ No newline at end of file
diff --git a/application/view/templates/debugbar.tpl b/application/view/templates/shared/debugbar.tpl
similarity index 100%
rename from application/view/templates/debugbar.tpl
rename to application/view/templates/shared/debugbar.tpl
diff --git a/application/view/templates/shared/footer.tpl b/application/view/templates/shared/footer.tpl
new file mode 100644
index 0000000..1157d6c
--- /dev/null
+++ b/application/view/templates/shared/footer.tpl
@@ -0,0 +1,13 @@
+{foreach item=script from=$js}
+
+{/foreach}
+
+{include file="./debugbar.tpl"}
\ No newline at end of file
diff --git a/application/view/templates/shared/header.tpl b/application/view/templates/shared/header.tpl
new file mode 100644
index 0000000..50adfdf
--- /dev/null
+++ b/application/view/templates/shared/header.tpl
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+ {$title}
+
+ {foreach item=style from=$css}
+
+ {/foreach}
+
+
\ No newline at end of file
diff --git a/composer.json b/composer.json
index 070e046..036e972 100644
--- a/composer.json
+++ b/composer.json
@@ -8,12 +8,18 @@
"authors": [
{
"name": "Stephan Kasdorf",
- "email": "skasdorf@alllinux.de",
- "homepage": "http://www.alllinux.de",
+ "email": "stephan.kasdorf@bittomine.com",
+ "homepage": "https://www.nibiru-framework.com",
"role": "Developer"
}
],
+ "config": {
+ "vendor-dir": "core/l"
+ },
"require": {
- "php": ">=7.1.0"
+ "php": ">=7.1.0",
+ "smarty/smarty": "^3.1",
+ "phpmailer/phpmailer": "^6.1",
+ "carbondate/carbon": "^2.0@beta"
}
-}
+}
\ No newline at end of file
diff --git a/core/a/controller.php b/core/a/controller.php
new file mode 100644
index 0000000..ade1c97
--- /dev/null
+++ b/core/a/controller.php
@@ -0,0 +1,29 @@
+getConfig()[View::NIBIRU_SECURITY]["password_hash"] . "') AS ".self::TABLE['field']['user_pass']." FROM user WHERE " . self::TABLE['field']['user_name']. " = '" . $user_name . "';");
return array_shift($result);
}
-
+
+ /**
+ * @return mixed
+ */
public function loadTableAsArray()
{
$result = Pdo::fetchTableAsArray( self::getTable()['table'] );
return $result;
}
-
+
+ /**
+ * @param bool $id
+ * @return mixed|void
+ */
public function selectRowsetById($id = false)
{
// TODO: Implement selectRowsetById() method.
}
+ /**
+ * @param array $rowset
+ * @param bool $id
+ * @return mixed|void
+ */
public function insertRowsetById($rowset = array(), $id = false)
{
// TODO: Implement insertRowsetById() method.
}
+ /**
+ * @param bool $min
+ * @param bool $max
+ * @return mixed|void
+ */
public function selectDatasetByMinMax($min = false, $max = false)
{
// TODO: Implement selectDatasetByMinMax() method.
diff --git a/core/a/pageination.php b/core/a/pageination.php
index a179c1e..55cfe86 100755
--- a/core/a/pageination.php
+++ b/core/a/pageination.php
@@ -12,8 +12,10 @@ use Nibiru\Config;
use Nibiru\Controller;
use Nibiru\Router;
use Nibiru\View;
+use Nibiru\IPageination;
+use Nibiru\Adapter\IDb;
-abstract class Pageination implements \Nibiru\IPageination
+abstract class Pageination implements IPageination
{
use Attributes\Pageination;
@@ -33,7 +35,10 @@ abstract class Pageination implements \Nibiru\IPageination
self::$_uri_pagination_path = '/' . Router::getInstance()->currentPage() . '/' . Controller::getInstance()->getRequest()['_action'] . '/';
}
- private static function getUriPaginationPath()
+ /**
+ * @return string
+ */
+ private static function getUriPaginationPath(): string
{
return self::$_uri_pagination_path;
}
@@ -56,7 +61,7 @@ abstract class Pageination implements \Nibiru\IPageination
/**
* @return int
*/
- private static function getMaxPageEntries()
+ private static function getMaxPageEntries(): int
{
return self::$_max_page_entries;
}
@@ -64,12 +69,15 @@ abstract class Pageination implements \Nibiru\IPageination
/**
* @param int $max_page_entries
*/
- private static function setMaxPageEntries( $max_page_entries )
+ private static function setMaxPageEntries( int $max_page_entries )
{
self::$_max_page_entries = $max_page_entries;
}
- private static function currentPageEntryLimit( )
+ /**
+ * @return mixed
+ */
+ private static function currentPageEntryLimit( ): ?array
{
return self::getPageEntryIndex()[self::getCurrentNumber()];
}
@@ -83,7 +91,7 @@ abstract class Pageination implements \Nibiru\IPageination
}
/**
- * @param array $page_entry_index
+ * will set the current page entry index
*/
private static function setPageEntryIndex( )
{
@@ -128,13 +136,13 @@ abstract class Pageination implements \Nibiru\IPageination
/**
* @return int
*/
- private static function getEntriesPerPage()
+ private static function getEntriesPerPage(): int
{
return self::$_entries_per_page;
}
/**
- * @param int $entries_per_page
+ * will set the entries per page
*/
private static function setEntriesPerPage( )
{
@@ -144,7 +152,7 @@ abstract class Pageination implements \Nibiru\IPageination
/**
* @return int
*/
- public static function getMaxPages( )
+ public static function getMaxPages( ): int
{
return self::$_max_pages;
}
@@ -153,7 +161,7 @@ abstract class Pageination implements \Nibiru\IPageination
* @desc if you have deactivated pages you can set a filter here
* @param string $where
*/
- private static function setMaxPages( $where = '' )
+ private static function setMaxPages( string $where = '' )
{
$tableinfo = self::getTable()->loadAllTableFieldNames();
self::setMaxPageEntries( self::getTable()->loadTableRowCount( $tableinfo[0], $where ));
@@ -163,15 +171,16 @@ abstract class Pageination implements \Nibiru\IPageination
/**
* @return boolean
*/
- private static function getTable( )
+ private static function getTable( ): IDb
{
return self::$_table;
}
/**
- * @param boolean $table
+ * @param IDb $table
+ * @param string $where
*/
- public static function setTable( Adapter\IDb $table, $where = '' )
+ public static function setTable( IDb $table, string $where = '' )
{
if(is_object( $table ))
{
@@ -185,13 +194,13 @@ abstract class Pageination implements \Nibiru\IPageination
/**
* @return array
*/
- protected static function pageContent()
+ protected static function pageContent(): array
{
return self::$_current_page_content;
}
/**
- * @param array $current_page_content
+ * will set the current page content
*/
protected static function setCurrentPageContent( )
{
@@ -211,7 +220,7 @@ abstract class Pageination implements \Nibiru\IPageination
/**
* @return int
*/
- protected static function getCurrentNumber()
+ protected static function getCurrentNumber(): int
{
return self::$_current_number;
}
@@ -221,7 +230,6 @@ abstract class Pageination implements \Nibiru\IPageination
* is also used without the pagination, so in order to avoid the
* settings not to work, it is possible to skip the currentNumber
* setup.
- * @param int $current_number
*/
protected static function setCurrentNumber( )
{
@@ -270,13 +278,13 @@ abstract class Pageination implements \Nibiru\IPageination
/**
* @return int
*/
- protected static function getNextPageNumber()
+ protected static function getNextPageNumber(): int
{
return self::$_next_page_number;
}
/**
- * @param int $next_page_number
+ * Will set the next page number up
*/
protected static function setNextPageNumber( )
{
@@ -295,13 +303,13 @@ abstract class Pageination implements \Nibiru\IPageination
/**
* @return int
*/
- public static function getPreviousPageNumber()
+ public static function getPreviousPageNumber(): int
{
return self::$_previous_page_number;
}
/**
- * @param int $previous_page_number
+ * will set the previous page number before
*/
public static function setPreviousPageNumber( )
{
diff --git a/core/a/postgres.db.php b/core/a/postgres.db.php
index a079975..a19e09d 100644
--- a/core/a/postgres.db.php
+++ b/core/a/postgres.db.php
@@ -34,7 +34,7 @@ abstract class Db implements IDb
* @desc getter for the table constant array
* @return array
*/
- private static function getTable()
+ private static function getTable(): array
{
return self::$table;
}
diff --git a/core/c/auth.php b/core/c/auth.php
index eeca611..b485687 100644
--- a/core/c/auth.php
+++ b/core/c/auth.php
@@ -104,4 +104,22 @@ class Auth extends Controller implements IAuth
$this->_password = $password;
}
+ /**
+ * This should be part of any extended controller
+ * class in order to implement a page structure
+ * @return array
+ */
+ public function pageAction()
+ {
+ // TODO: Implement pageAction() method.
+ }
+
+ /**
+ * This is the part where you can add titles to
+ * your page navigation.
+ */
+ public function navigationAction()
+ {
+ // TODO: Implement navigationAction() method.
+ }
}
\ No newline at end of file
diff --git a/core/c/autoloader.php b/core/c/autoloader.php
index e88f6c4..b552286 100644
--- a/core/c/autoloader.php
+++ b/core/c/autoloader.php
@@ -156,7 +156,16 @@ class Autoloader
{
return self::$_modules;
}
-
+
+ /**
+ * @param string $folderPath
+ * @return \RecursiveIteratorIterator
+ */
+ private static function folderContent( string $folderPath ): \RecursiveIteratorIterator
+ {
+ return new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator( $folderPath ));
+ }
+
/**
* @param array $filesInFoler
*/
@@ -172,7 +181,7 @@ class Autoloader
{
foreach ( Config::getInstance()->getConfig()[View::NIBIRU_SETTINGS][self::DB_MODEL_FOLDER] as $modelfolder )
{
- $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator( __DIR__ . $modelfolder ));
+ $iterator = self::folderContent( __DIR__ . $modelfolder );
foreach ( $iterator as $item )
{
if($item->getFileName()!= self::MY_FILE_NAME && $item->getFileName()!="." && $item->getFileName()!="..")
@@ -184,7 +193,7 @@ class Autoloader
}
else
{
- $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(__DIR__ . Config::getInstance()->getConfig()[View::NIBIRU_SETTINGS][self::DB_MODEL_FOLDER] ));
+ $iterator = self::folderContent(__DIR__ . Config::getInstance()->getConfig()[View::NIBIRU_SETTINGS][self::DB_MODEL_FOLDER] );
foreach ( $iterator as $item )
{
if($item->getFileName()!= self::MY_FILE_NAME && $item->getFileName()!="." && $item->getFileName()!="..")
@@ -196,7 +205,7 @@ class Autoloader
/**
* @desc run check on modules that should provide an interface as well as a trait
*/
- $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(__DIR__ . Config::getInstance()->getConfig()[View::NIBIRU_SETTINGS][self::INTERFACE_FOLDER] ));
+ $iterator = self::folderContent(__DIR__ . Config::getInstance()->getConfig()[View::NIBIRU_SETTINGS][self::INTERFACE_FOLDER] );
foreach ( $iterator as $item )
{
if($item->getFileName()!= self::MY_FILE_NAME && $item->getFileName()!="." && $item->getFileName()!="..")
@@ -214,7 +223,7 @@ class Autoloader
self::$_filesInFoler[] = $interface['filepathname'];
}
- $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(__DIR__ . Config::getInstance()->getConfig()[View::NIBIRU_SETTINGS][self::TRAIT_FOLDER] ));
+ $iterator = self::folderContent(__DIR__ . Config::getInstance()->getConfig()[View::NIBIRU_SETTINGS][self::TRAIT_FOLDER] );
foreach ( $iterator as $item )
{
if($item->getFileName()!= self::MY_FILE_NAME && $item->getFileName()!="." && $item->getFileName()!="..")
@@ -232,7 +241,7 @@ class Autoloader
self::$_filesInFoler[] = $trait['filepathname'];
}
- $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(__DIR__ . Config::getInstance()->getConfig()[View::NIBIRU_SETTINGS][self::MODULE_FOLDER] ));
+ $iterator = self::folderContent(__DIR__ . Config::getInstance()->getConfig()[View::NIBIRU_SETTINGS][self::MODULE_FOLDER] );
foreach ( $iterator as $item )
{
if($item->getFileName()!= self::MY_FILE_NAME && $item->getFileName()!="." && $item->getFileName()!="..")
diff --git a/core/c/controller.php b/core/c/controller.php
index 2420572..5373046 100644
--- a/core/c/controller.php
+++ b/core/c/controller.php
@@ -1,6 +1,5 @@
_setConfig(Config::getInstance()->getConfig());
- $this->_setTemplateEngine();
}
public static function getInstance()
@@ -42,59 +40,6 @@ class Engine implements IEngine
{
$this->_config = $config;
}
-
- /**
- * @return mixed
- */
- public function getTemplateEngine()
- {
- return self::$_template_engine;
- }
-
- /**
- * @desc set the template engine implementation and make it
- * known class wide
- * @param mixed $template_engine
- */
- protected function _setTemplateEngine( )
- {
- switch(self::getConfig()[self::T_ENGINE][self::T_ENGINE_NAME])
- {
- case self::T_ENGINE_DWOO:
- $this->_template_engine = self::T_ENGINE_DWOO;
- require_once __DIR__ . '/../l/Dwoo/IDataProvider.php';
- require_once __DIR__ . '/../l/Dwoo/Data.php';
- require_once __DIR__ . '/../l/Dwoo/ICompiler.php';
- require_once __DIR__ . '/../l/Dwoo/Compiler.php';
- require_once __DIR__ . '/../l/Dwoo/ITemplate.php';
- require_once __DIR__ . '/../l/Dwoo/Template/Str.php';
- require_once __DIR__ . '/../l/Dwoo/Template/File.php';
- require_once __DIR__ . '/../l/Dwoo/Exception.php';
- require_once __DIR__ . '/../l/Dwoo/Plugin.php';
- require_once __DIR__ . '/../l/Dwoo/ICompilable.php';
- require_once __DIR__ . '/../l/Dwoo/ICompilable/Block.php';
- require_once __DIR__ . '/../l/Dwoo/IElseable.php';
- require_once __DIR__ . '/../l/Dwoo/Plugins/';
- require_once __DIR__ . '/../l/Dwoo/Block/Plugin.php';
- require_once __DIR__ . '/../l/Dwoo/Plugins/Blocks/PluginTopLevelBlock.php';
- require_once __DIR__ . '/../l/Dwoo/Exception.php';
- require_once __DIR__ . '/../l/Dwoo/ILoader.php';
- require_once __DIR__ . '/../l/Dwoo/Loader.php';
- require_once __DIR__ . '/../l/Dwoo/Core.php';
-
- require_once __DIR__ . '/../l/Dwoo/Smarty/Adapter.php';
- break;
- case self::T_ENGINE_TWIG:
- $this->_template_engine = self::T_ENGINE_TWIG;
- require_once __DIR__ . '/../l/Twig/Autoloader.php';
- break;
- case self::T_ENGINE_SMARTY:
- default:
- $this->_template_engine = self::T_ENGINE_SMARTY;
- require_once __DIR__ . '/../l/Smarty/Smarty.class.php';
- break;
- }
- }
}
Engine::getInstance();
\ No newline at end of file
diff --git a/core/c/view.php b/core/c/view.php
index 4a0db6a..d451e5f 100755
--- a/core/c/view.php
+++ b/core/c/view.php
@@ -8,7 +8,7 @@ namespace Nibiru;
* @category - [PLEASE SPECIFIY]
* @license - BSD License
*/
-class View extends Controller implements IView
+class View implements IView
{
private static $_instance;
@@ -49,44 +49,28 @@ class View extends Controller implements IView
/**
* @return array
*/
- public function getEngine()
+ public function getEngine(): \Smarty
{
return self::$engine;
}
/**
- * @param array $engine
+ * Will setup the template engine
*/
public static function _setEngine( )
{
- switch(Config::getInstance()->getConfig()[Engine::T_ENGINE][Engine::T_ENGINE_NAME])
- {
- case Engine::T_ENGINE_SMARTY:
- self::$engine = new \Smarty();
- self::$engine->setTemplateDir(__DIR__ . Config::getInstance()->getConfig()[Engine::T_ENGINE]["templates"]);
- self::$engine->setCompileDir(__DIR__ . Config::getInstance()->getConfig()[Engine::T_ENGINE]["templates_c"]);
- self::$engine->setCacheDir(__DIR__ . Config::getInstance()->getConfig()[Engine::T_ENGINE]["cache"]);
- self::$engine->setConfigDir(__DIR__ . Config::getInstance()->getConfig()[Engine::T_ENGINE]["config_dir"]);
- self::$engine->assign('debuging', Config::getInstance()->getConfig()[Engine::T_ENGINE]["debugbar"]);
- break;
- case Engine::T_ENGINE_TWIG:
- $twig = new \Twig_Autoloader();
- $twig::register();
- self::$engine = new \Twig_Environment(new \Twig_Loader_Filesystem(Config::getInstance()->getConfig()[Engine::T_ENGINE]["templates"]), array(
- 'cache' => Config::getInstance()->getConfig()[Engine::T_ENGINE]["cache"],
- ));
- break;
- case Engine::T_ENGINE_DWOO:
- // Implement Dwoo Template Engine
- self::$engine = new \Dwoo\Core();
- self::$engine->setCacheDir(Config::getInstance()->getConfig()[Engine::T_ENGINE]["cache"]);
- self::$engine->setCompileDir(Config::getInstance()->getConfig()[Engine::T_ENGINE]["templates_c"]);
- self::$engine->setTemplateDir(Config::getInstance()->getConfig()[Engine::T_ENGINE]["templates"]);
- self::$engine->get('debugbar.tpl', array('debuging' => Config::getInstance()->getConfig()[Engine::T_ENGINE]["debugbar"]));
- break;
- }
+ self::$engine = new \Smarty();
+ self::$engine->setTemplateDir(__DIR__ . Config::getInstance()->getConfig()[Engine::T_ENGINE]["templates"]);
+ self::$engine->setCompileDir(__DIR__ . Config::getInstance()->getConfig()[Engine::T_ENGINE]["templates_c"]);
+ self::$engine->setCacheDir(__DIR__ . Config::getInstance()->getConfig()[Engine::T_ENGINE]["cache"]);
+ self::$engine->setConfigDir(__DIR__ . Config::getInstance()->getConfig()[Engine::T_ENGINE]["config_dir"]);
+ self::$engine->setDebugTemplate(__DIR__ . Config::getInstance()->getConfig()[Engine::T_ENGINE]["debug_template"] );
+ self::$engine->assign('debuging', Config::getInstance()->getConfig()[Engine::T_ENGINE]["debugbar"]);
}
+ /**
+ * @param array $varname
+ */
public function assign( $varname = array() )
{
if(is_array($varname))
@@ -95,12 +79,18 @@ class View extends Controller implements IView
}
}
+ /**
+ * @param $page
+ */
public static function forwardTo( $page )
{
header('Location: ' . $page);
exit();
}
+ /**
+ * @param $page
+ */
public function display( $page )
{
preg_match_all("/".self::NIBIRU_FILE_END."/", $page, $matches);
@@ -126,7 +116,12 @@ class View extends Controller implements IView
{
return $this->xmlPos;
}
-
+
+ /**
+ * @param $stuff
+ * @param bool $die
+ * @return string
+ */
protected static function printStuffToScreen( $stuff, $die = false )
{
$output = "
" . print_r( $stuff, true ) . "
";
diff --git a/core/framework.php b/core/framework.php
index b0afef8..587eccd 100644
--- a/core/framework.php
+++ b/core/framework.php
@@ -21,6 +21,7 @@ require_once __DIR__ . '/c/config.php';
require_once __DIR__ . '/c/router.php';
require_once __DIR__ . '/i/engine.php';
require_once __DIR__ . '/c/engine.php';
+require_once __DIR__ . '/l/autoload.php';
/**
* @desc Database connectivity
*/
@@ -79,10 +80,11 @@ require_once __DIR__ . '/c/typeselect.php';
require_once __DIR__ . '/c/typerange.php';
require_once __DIR__ . '/c/typeurl.php';
require_once __DIR__ . '/c/typelabel.php';
-require_once __DIR__ . '/i/controller.php';
-require_once __DIR__ . '/c/controller.php';
require_once __DIR__ . '/i/view.php';
require_once __DIR__ . '/c/view.php';
+require_once __DIR__ . '/i/controller.php';
+require_once __DIR__ . '/c/controller.php';
+require_once __DIR__ . '/a/controller.php';
require_once __DIR__ . '/c/jsonnavigation.php';
/**
* @desc currently unfinished
diff --git a/core/i/auth.php b/core/i/auth.php
index e7a9c4d..53967df 100644
--- a/core/i/auth.php
+++ b/core/i/auth.php
@@ -10,8 +10,5 @@ namespace Nibiru;
*/
interface IAuth
{
- const NIBIRU_SECURITY = "SECURITY";
-
public function auth( $username, $password );
-
}
\ No newline at end of file
diff --git a/core/i/engine.php b/core/i/engine.php
index fe2b075..e5a886d 100644
--- a/core/i/engine.php
+++ b/core/i/engine.php
@@ -9,8 +9,4 @@ namespace Nibiru;
interface IEngine
{
const T_ENGINE = "ENGINE";
- const T_ENGINE_NAME = "name";
- const T_ENGINE_TWIG = "Twig";
- const T_ENGINE_SMARTY = "Smarty";
- const T_ENGINE_DWOO = "Dwoo";
}
\ No newline at end of file
diff --git a/core/l/.gitkeep b/core/l/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/core/l/Dwoo/Block/Plugin.php b/core/l/Dwoo/Block/Plugin.php
deleted file mode 100644
index b05447c..0000000
--- a/core/l/Dwoo/Block/Plugin.php
+++ /dev/null
@@ -1,119 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2016 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.0
- * @date 2016-09-23
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Block;
-
-use Dwoo\Plugin as DwooPlugin;
-use Dwoo\Compiler as DwooCompiler;
-
-/**
- * Base class for block plugins.
- * you have to implement the init() method, it will receive the parameters that
- * are in the template code and is called when the block starts
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-abstract class Plugin extends DwooPlugin
-{
- /**
- * Stores the contents of the block while it runs.
- *
- * @var string
- */
- protected $buffer = '';
-
- /**
- * Buffers input, override only if necessary.
- *
- * @var string the content that must be buffered
- */
- public function buffer($input)
- {
- $this->buffer .= $input;
- }
-
- // initialization code, receives the parameters from {block param1 param2}
- // public function init($arg, $arg, ...);
-
- /**
- * Called when the block ends, this is most of the time followed right away by a call
- * of process() but not always, so this should be used to do any shutdown operations on the
- * block object, if required.
- */
- public function end()
- {
- }
-
- /**
- * Called when the block output is required by a parent block.
- * this must read $this->buffer and return it processed
- *
- * @return string
- */
- public function process()
- {
- return $this->buffer;
- }
-
- /**
- * Called at compile time to define what the block should output in the compiled template code, happens when the
- * block is declared basically this will replace the {block arg arg arg} tag in the template.
- *
- * @param DwooCompiler $compiler the compiler instance that calls this function
- * @param array $params an array containing original and compiled parameters
- * @param string $prepend that is just meant to allow a child class to call
- * parent::postProcessing($compiler, $params, "foo();") to add a command before the
- * default commands are executed parent::postProcessing($compiler, $params, "foo();")
- * to add a command before the default commands are executed
- * @param string $append that is just meant to allow a child class to call
- * parent::postProcessing($compiler, $params, null, "foo();") to add a command after
- * the default commands are executed parent::postProcessing($compiler, $params, null,
- * "foo();") to add a command after the default commands are executed
- * @param string $type the type is the plugin class name used
- *
- * @return string
- */
- public static function preProcessing(DwooCompiler $compiler, array $params, $prepend, $append, $type)
- {
- return DwooCompiler::PHP_OPEN . $prepend . '$this->addStack("' . $type . '", array(' . DwooCompiler::implode_r($compiler->getCompiledParams($params)) . '));' . $append . DwooCompiler::PHP_CLOSE;
- }
-
- /**
- * Called at compile time to define what the block should output in the compiled template code, happens when the
- * block is ended basically this will replace the {/block} tag in the template.
- *
- * @see preProcessing
- *
- * @param DwooCompiler $compiler the compiler instance that calls this function
- * @param array $params an array containing original and compiled parameters, see preProcessing() for more
- * details more details
- * @param string $prepend that is just meant to allow a child class to call
- * parent::postProcessing($compiler, $params, "foo();") to add a command before the
- * default commands are executed parent::postProcessing($compiler, $params, "foo();")
- * to add a command before the default commands are executed
- * @param string $append that is just meant to allow a child class to call
- * parent::postProcessing($compiler, $params, null, "foo();") to add a command after
- * the default commands are executed parent::postProcessing($compiler, $params, null,
- * "foo();") to add a command after the default commands are executed
- * @param string $content the entire content of the block being closed
- *
- * @return string
- */
- public static function postProcessing(DwooCompiler $compiler, array $params, $prepend, $append, $content)
- {
- return $content . DwooCompiler::PHP_OPEN . $prepend . '$this->delStack();' . $append . DwooCompiler::PHP_CLOSE;
- }
-}
diff --git a/core/l/Dwoo/Compilation/Exception.php b/core/l/Dwoo/Compilation/Exception.php
deleted file mode 100644
index 732a8d4..0000000
--- a/core/l/Dwoo/Compilation/Exception.php
+++ /dev/null
@@ -1,60 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2017 David Sanchez
- * @license http://dwoo.org/LICENSE LGPLv3
- * @version 1.3.6
- * @date 2017-03-21
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Compilation;
-
-use Dwoo\Exception as DwooException;
-use Dwoo\Compiler as DwooCompiler;
-
-/**
- * Dwoo compilation exception class.
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class Exception extends DwooException
-{
- protected $compiler;
- protected $template;
-
- /**
- * Exception constructor.
- *
- * @param DwooCompiler $compiler
- * @param int $message
- */
- public function __construct(DwooCompiler $compiler, $message)
- {
- $this->compiler = $compiler;
- $this->template = $compiler->getCore()->getTemplate();
- parent::__construct('Compilation error at line ' . $compiler->getLine() . ' in "' . $this->template->getResourceName() . ':' . $this->template->getResourceIdentifier() . '" : ' . $message);
- }
-
- /**
- * @return DwooCompiler
- */
- public function getCompiler()
- {
- return $this->compiler;
- }
-
- /**
- * @return \Dwoo\ITemplate|null
- */
- public function getTemplate()
- {
- return $this->template;
- }
-}
diff --git a/core/l/Dwoo/Compiler.php b/core/l/Dwoo/Compiler.php
deleted file mode 100644
index fff2e05..0000000
--- a/core/l/Dwoo/Compiler.php
+++ /dev/null
@@ -1,3671 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2017 David Sanchez
- * @license http://dwoo.org/LICENSE LGPLv3
- * @version 1.3.6
- * @date 2017-03-22
- * @link http://dwoo.org/
- */
-
-namespace Dwoo;
-
-use Closure;
-use Dwoo\Plugins\Blocks\PluginIf;
-use Dwoo\Security\Exception as SecurityException;
-use Dwoo\Security\Policy as SecurityPolicy;
-use Dwoo\Compilation\Exception as CompilationException;
-use ReflectionFunction;
-use ReflectionMethod;
-
-/**
- * Default dwoo compiler class, compiles dwoo templates into php.
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class Compiler implements ICompiler
-{
- /**
- * Constant that represents a php opening tag.
- * use it in case it needs to be adjusted
- *
- * @var string
- */
- const PHP_OPEN = '';
-
- /**
- * Boolean flag to enable or disable debugging output.
- *
- * @var bool
- */
- public $debug = false;
-
- /**
- * Left script delimiter.
- *
- * @var string
- */
- protected $ld = '{';
-
- /**
- * Left script delimiter with escaped regex meta characters.
- *
- * @var string
- */
- protected $ldr = '\\{';
-
- /**
- * Right script delimiter.
- *
- * @var string
- */
- protected $rd = '}';
-
- /**
- * Right script delimiter with escaped regex meta characters.
- *
- * @var string
- */
- protected $rdr = '\\}';
-
- /**
- * Defines whether the nested comments should be parsed as nested or not.
- * defaults to false (classic block comment parsing as in all languages)
- *
- * @var bool
- */
- protected $allowNestedComments = false;
-
- /**
- * Defines whether opening and closing tags can contain spaces before valid data or not.
- * turn to true if you want to be sloppy with the syntax, but when set to false it allows
- * to skip javascript and css tags as long as they are in the form "{ something", which is
- * nice. default is false.
- *
- * @var bool
- */
- protected $allowLooseOpenings = false;
-
- /**
- * Defines whether the compiler will automatically html-escape variables or not.
- * default is false
- *
- * @var bool
- */
- protected $autoEscape = false;
-
- /**
- * Security policy object.
- *
- * @var SecurityPolicy
- */
- protected $securityPolicy;
-
- /**
- * Stores the custom plugins registered with this compiler.
- *
- * @var array
- */
- protected $customPlugins = array();
-
- /**
- * Stores the template plugins registered with this compiler.
- *
- * @var array
- */
- protected $templatePlugins = array();
-
- /**
- * Stores the pre- and post-processors callbacks.
- *
- * @var array
- */
- protected $processors = array('pre' => array(), 'post' => array());
-
- /**
- * Stores a list of plugins that are used in the currently compiled
- * template, and that are not compilable. these plugins will be loaded
- * during the template's runtime if required.
- * it is a 1D array formatted as key:pluginName value:pluginType
- *
- * @var array
- */
- protected $usedPlugins;
-
- /**
- * Stores the template undergoing compilation.
- *
- * @var string
- */
- protected $template;
-
- /**
- * Stores the current pointer position inside the template.
- *
- * @var int
- */
- protected $pointer;
-
- /**
- * Stores the current line count inside the template for debugging purposes.
- *
- * @var int
- */
- protected $line;
-
- /**
- * Stores the current template source while compiling it.
- *
- * @var string
- */
- protected $templateSource;
-
- /**
- * Stores the data within which the scope moves.
- *
- * @var array
- */
- protected $data;
-
- /**
- * Variable scope of the compiler, set to null if
- * it can not be resolved to a static string (i.e. if some
- * plugin defines a new scope based on a variable array key).
- *
- * @var mixed
- */
- protected $scope;
-
- /**
- * Variable scope tree, that allows to rebuild the current
- * scope if required, i.e. when going to a parent level.
- *
- * @var array
- */
- protected $scopeTree;
-
- /**
- * Block plugins stack, accessible through some methods.
- *
- * @see findBlock
- * @see getCurrentBlock
- * @see addBlock
- * @see addCustomBlock
- * @see injectBlock
- * @see removeBlock
- * @see removeTopBlock
- * @var array
- */
- protected $stack = array();
-
- /**
- * Current block at the top of the block plugins stack,
- * accessible through getCurrentBlock.
- *
- * @see getCurrentBlock
- * @var array
- */
- protected $curBlock;
-
- /**
- * Current dwoo object that uses this compiler, or null.
- *
- * @var Core
- */
- public $core;
-
- /**
- * Holds an instance of this class, used by getInstance when you don't
- * provide a custom compiler in order to save resources.
- *
- * @var Compiler
- */
- protected static $instance;
-
- /**
- * Token types.
- *
- * @var int
- */
- const T_UNQUOTED_STRING = 1;
- const T_NUMERIC = 2;
- const T_NULL = 4;
- const T_BOOL = 8;
- const T_MATH = 16;
- const T_BREAKCHAR = 32;
-
- /**
- * Compiler constructor.
- * saves the created instance so that child templates get the same one
- */
- public function __construct()
- {
- self::$instance = $this;
- }
-
- /**
- * Sets the delimiters to use in the templates.
- * delimiters can be multi-character strings but should not be one of those as they will
- * make it very hard to work with templates or might even break the compiler entirely : "\", "$", "|", ":" and
- * finally "#" only if you intend to use config-vars with the #var# syntax.
- *
- * @param string $left left delimiter
- * @param string $right right delimiter
- */
- public function setDelimiters($left, $right)
- {
- $this->ld = $left;
- $this->rd = $right;
- $this->ldr = preg_quote($left, '/');
- $this->rdr = preg_quote($right, '/');
- }
-
- /**
- * Returns the left and right template delimiters.
- *
- * @return array containing the left and the right delimiters
- */
- public function getDelimiters()
- {
- return array($this->ld, $this->rd);
- }
-
- /**
- * Sets the way to handle nested comments, if set to true
- * {* foo {* some other *} comment *} will be stripped correctly.
- * if false it will remove {* foo {* some other *} and leave "comment *}" alone,
- * this is the default behavior
- *
- * @param bool $allow allow nested comments or not, defaults to true (but the default internal value is false)
- */
- public function setNestedCommentsHandling($allow = true)
- {
- $this->allowNestedComments = (bool)$allow;
- }
-
- /**
- * Returns the nested comments handling setting.
- *
- * @see setNestedCommentsHandling
- * @return bool true if nested comments are allowed
- */
- public function getNestedCommentsHandling()
- {
- return $this->allowNestedComments;
- }
-
- /**
- * Sets the tag openings handling strictness, if set to true, template tags can
- * contain spaces before the first function/string/variable such as { $foo} is valid.
- * if set to false (default setting), { $foo} is invalid but that is however a good thing
- * as it allows css (i.e. #foo { color:red; }) to be parsed silently without triggering
- * an error, same goes for javascript.
- *
- * @param bool $allow true to allow loose handling, false to restore default setting
- */
- public function setLooseOpeningHandling($allow = false)
- {
- $this->allowLooseOpenings = (bool)$allow;
- }
-
- /**
- * Returns the tag openings handling strictness setting.
- *
- * @see setLooseOpeningHandling
- * @return bool true if loose tags are allowed
- */
- public function getLooseOpeningHandling()
- {
- return $this->allowLooseOpenings;
- }
-
- /**
- * Changes the auto escape setting.
- * if enabled, the compiler will automatically html-escape variables,
- * unless they are passed through the safe function such as {$var|safe}
- * or {safe $var}
- * default setting is disabled/false
- *
- * @param bool $enabled set to true to enable, false to disable
- */
- public function setAutoEscape($enabled)
- {
- $this->autoEscape = (bool)$enabled;
- }
-
- /**
- * Returns the auto escape setting.
- * default setting is disabled/false
- *
- * @return bool
- */
- public function getAutoEscape()
- {
- return $this->autoEscape;
- }
-
- /**
- * Adds a preprocessor to the compiler, it will be called
- * before the template is compiled.
- *
- * @param mixed $callback either a valid callback to the preprocessor or a simple name if the autoload is set to
- * true
- * @param bool $autoload if set to true, the preprocessor is auto-loaded from one of the plugin directories, else
- * you must provide a valid callback
- */
- public function addPreProcessor($callback, $autoload = false)
- {
- if ($autoload) {
- $name = str_replace(Core::NAMESPACE_PLUGINS_PROCESSORS, '', Core::toCamelCase($callback));
- $class = Core::NAMESPACE_PLUGINS_PROCESSORS . $name;
-
- if (class_exists($class)) {
- $callback = array(new $class($this), 'process');
- } elseif (function_exists($class)) {
- $callback = $class;
- } else {
- $callback = array('autoload' => true, 'class' => $class, 'name' => $name);
- }
-
- $this->processors['pre'][] = $callback;
- } else {
- $this->processors['pre'][] = $callback;
- }
- }
-
- /**
- * Removes a preprocessor from the compiler.
- *
- * @param mixed $callback either a valid callback to the preprocessor or a simple name if it was autoloaded
- */
- public function removePreProcessor($callback)
- {
- if (($index = array_search($callback, $this->processors['pre'], true)) !== false) {
- unset($this->processors['pre'][$index]);
- } elseif (($index = array_search(Core::NAMESPACE_PLUGINS_PROCESSORS . str_replace(Core::NAMESPACE_PLUGINS_PROCESSORS, '',
- $callback),
- $this->processors['pre'], true)) !== false) {
- unset($this->processors['pre'][$index]);
- } else {
- $class = Core::NAMESPACE_PLUGINS_PROCESSORS . str_replace(Core::NAMESPACE_PLUGINS_PROCESSORS, '', $callback);
- foreach ($this->processors['pre'] as $index => $proc) {
- if (is_array($proc) && ($proc[0] instanceof $class) || (isset($proc['class']) && $proc['class'] == $class)) {
- unset($this->processors['pre'][$index]);
- break;
- }
- }
- }
- }
-
- /**
- * Adds a postprocessor to the compiler, it will be called
- * before the template is compiled.
- *
- * @param mixed $callback either a valid callback to the postprocessor or a simple name if the autoload is set to
- * true
- * @param bool $autoload if set to true, the postprocessor is auto-loaded from one of the plugin directories, else
- * you must provide a valid callback
- */
- public function addPostProcessor($callback, $autoload = false)
- {
- if ($autoload) {
- $name = str_replace(Core::NAMESPACE_PLUGINS_PROCESSORS, '', $callback);
- $class = Core::NAMESPACE_PLUGINS_PROCESSORS . Core::toCamelCase($name);
-
- if (class_exists($class)) {
- $callback = array(new $class($this), 'process');
- } elseif (function_exists($class)) {
- $callback = $class;
- } else {
- $callback = array('autoload' => true, 'class' => $class, 'name' => $name);
- }
-
- $this->processors['post'][] = $callback;
- } else {
- $this->processors['post'][] = $callback;
- }
- }
-
- /**
- * Removes a postprocessor from the compiler.
- *
- * @param mixed $callback either a valid callback to the postprocessor or a simple name if it was autoloaded
- */
- public function removePostProcessor($callback)
- {
- if (($index = array_search($callback, $this->processors['post'], true)) !== false) {
- unset($this->processors['post'][$index]);
- } elseif (($index = array_search(Core::NAMESPACE_PLUGINS_PROCESSORS . str_replace(Core::NAMESPACE_PLUGINS_PROCESSORS, '',
- $callback),
- $this->processors['post'], true)) !== false) {
- unset($this->processors['post'][$index]);
- } else {
- $class = Core::NAMESPACE_PLUGINS_PROCESSORS . str_replace(Core::NAMESPACE_PLUGINS_PROCESSORS, '', $callback);
- foreach ($this->processors['post'] as $index => $proc) {
- if (is_array($proc) && ($proc[0] instanceof $class) || (isset($proc['class']) && $proc['class'] == $class)) {
- unset($this->processors['post'][$index]);
- break;
- }
- }
- }
- }
-
- /**
- * Internal function to autoload processors at runtime if required.
- *
- * @param string $class the class/function name
- * @param string $name the plugin name (without Dwoo_Plugin_ prefix)
- *
- * @return array|string
- * @throws Exception
- */
- protected function loadProcessor($class, $name)
- {
- if (!class_exists($class) && !function_exists($class)) {
- try {
- $this->getCore()->getLoader()->loadPlugin($name);
- }
- catch (Exception $e) {
- throw new Exception('Processor ' . $name . ' could not be found in your plugin directories, please ensure it is in a file named ' . $name . '.php in the plugin directory');
- }
- }
-
- if (class_exists($class)) {
- return array(new $class($this), 'process');
- }
-
- if (function_exists($class)) {
- return $class;
- }
-
- throw new Exception('Wrong processor name, when using autoload the processor must be in one of your plugin dir as "name.php" containg a class or function named "Dwoo_Processor_name"');
- }
-
- /**
- * Adds an used plugin, this is reserved for use by the {template} plugin.
- * this is required so that plugin loading bubbles up from loaded
- * template files to the current one
- *
- * @private
- *
- * @param string $name function name
- * @param int $type plugin type (Core::*_PLUGIN)
- */
- public function addUsedPlugin($name, $type)
- {
- $this->usedPlugins[$name] = $type;
- }
-
- /**
- * Returns all the plugins this template uses.
- *
- * @private
- * @return array the list of used plugins in the parsed template
- */
- public function getUsedPlugins()
- {
- return $this->usedPlugins;
- }
-
- /**
- * Adds a template plugin, this is reserved for use by the {template} plugin.
- * this is required because the template functions are not declared yet
- * during compilation, so we must have a way of validating their argument
- * signature without using the reflection api
- *
- * @private
- *
- * @param string $name function name
- * @param array $params parameter array to help validate the function call
- * @param string $uuid unique id of the function
- * @param string $body function php code
- */
- public function addTemplatePlugin($name, array $params, $uuid, $body = null)
- {
- $this->templatePlugins[$name] = array('params' => $params, 'body' => $body, 'uuid' => $uuid);
- }
-
- /**
- * Returns all the parsed sub-templates.
- *
- * @private
- * @return array the parsed sub-templates
- */
- public function getTemplatePlugins()
- {
- return $this->templatePlugins;
- }
-
- /**
- * Marks a template plugin as being called, which means its source must be included in the compiled template.
- *
- * @param string $name function name
- */
- public function useTemplatePlugin($name)
- {
- $this->templatePlugins[$name]['called'] = true;
- }
-
- /**
- * Adds the custom plugins loaded into Dwoo to the compiler so it can load them.
- *
- * @see Core::addPlugin
- *
- * @param array $customPlugins an array of custom plugins
- */
- public function setCustomPlugins(array $customPlugins)
- {
- $this->customPlugins = $customPlugins;
- }
-
- /**
- * Sets the security policy object to enforce some php security settings.
- * use this if untrusted persons can modify templates,
- * set it on the Dwoo object as it will be passed onto the compiler automatically
- *
- * @param SecurityPolicy $policy the security policy object
- */
- public function setSecurityPolicy(SecurityPolicy $policy = null)
- {
- $this->securityPolicy = $policy;
- }
-
- /**
- * Returns the current security policy object or null by default.
- *
- * @return SecurityPolicy|null the security policy object if any
- */
- public function getSecurityPolicy()
- {
- return $this->securityPolicy;
- }
-
- /**
- * Sets the pointer position.
- *
- * @param int $position the new pointer position
- * @param bool $isOffset if set to true, the position acts as an offset and not an absolute position
- */
- public function setPointer($position, $isOffset = false)
- {
- if ($isOffset) {
- $this->pointer += $position;
- } else {
- $this->pointer = $position;
- }
- }
-
- /**
- * Returns the current pointer position, only available during compilation of a template.
- *
- * @return int
- */
- public function getPointer()
- {
- return $this->pointer;
- }
-
- /**
- * Sets the line number.
- *
- * @param int $number the new line number
- * @param bool $isOffset if set to true, the position acts as an offset and not an absolute position
- */
- public function setLine($number, $isOffset = false)
- {
- if ($isOffset) {
- $this->line += $number;
- } else {
- $this->line = $number;
- }
- }
-
- /**
- * Returns the current line number, only available during compilation of a template.
- *
- * @return int
- */
- public function getLine()
- {
- return $this->line;
- }
-
- /**
- * Returns the dwoo object that initiated this template compilation, only available during compilation of a
- * template.
- *
- * @return Core
- */
- public function getCore()
- {
- return $this->core;
- }
-
- /**
- * Overwrites the template that is being compiled.
- *
- * @param string $newSource the template source that must replace the current one
- * @param bool $fromPointer if set to true, only the source from the current pointer position is replaced
- *
- * @return void
- */
- public function setTemplateSource($newSource, $fromPointer = false)
- {
- if ($fromPointer === true) {
- $this->templateSource = substr($this->templateSource, 0, $this->pointer) . $newSource;
- } else {
- $this->templateSource = $newSource;
- }
- }
-
- /**
- * Returns the template that is being compiled.
- *
- * @param mixed $fromPointer if set to true, only the source from the current pointer
- * position is returned, if a number is given it overrides the current pointer
- *
- * @return string the template or partial template
- */
- public function getTemplateSource($fromPointer = false)
- {
- if ($fromPointer === true) {
- return substr($this->templateSource, $this->pointer);
- } elseif (is_numeric($fromPointer)) {
- return substr($this->templateSource, $fromPointer);
- } else {
- return $this->templateSource;
- }
- }
-
- /**
- * Resets the compilation pointer, effectively restarting the compilation process.
- * this is useful if a plugin modifies the template source since it might need to be recompiled
- */
- public function recompile()
- {
- $this->setPointer(0);
- }
-
- /**
- * Compiles the provided string down to php code.
- *
- * @param Core $core
- * @param ITemplate $template the template to compile
- *
- * @return string a compiled php string
- * @throws CompilationException
- */
- public function compile(Core $core, ITemplate $template)
- {
- // init vars
- // $compiled = '';
- $tpl = $template->getSource();
- $ptr = 0;
- $this->core = $core;
- $this->template = $template;
- $this->templateSource = &$tpl;
- $this->pointer = &$ptr;
-
- while (true) {
- // if pointer is at the beginning, reset everything, that allows a plugin to externally reset the compiler if everything must be reparsed
- if ($ptr === 0) {
- // resets variables
- $this->usedPlugins = array();
- $this->data = array();
- $this->scope = &$this->data;
- $this->scopeTree = array();
- $this->stack = array();
- $this->line = 1;
- $this->templatePlugins = array();
- // add top level block
- $compiled = $this->addBlock('TopLevelBlock', array(), 0);
- $this->stack[0]['buffer'] = '';
-
- if ($this->debug) {
- echo "\n";
- echo 'COMPILER INIT' . "\n";
- }
-
- if ($this->debug) {
- echo 'PROCESSING PREPROCESSORS (' . count($this->processors['pre']) . ')' . "\n";
- }
-
- // runs preprocessors
- foreach ($this->processors['pre'] as $preProc) {
- if (is_array($preProc) && isset($preProc['autoload'])) {
- $preProc = $this->loadProcessor($preProc['class'], $preProc['name']);
- }
- if (is_array($preProc) && $preProc[0] instanceof Processor) {
- $tpl = call_user_func($preProc, $tpl);
- } else {
- $tpl = call_user_func($preProc, $this, $tpl);
- }
- }
- unset($preProc);
-
- // show template source if debug
- if ($this->debug) {
- echo '
'.print_r(htmlentities($tpl), true).'
'."\n";
- }
-
- // strips php tags if required by the security policy
- if ($this->securityPolicy !== null) {
- $search = array('{<\?php.*?\?>}');
- if (ini_get('short_open_tags')) {
- $search = array('{<\?.*?\?>}', '{<%.*?%>}');
- }
- switch ($this->securityPolicy->getPhpHandling()) {
- case SecurityPolicy::PHP_ALLOW:
- break;
- case SecurityPolicy::PHP_ENCODE:
- $tpl = preg_replace_callback($search, array($this, 'phpTagEncodingHelper'), $tpl);
- break;
- case SecurityPolicy::PHP_REMOVE:
- $tpl = preg_replace($search, '', $tpl);
- }
- }
- }
-
- $pos = strpos($tpl, $this->ld, $ptr);
-
- if ($pos === false) {
- $this->push(substr($tpl, $ptr), 0);
- break;
- } elseif (substr($tpl, $pos - 1, 1) === '\\' && substr($tpl, $pos - 2, 1) !== '\\') {
- $this->push(substr($tpl, $ptr, $pos - $ptr - 1) . $this->ld);
- $ptr = $pos + strlen($this->ld);
- } elseif (preg_match('/^' . $this->ldr . ($this->allowLooseOpenings ? '\s*' : '') . 'literal' . ($this->allowLooseOpenings ? '\s*' : '') . $this->rdr . '/s', substr($tpl, $pos), $litOpen)) {
- if (!preg_match('/' . $this->ldr . ($this->allowLooseOpenings ? '\s*' : '') . '\/literal' . ($this->allowLooseOpenings ? '\s*' : '') . $this->rdr . '/s', $tpl, $litClose, PREG_OFFSET_CAPTURE, $pos)) {
- throw new CompilationException($this, 'The {literal} blocks must be closed explicitly with {/literal}');
- }
- $endpos = $litClose[0][1];
- $this->push(substr($tpl, $ptr, $pos - $ptr) . substr($tpl, $pos + strlen($litOpen[0]), $endpos - $pos - strlen($litOpen[0])));
- $ptr = $endpos + strlen($litClose[0][0]);
- } else {
- if (substr($tpl, $pos - 2, 1) === '\\' && substr($tpl, $pos - 1, 1) === '\\') {
- $this->push(substr($tpl, $ptr, $pos - $ptr - 1));
- $ptr = $pos;
- }
-
- $this->push(substr($tpl, $ptr, $pos - $ptr));
- $ptr = $pos;
-
- $pos += strlen($this->ld);
- if ($this->allowLooseOpenings) {
- while (substr($tpl, $pos, 1) === ' ') {
- $pos += 1;
- }
- } else {
- if (substr($tpl, $pos, 1) === ' ' || substr($tpl, $pos, 1) === "\r" || substr($tpl, $pos, 1) === "\n" || substr($tpl, $pos, 1) === "\t") {
- $ptr = $pos;
- $this->push($this->ld);
- continue;
- }
- }
-
- // check that there is an end tag present
- if (strpos($tpl, $this->rd, $pos) === false) {
- throw new CompilationException($this, 'A template tag was not closed, started with "' . substr($tpl, $ptr, 30) . '"');
- }
-
- $ptr += strlen($this->ld);
- $subptr = $ptr;
-
- while (true) {
- $parsed = $this->parse($tpl, $subptr, null, false, 'root', $subptr);
-
- // reload loop if the compiler was reset
- if ($ptr === 0) {
- continue 2;
- }
-
- $len = $subptr - $ptr;
- $this->push($parsed, substr_count(substr($tpl, $ptr, $len), "\n"));
- $ptr += $len;
-
- if ($parsed === false) {
- break;
- }
- }
- }
- }
-
- $compiled .= $this->removeBlock('TopLevelBlock');
-
- if ($this->debug) {
- echo 'PROCESSING POSTPROCESSORS' . "\n";
- }
-
- foreach ($this->processors['post'] as $postProc) {
- if (is_array($postProc) && isset($postProc['autoload'])) {
- $postProc = $this->loadProcessor($postProc['class'], $postProc['name']);
- }
- if (is_array($postProc) && $postProc[0] instanceof Processor) {
- $compiled = call_user_func($postProc, $compiled);
- } else {
- $compiled = call_user_func($postProc, $this, $compiled);
- }
- }
- unset($postProc);
-
- if ($this->debug) {
- echo 'COMPILATION COMPLETE : MEM USAGE : ' . memory_get_usage() . "\n";
- }
-
- $output = "getUsedPlugins() as $plugin => $type) {
- if ($type & Core::CUSTOM_PLUGIN) {
- continue;
- }
-
- switch ($type) {
- case Core::CLASS_PLUGIN:
- case Core::CLASS_PLUGIN + Core::BLOCK_PLUGIN:
- if (class_exists('Plugin' . $plugin) !== false) {
- $output .= "if (class_exists('" . "Plugin" . $plugin . "')===false)".
- "\n\t\$this->getLoader()->loadPlugin('Plugin$plugin');\n";
- } else {
- $output .= "if (class_exists('" . Core::NAMESPACE_PLUGINS_BLOCKS . "Plugin" . $plugin . "')===false)".
- "\n\t\$this->getLoader()->loadPlugin('Plugin$plugin');\n";
- }
- break;
- case Core::CLASS_PLUGIN + Core::FUNC_PLUGIN:
- if (class_exists('Plugin' . $plugin) !== false) {
- $output .= "if (class_exists('" . "Plugin" . $plugin . "')===false)".
- "\n\t\$this->getLoader()->loadPlugin('Plugin$plugin');\n";
- } else {
- $output .= "if (class_exists('" . Core::NAMESPACE_PLUGINS_FUNCTIONS . "Plugin" . $plugin . "')===false)".
- "\n\t\$this->getLoader()->loadPlugin('Plugin$plugin');\n";
- }
- break;
- case Core::FUNC_PLUGIN:
- if (function_exists('Plugin' . $plugin) !== false) {
- $output .= "if (function_exists('" . "Plugin" . $plugin . "')===false)".
- "\n\t\$this->getLoader()->loadPlugin('Plugin$plugin');\n";
- } else {
- $output .= "if (function_exists('" . Core::NAMESPACE_PLUGINS_FUNCTIONS . "Plugin" . $plugin . "')===false)".
- "\n\t\$this->getLoader()->loadPlugin('Plugin$plugin');\n";
- }
- break;
- case Core::SMARTY_MODIFIER:
- $output .= "if (function_exists('smarty_modifier_$plugin')===false)".
- "\n\t\$this->getLoader()->loadPlugin('$plugin');\n";
- break;
- case Core::SMARTY_FUNCTION:
- $output .= "if (function_exists('smarty_function_$plugin')===false)".
- "\n\t\$this->getLoader()->loadPlugin('$plugin');\n";
- break;
- case Core::SMARTY_BLOCK:
- $output .= "if (function_exists('smarty_block_$plugin')===false)".
- "\n\t\$this->getLoader()->loadPlugin('$plugin');\n";
- break;
- case Core::PROXY_PLUGIN:
- $output .= $this->getCore()->getPluginProxy()->getLoader($plugin);
- break;
- default:
- throw new CompilationException($this, 'Type error for ' . $plugin . ' with type' . $type);
- }
- }
-
- foreach ($this->templatePlugins as $function => $attr) {
- if (isset($attr['called']) && $attr['called'] === true && !isset($attr['checked'])) {
- $this->resolveSubTemplateDependencies($function);
- }
- }
- foreach ($this->templatePlugins as $function) {
- if (isset($function['called']) && $function['called'] === true) {
- $output .= $function['body'] . PHP_EOL;
- }
- }
-
- $output .= $compiled . "\n?>";
-
- $output = preg_replace('/(?\s*)<\?xml#is', '$1', $output);
-
- // add another line break after PHP closing tags that have a line break following,
- // as we do not know whether it's intended, and PHP will strip it otherwise
- $output = preg_replace('/(?\n/', '$0' . "\n", $output);
-
- if ($this->debug) {
- echo '=============================================================================================' . "\n";
- $lines = preg_split('{\r\n|\n| }', $output);
- array_shift($lines);
- foreach ($lines as $i => $line) {
- echo ($i + 1) . '. ' . $line . "\r\n";
- }
- echo '=============================================================================================' . "\n";
- }
-
- $this->template = $this->dwoo = null;
- $tpl = null;
-
- return $output;
- }
-
- /**
- * Checks what sub-templates are used in every sub-template so that we're sure they are all compiled.
- *
- * @param string $function the sub-template name
- */
- protected function resolveSubTemplateDependencies($function)
- {
- if ($this->debug) {
- echo 'Compiler::' . __FUNCTION__ . "\n";
- }
-
- $body = $this->templatePlugins[$function]['body'];
- foreach ($this->templatePlugins as $func => $attr) {
- if ($func !== $function && !isset($attr['called']) && strpos($body, Core::NAMESPACE_PLUGINS_FUNCTIONS .
- 'Plugin' . Core::toCamelCase($func)) !== false) {
- $this->templatePlugins[$func]['called'] = true;
- $this->resolveSubTemplateDependencies($func);
- }
- }
- $this->templatePlugins[$function]['checked'] = true;
- }
-
- /**
- * Adds compiled content to the current block.
- *
- * @param string $content the content to push
- * @param int $lineCount newlines count in content, optional
- *
- * @throws CompilationException
- */
- public function push($content, $lineCount = null)
- {
- if ($lineCount === null) {
- $lineCount = substr_count($content, "\n");
- }
-
- if ($this->curBlock['buffer'] === null && count($this->stack) > 1) {
- // buffer is not initialized yet (the block has just been created)
- $this->stack[count($this->stack) - 2]['buffer'] .= (string)$content;
- $this->curBlock['buffer'] = '';
- } else {
- if (!isset($this->curBlock['buffer'])) {
- throw new CompilationException($this, 'The template has been closed too early, you probably have an extra block-closing tag somewhere');
- }
- // append current content to current block's buffer
- $this->curBlock['buffer'] .= (string)$content;
- }
- $this->line += $lineCount;
- }
-
- /**
- * Sets the scope.
- * set to null if the scope becomes "unstable" (i.e. too variable or unknown) so that
- * variables are compiled in a more evaluative way than just $this->scope['key']
- *
- * @param mixed $scope a string i.e. "level1.level2" or an array i.e. array("level1", "level2")
- * @param bool $absolute if true, the scope is set from the top level scope and not from the current scope
- *
- * @return array the current scope tree
- */
- public function setScope($scope, $absolute = false)
- {
- $old = $this->scopeTree;
-
- if ($scope === null) {
- unset($this->scope);
- $this->scope = null;
- }
-
- if (is_array($scope) === false) {
- $scope = explode('.', $scope);
- }
-
- if ($absolute === true) {
- $this->scope = &$this->data;
- $this->scopeTree = array();
- }
-
- while (($bit = array_shift($scope)) !== null) {
- if ($bit === '_parent' || $bit === '_') {
- array_pop($this->scopeTree);
- reset($this->scopeTree);
- $this->scope = &$this->data;
- $cnt = count($this->scopeTree);
- for ($i = 0; $i < $cnt; ++ $i) {
- $this->scope = &$this->scope[$this->scopeTree[$i]];
- }
- } elseif ($bit === '_root' || $bit === '__') {
- $this->scope = &$this->data;
- $this->scopeTree = array();
- } elseif (isset($this->scope[$bit])) {
- $this->scope = &$this->scope[$bit];
- $this->scopeTree[] = $bit;
- } else {
- $this->scope[$bit] = array();
- $this->scope = &$this->scope[$bit];
- $this->scopeTree[] = $bit;
- }
- }
-
- return $old;
- }
-
- /**
- * Adds a block to the top of the block stack.
- *
- * @param string $type block type (name)
- * @param array $params the parameters array
- * @param int $paramtype the parameters type (see mapParams), 0, 1 or 2
- *
- * @return string the preProcessing() method's output
- */
- public function addBlock($type, array $params, $paramtype)
- {
- if ($this->debug) {
- echo 'Compiler::' . __FUNCTION__ . "\n";
- }
-
- $class = Core::NAMESPACE_PLUGINS_BLOCKS . 'Plugin' . Core::toCamelCase($type);
- if (class_exists($class) === false) {
- $this->getCore()->getLoader()->loadPlugin($type);
- }
- $params = $this->mapParams($params, array($class, 'init'), $paramtype);
-
- $this->stack[] = array(
- 'type' => $type,
- 'params' => $params,
- 'custom' => false,
- 'class' => $class,
- 'buffer' => null
- );
- $this->curBlock = &$this->stack[count($this->stack) - 1];
-
- return call_user_func(array($class, 'preProcessing'), $this, $params, '', '', $type);
- }
-
- /**
- * Adds a custom block to the top of the block stack.
- *
- * @param string $type block type (name)
- * @param array $params the parameters array
- * @param int $paramtype the parameters type (see mapParams), 0, 1 or 2
- *
- * @return string the preProcessing() method's output
- */
- public function addCustomBlock($type, array $params, $paramtype)
- {
- $callback = $this->customPlugins[$type]['callback'];
- if (is_array($callback)) {
- $class = is_object($callback[0]) ? get_class($callback[0]) : $callback[0];
- } else {
- $class = $callback;
- }
-
- $params = $this->mapParams($params, array($class, 'init'), $paramtype);
-
- $this->stack[] = array(
- 'type' => $type,
- 'params' => $params,
- 'custom' => true,
- 'class' => $class,
- 'buffer' => null
- );
- $this->curBlock = &$this->stack[count($this->stack) - 1];
-
- return call_user_func(array($class, 'preProcessing'), $this, $params, '', '', $type);
- }
-
- /**
- * Injects a block at the top of the plugin stack without calling its preProcessing method.
- * used by {else} blocks to re-add themselves after having closed everything up to their parent
- *
- * @param string $type block type (name)
- * @param array $params parameters array
- */
- public function injectBlock($type, array $params)
- {
- if ($this->debug) {
- echo 'Compiler::' . __FUNCTION__ . "\n";
- }
-
- $class = Core::NAMESPACE_PLUGINS_BLOCKS . 'Plugin' . Core::toCamelCase($type);
- if (class_exists($class) === false) {
- $this->getCore()->getLoader()->loadPlugin($type);
- }
- $this->stack[] = array(
- 'type' => $type,
- 'params' => $params,
- 'custom' => false,
- 'class' => $class,
- 'buffer' => null
- );
- $this->curBlock = &$this->stack[count($this->stack) - 1];
- }
-
- /**
- * Removes the closest-to-top block of the given type and all other
- * blocks encountered while going down the block stack.
- *
- * @param string $type block type (name)
- *
- * @return string the output of all postProcessing() method's return values of the closed blocks
- * @throws CompilationException
- */
- public function removeBlock($type)
- {
- if ($this->debug) {
- echo 'Compiler::' . __FUNCTION__ . "\n";
- }
-
- $output = '';
-
- $pluginType = $this->getPluginType($type);
- if ($pluginType & Core::SMARTY_BLOCK) {
- $type = 'Smartyinterface';
- }
- while (true) {
- while ($top = array_pop($this->stack)) {
- if ($top['custom']) {
- $class = $top['class'];
- } else {
- $class = Core::NAMESPACE_PLUGINS_BLOCKS . 'Plugin' . Core::toCamelCase($top['type']);
- }
- if (count($this->stack)) {
- $this->curBlock = &$this->stack[count($this->stack) - 1];
- $this->push(call_user_func(array(
- $class,
- 'postProcessing'
- ), $this, $top['params'], '', '', $top['buffer']), 0);
- } else {
- $null = null;
- $this->curBlock = &$null;
- $output = call_user_func(
- array(
- $class,
- 'postProcessing'
- ), $this, $top['params'], '', '', $top['buffer']
- );
- }
-
- if ($top['type'] === $type) {
- break 2;
- }
- }
-
- throw new CompilationException($this, 'Syntax malformation, a block of type "' . $type . '" was closed but was not opened');
- }
-
- return $output;
- }
-
- /**
- * Returns a reference to the first block of the given type encountered and
- * optionally closes all blocks until it finds it
- * this is mainly used by {else} plugins to close everything that was opened
- * between their parent and themselves.
- *
- * @param string $type the block type (name)
- * @param bool $closeAlong whether to close all blocks encountered while going down the block stack or not
- *
- * @return mixed &array the array is as such: array('type'=>pluginName, 'params'=>parameter array,
- * 'custom'=>bool defining whether it's a custom plugin or not, for internal use)
- * @throws CompilationException
- */
- public function &findBlock($type, $closeAlong = false)
- {
- if ($closeAlong === true) {
- while ($b = end($this->stack)) {
- if ($b['type'] === $type) {
- return $this->stack[key($this->stack)];
- }
- $this->push($this->removeTopBlock(), 0);
- }
- } else {
- end($this->stack);
- while ($b = current($this->stack)) {
- if ($b['type'] === $type) {
- return $this->stack[key($this->stack)];
- }
- prev($this->stack);
- }
- }
-
- throw new CompilationException($this, 'A parent block of type "' . $type . '" is required and can not be found');
- }
-
- /**
- * Returns a reference to the current block array.
- *
- * @return array the array is as such: array('type'=>pluginName, 'params'=>parameter array,
- * 'custom'=>bool defining whether it's a custom plugin or not, for internal use)
- */
- public function &getCurrentBlock()
- {
- return $this->curBlock;
- }
-
- /**
- * Removes the block at the top of the stack and calls its postProcessing() method.
- *
- * @return string the postProcessing() method's output
- * @throws CompilationException
- */
- public function removeTopBlock()
- {
- if ($this->debug) {
- echo 'Compiler::' . __FUNCTION__ . "\n";
- }
-
- $o = array_pop($this->stack);
- if ($o === null) {
- throw new CompilationException($this, 'Syntax malformation, a block of unknown type was closed but was not opened.');
- }
- if ($o['custom']) {
- $class = $o['class'];
- } else {
- $class = Core::NAMESPACE_PLUGINS_BLOCKS . 'Plugin' . Core::toCamelCase($o['type']);
- }
-
- $this->curBlock = &$this->stack[count($this->stack) - 1];
-
- return call_user_func(array($class, 'postProcessing'), $this, $o['params'], '', '', $o['buffer']);
- }
-
- /**
- * Returns the compiled parameters (for example a variable's compiled parameter will be "$this->scope['key']") out
- * of the given parameter array.
- *
- * @param array $params parameter array
- *
- * @return array filtered parameters
- */
- public function getCompiledParams(array $params)
- {
- foreach ($params as $k => $p) {
- if (is_array($p)) {
- $params[$k] = $p[0];
- }
- }
-
- return $params;
- }
-
- /**
- * Returns the real parameters (for example a variable's real parameter will be its key, etc) out of the given
- * parameter array.
- *
- * @param array $params parameter array
- *
- * @return array filtered parameters
- */
- public function getRealParams(array $params)
- {
- foreach ($params as $k => $p) {
- if (is_array($p)) {
- $params[$k] = $p[1];
- }
- }
-
- return $params;
- }
-
- /**
- * Returns the token of each parameter out of the given parameter array.
- *
- * @param array $params parameter array
- *
- * @return array tokens
- */
- public function getParamTokens(array $params)
- {
- foreach ($params as $k => $p) {
- if (is_array($p)) {
- $params[$k] = isset($p[2]) ? $p[2] : 0;
- }
- }
-
- return $params;
- }
-
- /**
- * Entry point of the parser, it redirects calls to other parse* functions.
- *
- * @param string $in the string within which we must parse something
- * @param int $from the starting offset of the parsed area
- * @param int $to the ending offset of the parsed area
- * @param mixed $parsingParams must be an array if we are parsing a function or modifier's parameters, or false by
- * default
- * @param string $curBlock the current parser-block being processed
- * @param mixed $pointer a reference to a pointer that will be increased by the amount of characters parsed,
- * or null by default
- *
- * @return string parsed values
- * @throws CompilationException
- */
- protected function parse($in, $from, $to, $parsingParams = false, $curBlock = '', &$pointer = null)
- {
- if ($this->debug) {
- echo 'Compiler::' . __FUNCTION__ . "\n";
- }
-
- if ($to === null) {
- $to = strlen($in);
- }
- $first = substr($in, $from, 1);
-
- if ($first === false) {
- throw new CompilationException($this, 'Unexpected EOF, a template tag was not closed');
- }
-
- while ($first === ' ' || $first === "\n" || $first === "\t" || $first === "\r") {
- if ($curBlock === 'root' && substr($in, $from, strlen($this->rd)) === $this->rd) {
- // end template tag
- $pointer += strlen($this->rd);
- if ($this->debug) {
- echo 'TEMPLATE PARSING ENDED' . "\n";
- }
-
- return false;
- }
- ++ $from;
- if ($pointer !== null) {
- ++ $pointer;
- }
- if ($from >= $to) {
- if (is_array($parsingParams)) {
- return $parsingParams;
- } else {
- return '';
- }
- }
- $first = $in[$from];
- }
-
- $substr = substr($in, $from, $to - $from);
-
- if ($this->debug) {
- echo 'PARSE CALL : PARSING "' . htmlentities(substr($in, $from, min($to - $from, 50))) . (($to - $from) > 50 ? '...' : '') . '" @ ' . $from . ':' . $to . ' in ' . $curBlock . ' : pointer=' . $pointer . "\n";
- }
- $parsed = '';
-
- if ($curBlock === 'root' && $first === '*') {
- $src = $this->getTemplateSource();
- $startpos = $this->getPointer() - strlen($this->ld);
- if (substr($src, $startpos, strlen($this->ld)) === $this->ld) {
- if ($startpos > 0) {
- do {
- $char = substr($src, -- $startpos, 1);
- if ($char == "\n") {
- ++ $startpos;
- $whitespaceStart = true;
- break;
- }
- }
- while ($startpos > 0 && ($char == ' ' || $char == "\t"));
- }
-
- if (!isset($whitespaceStart)) {
- $startpos = $this->getPointer();
- } else {
- $pointer -= $this->getPointer() - $startpos;
- }
-
- if ($this->allowNestedComments && strpos($src, $this->ld . '*', $this->getPointer()) !== false) {
- $comOpen = $this->ld . '*';
- $comClose = '*' . $this->rd;
- $level = 1;
- $ptr = $this->getPointer();
-
- while ($level > 0 && $ptr < strlen($src)) {
- $open = strpos($src, $comOpen, $ptr);
- $close = strpos($src, $comClose, $ptr);
-
- if ($open !== false && $close !== false) {
- if ($open < $close) {
- $ptr = $open + strlen($comOpen);
- ++ $level;
- } else {
- $ptr = $close + strlen($comClose);
- -- $level;
- }
- } elseif ($open !== false) {
- $ptr = $open + strlen($comOpen);
- ++ $level;
- } elseif ($close !== false) {
- $ptr = $close + strlen($comClose);
- -- $level;
- } else {
- $ptr = strlen($src);
- }
- }
- $endpos = $ptr - strlen('*' . $this->rd);
- } else {
- $endpos = strpos($src, '*' . $this->rd, $startpos);
- if ($endpos == false) {
- throw new CompilationException($this, 'Un-ended comment');
- }
- }
- $pointer += $endpos - $startpos + strlen('*' . $this->rd);
- if (isset($whitespaceStart) && preg_match('#^[\t ]*\r?\n#', substr($src, $endpos + strlen('*' . $this->rd)), $m)) {
- $pointer += strlen($m[0]);
- $this->curBlock['buffer'] = substr($this->curBlock['buffer'], 0, strlen($this->curBlock['buffer']) - ($this->getPointer() - $startpos - strlen($this->ld)));
- }
-
- return false;
- }
- }
-
- if ($first === '$') {
- // var
- $out = $this->parseVar($in, $from, $to, $parsingParams, $curBlock, $pointer);
- $parsed = 'var';
- } elseif ($first === '%' && preg_match('#^%[a-z_\\\\]#i', $substr)) {
- // Short constant
- $out = $this->parseConst($in, $from, $to, $parsingParams, $curBlock, $pointer);
- } elseif (($first === '"' || $first === "'") && !(is_array($parsingParams) && preg_match('#^([\'"])[a-z0-9_]+\1\s*=>?(?:\s+|[^=])#i', $substr))) {
- // string
- $out = $this->parseString($in, $from, $to, $parsingParams, $curBlock, $pointer);
- } elseif (preg_match('/^\\\\?[a-z_](?:\\\\?[a-z0-9_]+)*(?:::[a-z_][a-z0-9_]*)?(' . (is_array($parsingParams) || $curBlock != 'root' ? '' : '\s+[^(]|') . '\s*\(|\s*' . $this->rdr . '|\s*;)/i', $substr)) {
- // func
- $out = $this->parseFunction($in, $from, $to, $parsingParams, $curBlock, $pointer);
- $parsed = 'func';
- } elseif ($first === ';') {
- // instruction end
- if ($this->debug) {
- echo 'END OF INSTRUCTION' . "\n";
- }
- if ($pointer !== null) {
- ++ $pointer;
- }
-
- return $this->parse($in, $from + 1, $to, false, 'root', $pointer);
- } elseif ($curBlock === 'root' && preg_match('#^/([a-z_][a-z0-9_]*)?#i', $substr, $match)) {
- // close block
- if (!empty($match[1]) && $match[1] == 'else') {
- throw new CompilationException($this, 'Else blocks must not be closed explicitly, they are automatically closed when their parent block is closed');
- }
- if (!empty($match[1]) && $match[1] == 'elseif') {
- throw new CompilationException($this, 'Elseif blocks must not be closed explicitly, they are automatically closed when their parent block is closed or a new else/elseif block is declared after them');
- }
- if ($pointer !== null) {
- $pointer += strlen($match[0]);
- }
- if (empty($match[1])) {
- if ($this->curBlock['type'] == 'else' || $this->curBlock['type'] == 'elseif') {
- $pointer -= strlen($match[0]);
- }
- if ($this->debug) {
- echo 'TOP BLOCK CLOSED' . "\n";
- }
-
- return $this->removeTopBlock();
- } else {
- if ($this->debug) {
- echo 'BLOCK OF TYPE ' . $match[1] . ' CLOSED' . "\n";
- }
-
- return $this->removeBlock($match[1]);
- }
- } elseif ($curBlock === 'root' && substr($substr, 0, strlen($this->rd)) === $this->rd) {
- // end template tag
- if ($this->debug) {
- echo 'TAG PARSING ENDED' . "\n";
- }
- $pointer += strlen($this->rd);
-
- return false;
- } elseif (is_array($parsingParams) && preg_match('#^(([\'"]?)[a-z0-9_]+\2\s*=' . ($curBlock === 'array' ? '>?' : '') . ')(?:\s+|[^=]).*#i', $substr, $match)) {
- // named parameter
- if ($this->debug) {
- echo 'NAMED PARAM FOUND' . "\n";
- }
- $len = strlen($match[1]);
- while (substr($in, $from + $len, 1) === ' ') {
- ++ $len;
- }
- if ($pointer !== null) {
- $pointer += $len;
- }
-
- $output = array(
- trim($match[1], " \t\r\n=>'\""),
- $this->parse($in, $from + $len, $to, false, 'namedparam', $pointer)
- );
-
- $parsingParams[] = $output;
-
- return $parsingParams;
- } elseif (preg_match('#^(\\\\?[a-z_](?:\\\\?[a-z0-9_]+)*::\$[a-z0-9_]+)#i', $substr, $match)) {
- // static member access
- $parsed = 'var';
- if (is_array($parsingParams)) {
- $parsingParams[] = array($match[1], $match[1]);
- $out = $parsingParams;
- } else {
- $out = $match[1];
- }
- $pointer += strlen($match[1]);
- } elseif ($substr !== '' && (is_array($parsingParams) || $curBlock === 'namedparam' || $curBlock === 'condition' || $curBlock === 'expression')) {
- // unquoted string, bool or number
- $out = $this->parseOthers($in, $from, $to, $parsingParams, $curBlock, $pointer);
- } else {
- // parse error
- throw new CompilationException($this, 'Parse error in "' . substr($in, $from, $to - $from) . '"');
- }
-
- if (empty($out)) {
- return '';
- }
-
- $substr = substr($in, $pointer, $to - $pointer);
-
- // var parsed, check if any var-extension applies
- if ($parsed === 'var') {
- if (preg_match('#^\s*([/%+*-])\s*([a-z0-9]|\$)#i', $substr, $match)) {
- if ($this->debug) {
- echo 'PARSING POST-VAR EXPRESSION ' . $substr . "\n";
- }
- // parse expressions
- $pointer += strlen($match[0]) - 1;
- if (is_array($parsingParams)) {
- if ($match[2] == '$') {
- $expr = $this->parseVar($in, $pointer, $to, array(), $curBlock, $pointer);
- } else {
- $expr = $this->parse($in, $pointer, $to, array(), 'expression', $pointer);
- }
- $out[count($out) - 1][0] .= $match[1] . $expr[0][0];
- $out[count($out) - 1][1] .= $match[1] . $expr[0][1];
- } else {
- if ($match[2] == '$') {
- $expr = $this->parseVar($in, $pointer, $to, false, $curBlock, $pointer);
- } else {
- $expr = $this->parse($in, $pointer, $to, false, 'expression', $pointer);
- }
- if (is_array($out) && is_array($expr)) {
- $out[0] .= $match[1] . $expr[0];
- $out[1] .= $match[1] . $expr[1];
- } elseif (is_array($out)) {
- $out[0] .= $match[1] . $expr;
- $out[1] .= $match[1] . $expr;
- } elseif (is_array($expr)) {
- $out .= $match[1] . $expr[0];
- } else {
- $out .= $match[1] . $expr;
- }
- }
- } elseif ($curBlock === 'root' && preg_match('#^(\s*(?:[+/*%-.]=|=|\+\+|--)\s*)(.*)#s', $substr, $match)) {
- if ($this->debug) {
- echo 'PARSING POST-VAR ASSIGNMENT ' . $substr . "\n";
- }
- // parse assignment
- $value = $match[2];
- $operator = trim($match[1]);
- if (substr($value, 0, 1) == '=') {
- throw new CompilationException($this, 'Unexpected "=" in ' . $substr . '');
- }
-
- if ($pointer !== null) {
- $pointer += strlen($match[1]);
- }
-
- if ($operator !== '++' && $operator !== '--') {
- $parts = array();
- $ptr = 0;
- $parts = $this->parse($value, 0, strlen($value), $parts, 'condition', $ptr);
- $pointer += $ptr;
-
- // load if plugin
- try {
- $this->getPluginType('if');
- }
- catch (Exception $e) {
- throw new CompilationException($this, 'Assignments require the "if" plugin to be accessible');
- }
-
- $parts = $this->mapParams($parts, array(Core::NAMESPACE_PLUGINS_BLOCKS . 'PluginIf', 'init'), 1);
- $tokens = $this->getParamTokens($parts);
- $parts = $this->getCompiledParams($parts);
-
- $value = PluginIf::replaceKeywords($parts['*'], $tokens['*'], $this);
- $echo = '';
- } else {
- $value = array();
- $echo = 'echo ';
- }
-
- if ($this->autoEscape) {
- $out = preg_replace('#\(is_string\(\$tmp=(.+?)\) \? htmlspecialchars\(\$tmp, ENT_QUOTES, \$this->charset\) : \$tmp\)#', '$1', $out);
- }
- $out = self::PHP_OPEN . $echo . $out . $operator . implode(' ', $value) . self::PHP_CLOSE;
- } elseif ($curBlock === 'array' && is_array($parsingParams) && preg_match('#^(\s*=>?\s*)#', $substr, $match)) {
- // parse namedparam with var as name (only for array)
- if ($this->debug) {
- echo 'VARIABLE NAMED PARAM (FOR ARRAY) FOUND' . "\n";
- }
- $len = strlen($match[1]);
- $var = $out[count($out) - 1];
- $pointer += $len;
-
- $output = array($var[0], $this->parse($substr, $len, null, false, 'namedparam', $pointer));
-
- $parsingParams[] = $output;
-
- return $parsingParams;
- }
- }
-
- if ($curBlock !== 'modifier' && ($parsed === 'func' || $parsed === 'var') && preg_match('#^(\|@?[a-z0-9_]+(:.*)?)+#i', $substr, $match)) {
- // parse modifier on funcs or vars
- $srcPointer = $pointer;
- if (is_array($parsingParams)) {
- $tmp = $this->replaceModifiers(
- array(
- null,
- null,
- $out[count($out) - 1][0],
- $match[0]
- ), $curBlock, $pointer
- );
- $out[count($out) - 1][0] = $tmp;
- $out[count($out) - 1][1] .= substr($substr, $srcPointer, $srcPointer - $pointer);
- } else {
- $out = $this->replaceModifiers(array(null, null, $out, $match[0]), $curBlock, $pointer);
- }
- }
-
- // func parsed, check if any func-extension applies
- if ($parsed === 'func' && preg_match('#^->[a-z0-9_]+(\s*\(.+|->[a-z_].*)?#is', $substr, $match)) {
- // parse method call or property read
- $ptr = 0;
-
- if (is_array($parsingParams)) {
- $output = $this->parseMethodCall($out[count($out) - 1][1], $match[0], $curBlock, $ptr);
-
- $out[count($out) - 1][0] = $output;
- $out[count($out) - 1][1] .= substr($match[0], 0, $ptr);
- } else {
- $out = $this->parseMethodCall($out, $match[0], $curBlock, $ptr);
- }
-
- $pointer += $ptr;
- }
-
- if ($curBlock === 'root' && substr($out, 0, strlen(self::PHP_OPEN)) !== self::PHP_OPEN) {
- return self::PHP_OPEN . 'echo ' . $out . ';' . self::PHP_CLOSE;
- }
-
- return $out;
- }
-
- /**
- * Parses a function call.
- *
- * @param string $in the string within which we must parse something
- * @param int $from the starting offset of the parsed area
- * @param int $to the ending offset of the parsed area
- * @param mixed $parsingParams must be an array if we are parsing a function or modifier's parameters, or false by
- * default
- * @param string $curBlock the current parser-block being processed
- * @param mixed $pointer a reference to a pointer that will be increased by the amount of characters parsed,
- * or null by default
- *
- * @return string parsed values
- * @throws CompilationException
- * @throws Exception
- * @throws SecurityException
- */
- protected function parseFunction($in, $from, $to, $parsingParams = false, $curBlock = '', &$pointer = null)
- {
- $output = '';
- $cmdstr = substr($in, $from, $to - $from);
- preg_match('/^(\\\\?[a-z_](?:\\\\?[a-z0-9_]+)*(?:::[a-z_][a-z0-9_]*)?)(\s*' . $this->rdr . '|\s*;)?/i', $cmdstr, $match);
-
- if (empty($match[1])) {
- throw new CompilationException($this, 'Parse error, invalid function name : ' . substr($cmdstr, 0, 15));
- }
-
- $func = $match[1];
-
- if (!empty($match[2])) {
- $cmdstr = $match[1];
- }
-
- if ($this->debug) {
- echo 'FUNC FOUND (' . $func . ')' . "\n";
- }
-
- $paramsep = '';
-
- if (is_array($parsingParams) || $curBlock != 'root') {
- $paramspos = strpos($cmdstr, '(');
- $paramsep = ')';
- } elseif (preg_match_all('#^\s*[\\\\:a-z0-9_]+(\s*\(|\s+[^(])#i', $cmdstr, $match, PREG_OFFSET_CAPTURE)) {
- $paramspos = $match[1][0][1];
- $paramsep = substr($match[1][0][0], - 1) === '(' ? ')' : '';
- if ($paramsep === ')') {
- $paramspos += strlen($match[1][0][0]) - 1;
- if (substr($cmdstr, 0, 2) === 'if' || substr($cmdstr, 0, 6) === 'elseif') {
- $paramsep = '';
- if (strlen($match[1][0][0]) > 1) {
- -- $paramspos;
- }
- }
- }
- } else {
- $paramspos = false;
- }
-
- $state = 0;
-
- if ($paramspos === false) {
- $params = array();
-
- if ($curBlock !== 'root') {
- return $this->parseOthers($in, $from, $to, $parsingParams, $curBlock, $pointer);
- }
- } else {
- if ($curBlock === 'condition') {
- // load if plugin
- $this->getPluginType('if');
-
- if (PluginIf::replaceKeywords(array($func), array(self::T_UNQUOTED_STRING), $this) !== array($func)) {
- return $this->parseOthers($in, $from, $to, $parsingParams, $curBlock, $pointer);
- }
- }
- $whitespace = strlen(substr($cmdstr, strlen($func), $paramspos - strlen($func)));
- $paramstr = substr($cmdstr, $paramspos + 1);
- if (substr($paramstr, - 1, 1) === $paramsep) {
- $paramstr = substr($paramstr, 0, - 1);
- }
-
- if (strlen($paramstr) === 0) {
- $params = array();
- $paramstr = '';
- } else {
- $ptr = 0;
- $params = array();
- if ($func === 'empty') {
- $params = $this->parseVar($paramstr, $ptr, strlen($paramstr), $params, 'root', $ptr);
- } else {
- while ($ptr < strlen($paramstr)) {
- while (true) {
- if ($ptr >= strlen($paramstr)) {
- break 2;
- }
-
- if ($func !== 'if' && $func !== 'elseif' && $paramstr[$ptr] === ')') {
- if ($this->debug) {
- echo 'PARAM PARSING ENDED, ")" FOUND, POINTER AT ' . $ptr . "\n";
- }
- break 2;
- } elseif ($paramstr[$ptr] === ';') {
- ++ $ptr;
- if ($this->debug) {
- echo 'PARAM PARSING ENDED, ";" FOUND, POINTER AT ' . $ptr . "\n";
- }
- break 2;
- } elseif ($func !== 'if' && $func !== 'elseif' && $paramstr[$ptr] === '/') {
- if ($this->debug) {
- echo 'PARAM PARSING ENDED, "/" FOUND, POINTER AT ' . $ptr . "\n";
- }
- break 2;
- } elseif (substr($paramstr, $ptr, strlen($this->rd)) === $this->rd) {
- if ($this->debug) {
- echo 'PARAM PARSING ENDED, RIGHT DELIMITER FOUND, POINTER AT ' . $ptr . "\n";
- }
- break 2;
- }
-
- if ($paramstr[$ptr] === ' ' || $paramstr[$ptr] === ',' || $paramstr[$ptr] === "\r" || $paramstr[$ptr] === "\n" || $paramstr[$ptr] === "\t") {
- ++ $ptr;
- } else {
- break;
- }
- }
-
- if ($this->debug) {
- echo 'FUNC START PARAM PARSING WITH POINTER AT ' . $ptr . "\n";
- }
-
- if ($func === 'if' || $func === 'elseif' || $func === 'tif') {
- $params = $this->parse($paramstr, $ptr, strlen($paramstr), $params, 'condition', $ptr);
- } elseif ($func === 'array') {
- $params = $this->parse($paramstr, $ptr, strlen($paramstr), $params, 'array', $ptr);
- } else {
- $params = $this->parse($paramstr, $ptr, strlen($paramstr), $params, 'function', $ptr);
- }
-
- if ($this->debug) {
- echo 'PARAM PARSED, POINTER AT ' . $ptr . ' (' . substr($paramstr, $ptr - 1, 3) . ')' . "\n";
- }
- }
- }
- $paramstr = substr($paramstr, 0, $ptr);
- $state = 0;
- foreach ($params as $k => $p) {
- if (is_array($p) && is_array($p[1])) {
- $state |= 2;
- } else {
- if (($state & 2) && preg_match('#^(["\'])(.+?)\1$#', $p[0], $m) && $func !== 'array') {
- $params[$k] = array($m[2], array('true', 'true'));
- } else {
- if ($state & 2 && $func !== 'array') {
- throw new CompilationException($this, 'You can not use an unnamed parameter after a named one');
- }
- $state |= 1;
- }
- }
- }
- }
- }
-
- if ($pointer !== null) {
- $pointer += (isset($paramstr) ? strlen($paramstr) : 0) + (')' === $paramsep ? 2 : ($paramspos === false ? 0 : 1)) + strlen($func) + (isset($whitespace) ? $whitespace : 0);
- if ($this->debug) {
- echo 'FUNC ADDS ' . ((isset($paramstr) ? strlen($paramstr) : 0) + (')' === $paramsep ? 2 : ($paramspos === false ? 0 : 1)) + strlen($func)) . ' TO POINTER' . "\n";
- }
- }
-
- if ($curBlock === 'method' || $func === 'do' || strstr($func, '::') !== false) {
- // handle static method calls with security policy
- if (strstr($func, '::') !== false && $this->securityPolicy !== null && $this->securityPolicy->isMethodAllowed(explode('::', strtolower($func))) !== true) {
- throw new SecurityException('Call to a disallowed php function : ' . $func);
- }
- $pluginType = Core::NATIVE_PLUGIN;
- } else {
- $pluginType = $this->getPluginType($func);
- }
-
- // Blocks plugin
- if ($pluginType & Core::BLOCK_PLUGIN) {
- if ($curBlock !== 'root' || is_array($parsingParams)) {
- throw new CompilationException($this, 'Block plugins can not be used as other plugin\'s arguments');
- }
- if ($pluginType & Core::CUSTOM_PLUGIN) {
- return $this->addCustomBlock($func, $params, $state);
- } else {
- return $this->addBlock($func, $params, $state);
- }
- } elseif ($pluginType & Core::SMARTY_BLOCK) {
- if ($curBlock !== 'root' || is_array($parsingParams)) {
- throw new CompilationException($this, 'Block plugins can not be used as other plugin\'s arguments');
- }
-
- if ($state & 2) {
- array_unshift($params, array('__functype', array($pluginType, $pluginType)));
- array_unshift($params, array('__funcname', array($func, $func)));
- } else {
- array_unshift($params, array($pluginType, $pluginType));
- array_unshift($params, array($func, $func));
- }
-
- return $this->addBlock('smartyinterface', $params, $state);
- }
-
- // Native & Smarty plugins
- if ($pluginType & Core::NATIVE_PLUGIN || $pluginType & Core::SMARTY_FUNCTION || $pluginType & Core::SMARTY_BLOCK) {
- $params = $this->mapParams($params, null, $state);
- } // PHP class plugin
- elseif ($pluginType & Core::CLASS_PLUGIN) {
- if ($pluginType & Core::CUSTOM_PLUGIN) {
- $params = $this->mapParams(
- $params, array(
- $this->customPlugins[$func]['class'],
- $this->customPlugins[$func]['function']
- ), $state);
- } else {
- if (class_exists('Plugin' . Core::toCamelCase($func)) !== false) {
- $params = $this->mapParams($params, array(
- 'Plugin' . Core::toCamelCase($func),
- ($pluginType & Core::COMPILABLE_PLUGIN) ? 'compile' : 'process'
- ), $state);
- } elseif (class_exists(Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase($func)) !== false) {
- $params = $this->mapParams($params, array(
- Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase($func),
- ($pluginType & Core::COMPILABLE_PLUGIN) ? 'compile' : 'process'
- ), $state);
- } else {
- $params = $this->mapParams($params, array(
- Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($func),
- ($pluginType & Core::COMPILABLE_PLUGIN) ? 'compile' : 'process'
- ), $state);
- }
- }
- } // PHP function plugin
- elseif ($pluginType & Core::FUNC_PLUGIN) {
- if ($pluginType & Core::CUSTOM_PLUGIN) {
- $params = $this->mapParams($params, $this->customPlugins[$func]['callback'], $state);
- } else {
- // Custom plugin
- if (function_exists('Plugin' . Core::toCamelCase($func) . (($pluginType & Core::COMPILABLE_PLUGIN) ?
- 'Compile' : '')) !== false) {
- $params = $this->mapParams($params, 'Plugin' . Core::toCamelCase($func) . (($pluginType &
- Core::COMPILABLE_PLUGIN) ? 'Compile' : ''), $state);
- } // Builtin helper plugin
- elseif (function_exists(Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase($func) . (
- ($pluginType & Core::COMPILABLE_PLUGIN) ? 'Compile' : '')) !== false) {
- $params = $this->mapParams($params, Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase
- ($func) . (($pluginType & Core::COMPILABLE_PLUGIN) ? 'Compile' : ''), $state);
- } // Builtin function plugin
- else {
- $params = $this->mapParams($params, Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase
- ($func) . (($pluginType & Core::COMPILABLE_PLUGIN) ? 'Compile' : ''), $state);
- }
- }
- } // Smarty modifier
- elseif ($pluginType & Core::SMARTY_MODIFIER) {
- $output = 'smarty_modifier_' . $func . '(' . implode(', ', $params) . ')';
- } // Proxy plugin
- elseif ($pluginType & Core::PROXY_PLUGIN) {
- $params = $this->mapParams($params, $this->getCore()->getPluginProxy()->getCallback($func), $state);
- } // Template plugin
- elseif ($pluginType & Core::TEMPLATE_PLUGIN) {
- // transforms the parameter array from (x=>array('paramname'=>array(values))) to (paramname=>array(values))
- $map = array();
- foreach ($this->templatePlugins[$func]['params'] as $param => $defValue) {
- if ($param == 'rest') {
- $param = '*';
- }
- $hasDefault = $defValue !== null;
- if ($defValue === 'null') {
- $defValue = null;
- } elseif ($defValue === 'false') {
- $defValue = false;
- } elseif ($defValue === 'true') {
- $defValue = true;
- } elseif (preg_match('#^([\'"]).*?\1$#', $defValue)) {
- $defValue = substr($defValue, 1, - 1);
- }
- $map[] = array($param, $hasDefault, $defValue);
- }
-
- $params = $this->mapParams($params, null, $state, $map);
- }
-
- // only keep php-syntax-safe values for non-block plugins
- $tokens = array();
- foreach ($params as $k => $p) {
- $tokens[$k] = isset($p[2]) ? $p[2] : 0;
- $params[$k] = $p[0];
- }
-
- // Native plugin
- if ($pluginType & Core::NATIVE_PLUGIN) {
- if ($func === 'do') {
- $output = '';
- if (isset($params['*'])) {
- $output = implode(';', $params['*']) . ';';
- }
-
- if (is_array($parsingParams) || $curBlock !== 'root') {
- throw new CompilationException($this, 'Do can not be used inside another function or block');
- }
-
- return self::PHP_OPEN . $output . self::PHP_CLOSE;
- } else {
- if (isset($params['*'])) {
- $output = $func . '(' . implode(', ', $params['*']) . ')';
- } else {
- $output = $func . '()';
- }
- }
- } // Block class OR Function class
- elseif ($pluginType & Core::CLASS_PLUGIN || ($pluginType & Core::FUNC_PLUGIN && $pluginType & Core::CLASS_PLUGIN)) {
- if ($pluginType & Core::COMPILABLE_PLUGIN) {
- if ($pluginType & Core::CUSTOM_PLUGIN) {
- $callback = $this->customPlugins[$func]['callback'];
- if (!is_array($callback)) {
- if (!method_exists($callback, 'compile')) {
- throw new Exception('Custom plugin ' . $func . ' must implement the "compile" method to be compilable, or you should provide a full callback to the method to use');
- }
- if (($ref = new ReflectionMethod($callback, 'compile')) && $ref->isStatic()) {
- $funcCompiler = array($callback, 'compile');
- } else {
- $funcCompiler = array(new $callback(), 'compile');
- }
- } else {
- $funcCompiler = $callback;
- }
- } else {
- if (class_exists('Plugin' . Core::toCamelCase($func)) !== false) {
- $funcCompiler = array('Plugin' . Core::toCamelCase($func), 'compile');
- } elseif (class_exists(Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase($func)) !== false) {
- $funcCompiler = array(Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase($func), 'compile');
- } else {
- $funcCompiler = array(
- Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($func),
- 'compile'
- );
- }
- array_unshift($params, $this);
- }
- // @TODO: Is it a real fix ?
- if ($func === 'tif') {
- $params[] = $tokens;
- }
- $output = call_user_func_array($funcCompiler, $params);
- } else {
- $params = self::implode_r($params);
- if ($pluginType & Core::CUSTOM_PLUGIN) {
- $callback = $this->customPlugins[$func]['callback'];
- if (!is_array($callback)) {
- if (!method_exists($callback, 'process')) {
- throw new Exception('Custom plugin ' . $func . ' must implement the "process" method to be usable, or you should provide a full callback to the method to use');
- }
- if (is_object($callback)) {
- $callback = get_class($callback);
- }
- if (($ref = new ReflectionMethod($callback, 'process')) && $ref->isStatic()) {
- $output = 'call_user_func(array(\'' . $callback . '\', \'process\'), ' . $params . ')';
- } else {
- $output = 'call_user_func(array($this->getObjectPlugin(\'' . $callback . '\'), \'process\'), ' . $params . ')';
- }
- } elseif (is_object($callback[0])) {
- $output = 'call_user_func(array($this->plugins[\'' . $func . '\'][\'callback\'][0], \'' . $callback[1] . '\'), ' . $params . ')';
- } elseif (($ref = new ReflectionMethod($callback[0], $callback[1])) && $ref->isStatic()) {
- $output = 'call_user_func(array(\'' . $callback[0] . '\', \'' . $callback[1] . '\'), ' . $params . ')';
- } else {
- $output = 'call_user_func(array($this->getObjectPlugin(\'' . $callback[0] . '\'), \'' . $callback[1] . '\'), ' . $params . ')';
- }
- if (empty($params)) {
- $output = substr($output, 0, - 3) . ')';
- }
- } else {
- if (class_exists('Plugin' . Core::toCamelCase($func)) !== false) {
- $output = '$this->classCall(\'Plugin' . $func . '\', array(' . $params . '))';
- } elseif (class_exists(Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($func)) !== false) {
- $output = '$this->classCall(\'' . Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . $func . '\',
- array(' . $params . '))';
- } else {
- $output = '$this->classCall(\'' . $func . '\', array(' . $params . '))';
- }
- }
- }
- } // Function plugin only (cannot be a class)
- elseif ($pluginType & Core::FUNC_PLUGIN) {
- if ($pluginType & Core::COMPILABLE_PLUGIN) {
- if ($pluginType & Core::CUSTOM_PLUGIN) {
- $funcCompiler = $this->customPlugins[$func]['callback'];
- } else {
- // Custom plugin
- if (function_exists('Plugin' . Core::toCamelCase($func) . 'Compile') !== false) {
- $funcCompiler = 'Plugin' . Core::toCamelCase($func) . 'Compile';
- } // Builtin helper plugin
- elseif (function_exists(Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase($func) . 'Compile') !== false) {
- $funcCompiler = Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase($func) .
- 'Compile';
- } // Builtin function plugin
- else {
- $funcCompiler = Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($func) .
- 'Compile';
- }
- }
- array_unshift($params, $this);
- // @TODO: Is it a real fix ?
- if ($func === 'tif') {
- $params[] = $tokens;
- }
- $output = call_user_func_array($funcCompiler, $params);
- } else {
- array_unshift($params, '$this');
- $params = self::implode_r($params);
- if ($pluginType & Core::CUSTOM_PLUGIN) {
- $callback = $this->customPlugins[$func]['callback'];
- if ($callback instanceof Closure) {
- $output = 'call_user_func($this->getCustomPlugin(\'' . $func . '\'), ' . $params . ')';
- } else {
- $output = 'call_user_func(\'' . $callback . '\', ' . $params . ')';
- }
- } else {
- // Custom plugin
- if (function_exists('Plugin' . Core::toCamelCase($func)) !== false) {
- $output = 'Plugin' . Core::toCamelCase($func) . '(' . $params .
- ')';
- } // Builtin helper plugin
- elseif(function_exists(Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase($func)) !==
- false) {
- $output = Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase($func) . '(' .
- $params . ')';
- } // Builtin function plugin
- else {
- $output = Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($func) . '(' .
- $params . ')';
- }
- }
- }
- } // Proxy plugin
- elseif ($pluginType & Core::PROXY_PLUGIN) {
- $output = call_user_func(array($this->getCore()->getPluginProxy(), 'getCode'), $func, $params);
- } // Smarty function (@deprecated)
- elseif ($pluginType & Core::SMARTY_FUNCTION) {
- $params = '';
- if (isset($params['*'])) {
- $params = self::implode_r($params['*'], true);
- }
-
- if ($pluginType & Core::CUSTOM_PLUGIN) {
- $callback = $this->customPlugins[$func]['callback'];
- if (is_array($callback)) {
- if (is_object($callback[0])) {
- $output = 'call_user_func_array(array($this->getCustomPlugin(\'' . $func . '\'), \'' . $callback[1] . '\'), array(array(' . $params . '), $this))';
- } else {
- $output = 'call_user_func_array(array(\'' . $callback[0] . '\', \'' . $callback[1] . '\'), array(array(' . $params . '), $this))';
- }
- } else {
- $output = $callback . '(array(' . $params . '), $this)';
- }
- } else {
- $output = 'smarty_function_' . $func . '(array(' . $params . '), $this)';
- }
- } // Template plugin
- elseif ($pluginType & Core::TEMPLATE_PLUGIN) {
- array_unshift($params, '$this');
- $params = self::implode_r($params);
- $output = 'Plugin' . Core::toCamelCase($func) .
- $this->templatePlugins[$func]['uuid'] . '(' . $params . ')';
- $this->templatePlugins[$func]['called'] = true;
- }
-
- if (is_array($parsingParams)) {
- $parsingParams[] = array($output, $output);
-
- return $parsingParams;
- } elseif ($curBlock === 'namedparam') {
- return array($output, $output);
- }
-
- return $output;
- }
-
- /**
- * Parses a string.
- *
- * @param string $in the string within which we must parse something
- * @param int $from the starting offset of the parsed area
- * @param int $to the ending offset of the parsed area
- * @param mixed $parsingParams must be an array if we are parsing a function or modifier's parameters, or false by
- * default
- * @param string $curBlock the current parser-block being processed
- * @param mixed $pointer a reference to a pointer that will be increased by the amount of characters parsed,
- * or null by default
- *
- * @return string parsed values
- * @throws CompilationException
- */
- protected function parseString($in, $from, $to, $parsingParams = false, $curBlock = '', &$pointer = null)
- {
- $substr = substr($in, $from, $to - $from);
- $first = $substr[0];
-
- if ($this->debug) {
- echo 'STRING FOUND (in ' . htmlentities(substr($in, $from, min($to - $from, 50))) . (($to - $from) > 50 ? '...' : '') . ')' . "\n";
- }
- $strend = false;
- $o = $from + 1;
- while ($strend === false) {
- $strend = strpos($in, $first, $o);
- if ($strend === false) {
- throw new CompilationException($this, 'Unfinished string, started with ' . substr($in, $from, $to - $from));
- }
- if (substr($in, $strend - 1, 1) === '\\') {
- $o = $strend + 1;
- $strend = false;
- }
- }
- if ($this->debug) {
- echo 'STRING DELIMITED: ' . substr($in, $from, $strend + 1 - $from) . "\n";
- }
-
- $srcOutput = substr($in, $from, $strend + 1 - $from);
-
- if ($pointer !== null) {
- $pointer += strlen($srcOutput);
- }
-
- $output = $this->replaceStringVars($srcOutput, $first);
-
- // handle modifiers
- if ($curBlock !== 'modifier' && preg_match('#^((?:\|(?:@?[a-z0-9_]+(?::.*)*))+)#i', substr($substr, $strend + 1 - $from), $match)) {
- $modstr = $match[1];
-
- if ($curBlock === 'root' && substr($modstr, - 1) === '}') {
- $modstr = substr($modstr, 0, - 1);
- }
- $modstr = str_replace('\\' . $first, $first, $modstr);
- $ptr = 0;
- $output = $this->replaceModifiers(array(null, null, $output, $modstr), 'string', $ptr);
-
- $strend += $ptr;
- if ($pointer !== null) {
- $pointer += $ptr;
- }
- $srcOutput .= substr($substr, $strend + 1 - $from, $ptr);
- }
-
- if (is_array($parsingParams)) {
- $parsingParams[] = array($output, substr($srcOutput, 1, - 1));
-
- return $parsingParams;
- } elseif ($curBlock === 'namedparam') {
- return array($output, substr($srcOutput, 1, - 1));
- }
-
- return $output;
- }
-
- /**
- * Parses a constant.
- *
- * @param string $in the string within which we must parse something
- * @param int $from the starting offset of the parsed area
- * @param int $to the ending offset of the parsed area
- * @param mixed $parsingParams must be an array if we are parsing a function or modifier's parameters, or false by
- * default
- * @param string $curBlock the current parser-block being processed
- * @param mixed $pointer a reference to a pointer that will be increased by the amount of characters parsed,
- * or null by default
- *
- * @return string parsed values
- * @throws CompilationException
- */
- protected function parseConst($in, $from, $to, $parsingParams = false, $curBlock = '', &$pointer = null)
- {
- $substr = substr($in, $from, $to - $from);
-
- if ($this->debug) {
- echo 'CONST FOUND : ' . $substr . "\n";
- }
-
- if (!preg_match('#^%([\\\\a-z0-9_:]+)#i', $substr, $m)) {
- throw new CompilationException($this, 'Invalid constant');
- }
-
- if ($pointer !== null) {
- $pointer += strlen($m[0]);
- }
-
- $output = $this->parseConstKey($m[1], $curBlock);
-
- if (is_array($parsingParams)) {
- $parsingParams[] = array($output, $m[1]);
-
- return $parsingParams;
- } elseif ($curBlock === 'namedparam') {
- return array($output, $m[1]);
- }
-
- return $output;
- }
-
- /**
- * Parses a constant.
- *
- * @param string $key the constant to parse
- * @param string $curBlock the current parser-block being processed
- *
- * @return string parsed constant
- */
- protected function parseConstKey($key, $curBlock)
- {
- $key = str_replace('\\\\', '\\', $key);
-
- if ($this->securityPolicy !== null && $this->securityPolicy->getConstantHandling() === SecurityPolicy::CONST_DISALLOW) {
- return 'null';
- }
-
- if ($curBlock !== 'root') {
- return '(defined("' . $key . '") ? ' . $key . ' : null)';
- }
-
- return $key;
- }
-
- /**
- * Parses a variable.
- *
- * @param string $in the string within which we must parse something
- * @param int $from the starting offset of the parsed area
- * @param int $to the ending offset of the parsed area
- * @param mixed $parsingParams must be an array if we are parsing a function or modifier's parameters, or false by
- * default
- * @param string $curBlock the current parser-block being processed
- * @param mixed $pointer a reference to a pointer that will be increased by the amount of characters parsed,
- * or null by default
- *
- * @return string parsed values
- * @throws CompilationException
- */
- protected function parseVar($in, $from, $to, $parsingParams = false, $curBlock = '', &$pointer = null)
- {
- $substr = substr($in, $from, $to - $from);
-
- // var key
- $varRegex = '(\\$?\\.?[a-z0-9\\\\_:]*(?:(?:(?:\\.|->)(?:[a-z0-9\\\\_:]+|(?R))|\\[(?:[a-z0-9\\\\_:]+|(?R)|(["\'])[^\\2]*?\\2)\\]))*)';
- // method call
- $methodCall = ($curBlock === 'root' || $curBlock === 'function' || $curBlock === 'namedparam' || $curBlock === 'condition' || $curBlock === 'variable' || $curBlock === 'expression' || $curBlock === 'delimited_string' ? '(\(.*)?' : '()');
- // simple math expressions
- $simpleMathExpressions = ($curBlock === 'root' || $curBlock === 'function' || $curBlock === 'namedparam' || $curBlock === 'condition' || $curBlock === 'variable' || $curBlock === 'delimited_string' ? '((?:(?:[+\/*%=-])(?:(?_:-]+(?:\([^)]*\))?|(?')));
- $key = substr($match[1], 1, strrpos($match[1], '->') - 1);
- $methodCall = substr($match[1], strrpos($match[1], '->')) . $match[3];
- }
-
- if ($hasModifiers) {
- $matchedLength -= strlen($match[5]);
- }
-
- if ($pointer !== null) {
- $pointer += $matchedLength;
- }
-
- // replace useless brackets by dot accessed vars and strip enclosing quotes if present
- $key = preg_replace('#\[(["\']?)([^$%\[.>-]+)\1\]#', '.$2', $key);
-
- if ($this->debug) {
- if ($hasMethodCall) {
- echo 'METHOD CALL FOUND : $' . $key . substr($methodCall, 0, 30) . "\n";
- } else {
- echo 'VAR FOUND : $' . $key . "\n";
- }
- }
-
- $key = str_replace('"', '\\"', $key);
-
- $cnt = substr_count($key, '$');
- if ($cnt > 0) {
- $uid = 0;
- $parsed = array($uid => '');
- $current = &$parsed;
- $curTxt = &$parsed[$uid ++];
- $tree = array();
- $chars = str_split($key, 1);
- $inSplittedVar = false;
- $bracketCount = 0;
-
- while (($char = array_shift($chars)) !== null) {
- if ($char === '[') {
- if (count($tree) > 0) {
- ++ $bracketCount;
- } else {
- $tree[] = &$current;
- $current[$uid] = array($uid + 1 => '');
- $current = &$current[$uid ++];
- $curTxt = &$current[$uid ++];
- continue;
- }
- } elseif ($char === ']') {
- if ($bracketCount > 0) {
- -- $bracketCount;
- } else {
- $current = &$tree[count($tree) - 1];
- array_pop($tree);
- if (current($chars) !== '[' && current($chars) !== false && current($chars) !== ']') {
- $current[$uid] = '';
- $curTxt = &$current[$uid ++];
- }
- continue;
- }
- } elseif ($char === '$') {
- if (count($tree) == 0) {
- $curTxt = &$current[$uid ++];
- $inSplittedVar = true;
- }
- } elseif (($char === '.' || $char === '-') && count($tree) == 0 && $inSplittedVar) {
- $curTxt = &$current[$uid ++];
- $inSplittedVar = false;
- }
-
- $curTxt .= $char;
- }
- unset($uid, $current, $curTxt, $tree, $chars);
-
- if ($this->debug) {
- echo 'RECURSIVE VAR REPLACEMENT : ' . $key . "\n";
- }
-
- $key = $this->flattenVarTree($parsed);
-
- if ($this->debug) {
- echo 'RECURSIVE VAR REPLACEMENT DONE : ' . $key . "\n";
- }
-
- $output = preg_replace('#(^""\.|""\.|\.""$|(\()""\.|\.""(\)))#', '$2$3', '$this->readVar("' . $key . '")');
- } else {
- $output = $this->parseVarKey($key, $hasModifiers ? 'modifier' : $curBlock);
- }
-
-
- // methods
- if ($hasMethodCall) {
- $ptr = 0;
-
- $output = $this->parseMethodCall($output, $methodCall, $curBlock, $ptr);
-
- if ($pointer !== null) {
- $pointer += $ptr;
- }
- $matchedLength += $ptr;
- }
-
- if ($hasExpression) {
- // expressions
- preg_match_all('#(?:([+/*%=-])(=?-?[%$][a-z0-9\\\\.[\]>_:-]+(?:\([^)]*\))?|=?-?[0-9.,]+|\1))#i', $match[4], $expMatch);
- foreach ($expMatch[1] as $k => $operator) {
- if (substr($expMatch[2][$k], 0, 1) === '=') {
- $assign = true;
- if ($operator === '=') {
- throw new CompilationException($this, 'Invalid expression ' . $substr . ', can not use "==" in expressions');
- }
- if ($curBlock !== 'root') {
- throw new CompilationException($this, 'Invalid expression ' . $substr . ', assignments can only be used in top level expressions like {$foo+=3} or {$foo="bar"}');
- }
- $operator .= '=';
- $expMatch[2][$k] = substr($expMatch[2][$k], 1);
- }
-
- if (substr($expMatch[2][$k], 0, 1) === '-' && strlen($expMatch[2][$k]) > 1) {
- $operator .= '-';
- $expMatch[2][$k] = substr($expMatch[2][$k], 1);
- }
- if (($operator === '+' || $operator === '-') && $expMatch[2][$k] === $operator) {
- $output = '(' . $output . $operator . $operator . ')';
- break;
- } elseif (substr($expMatch[2][$k], 0, 1) === '$') {
- $output = '(' . $output . ' ' . $operator . ' ' . $this->parseVar($expMatch[2][$k], 0, strlen($expMatch[2][$k]), false, 'expression') . ')';
- } elseif (substr($expMatch[2][$k], 0, 1) === '%') {
- $output = '(' . $output . ' ' . $operator . ' ' . $this->parseConst($expMatch[2][$k], 0, strlen($expMatch[2][$k]), false, 'expression') . ')';
- } elseif (!empty($expMatch[2][$k])) {
- $output = '(' . $output . ' ' . $operator . ' ' . str_replace(',', '.', $expMatch[2][$k]) . ')';
- } else {
- throw new CompilationException($this, 'Unfinished expression ' . $substr . ', missing var or number after math operator');
- }
- }
- }
-
- if ($this->autoEscape === true && $curBlock !== 'condition') {
- $output = '(is_string($tmp=' . $output . ') ? htmlspecialchars($tmp, ENT_QUOTES, $this->charset) : $tmp)';
- }
-
- // handle modifiers
- if ($curBlock !== 'modifier' && $hasModifiers) {
- $ptr = 0;
- $output = $this->replaceModifiers(array(null, null, $output, $match[5]), 'var', $ptr);
- if ($pointer !== null) {
- $pointer += $ptr;
- }
- $matchedLength += $ptr;
- }
-
- if (is_array($parsingParams)) {
- $parsingParams[] = array($output, $key);
-
- return $parsingParams;
- } elseif ($curBlock === 'namedparam') {
- return array($output, $key);
- } elseif ($curBlock === 'string' || $curBlock === 'delimited_string') {
- return array($matchedLength, $output);
- } elseif ($curBlock === 'expression' || $curBlock === 'variable') {
- return $output;
- } elseif (isset($assign)) {
- return self::PHP_OPEN . $output . ';' . self::PHP_CLOSE;
- }
-
- return $output;
- } else {
- if ($curBlock === 'string' || $curBlock === 'delimited_string') {
- return array(0, '');
- }
- throw new CompilationException($this, 'Invalid variable name ' . $substr . '');
- }
- }
-
- /**
- * Parses any number of chained method calls/property reads.
- *
- * @param string $output the variable or whatever upon which the method are called
- * @param string $methodCall method call source, starting at "->"
- * @param string $curBlock the current parser-block being processed
- * @param int $pointer a reference to a pointer that will be increased by the amount of characters parsed
- *
- * @return string parsed call(s)/read(s)
- */
- protected function parseMethodCall($output, $methodCall, $curBlock, &$pointer)
- {
- $ptr = 0;
- $len = strlen($methodCall);
-
- while ($ptr < $len) {
- if (strpos($methodCall, '->', $ptr) === $ptr) {
- $ptr += 2;
- }
-
- if (in_array(
- $methodCall[$ptr], array(
- ';',
- ',',
- '/',
- ' ',
- "\t",
- "\r",
- "\n",
- ')',
- '+',
- '*',
- '%',
- '=',
- '-',
- '|'
- )
- ) || substr($methodCall, $ptr, strlen($this->rd)) === $this->rd
- ) {
- // break char found
- break;
- }
-
- if (!preg_match('/^([a-z0-9_]+)(\(.*?\))?/i', substr($methodCall, $ptr), $methMatch)) {
- break;
- }
-
- if (empty($methMatch[2])) {
- // property
- if ($curBlock === 'root') {
- $output .= '->' . $methMatch[1];
- } else {
- $output = '(($tmp = ' . $output . ') ? $tmp->' . $methMatch[1] . ' : null)';
- }
- $ptr += strlen($methMatch[1]);
- } else {
- // method
- if (substr($methMatch[2], 0, 2) === '()') {
- $parsedCall = $methMatch[1] . '()';
- $ptr += strlen($methMatch[1]) + 2;
- } else {
- $parsedCall = $this->parseFunction($methodCall, $ptr, strlen($methodCall), false, 'method', $ptr);
- }
- if ($this->securityPolicy !== null) {
- $argPos = strpos($parsedCall, '(');
- $method = strtolower(substr($parsedCall, 0, $argPos));
- $args = substr($parsedCall, $argPos);
- if ($curBlock === 'root') {
- $output = '$this->getSecurityPolicy()->callMethod($this, ' . $output . ', ' . var_export($method, true) . ', array' . $args . ')';
- } else {
- $output = '(($tmp = ' . $output . ') ? $this->getSecurityPolicy()->callMethod($this, $tmp, ' . var_export($method, true) . ', array' . $args . ') : null)';
- }
- } else {
- if ($curBlock === 'root') {
- $output .= '->' . $parsedCall;
- } else {
- $output = '(($tmp = ' . $output . ') ? $tmp->' . $parsedCall . ' : null)';
- }
- }
- }
- }
-
- $pointer += $ptr;
-
- return $output;
- }
-
- /**
- * Parses a constant variable (a variable that doesn't contain another variable) and preprocesses it to save
- * runtime processing time.
- *
- * @param string $key the variable to parse
- * @param string $curBlock the current parser-block being processed
- *
- * @return string parsed variable
- */
- protected function parseVarKey($key, $curBlock)
- {
- if ($key === '') {
- return '$this->scope';
- }
- if (substr($key, 0, 1) === '.') {
- $key = 'dwoo' . $key;
- }
- if (preg_match('#dwoo\.(get|post|server|cookies|session|env|request)((?:\.[a-z0-9_-]+)+)#i', $key, $m)) {
- $global = strtoupper($m[1]);
- if ($global === 'COOKIES') {
- $global = 'COOKIE';
- }
- $key = '$_' . $global;
- foreach (explode('.', ltrim($m[2], '.')) as $part) {
- $key .= '[' . var_export($part, true) . ']';
- }
- if ($curBlock === 'root') {
- $output = $key;
- } else {
- $output = '(isset(' . $key . ')?' . $key . ':null)';
- }
- } elseif (preg_match('#dwoo\\.const\\.([a-z0-9\\\\_:]+)#i', $key, $m)) {
- return $this->parseConstKey($m[1], $curBlock);
- } elseif ($this->scope !== null) {
- if (strstr($key, '.') === false && strstr($key, '[') === false && strstr($key, '->') === false) {
- if ($key === 'dwoo') {
- $output = '$this->globals';
- } elseif ($key === '_root' || $key === '__') {
- $output = '$this->data';
- } elseif ($key === '_parent' || $key === '_') {
- $output = '$this->readParentVar(1)';
- } elseif ($key === '_key') {
- $output = '$tmp_key';
- } else {
- if ($curBlock === 'root') {
- $output = '$this->scope["' . $key . '"]';
- } else {
- $output = '(isset($this->scope["' . $key . '"]) ? $this->scope["' . $key . '"] : null)';
- }
- }
- } else {
- preg_match_all('#(\[|->|\.)?((?:[a-z0-9_]|-(?!>))+|(\\\?[\'"])[^\3]*?\3)\]?#i', $key, $m);
-
- $i = $m[2][0];
- if ($i === '_parent' || $i === '_') {
- $parentCnt = 0;
-
- while (true) {
- ++ $parentCnt;
- array_shift($m[2]);
- array_shift($m[1]);
- if (current($m[2]) === '_parent') {
- continue;
- }
- break;
- }
-
- $output = '$this->readParentVar(' . $parentCnt . ')';
- } else {
- if ($i === 'dwoo') {
- $output = '$this->globals';
- array_shift($m[2]);
- array_shift($m[1]);
- } elseif ($i === '_root' || $i === '__') {
- $output = '$this->data';
- array_shift($m[2]);
- array_shift($m[1]);
- } elseif ($i === '_key') {
- $output = '$tmp_key';
- } else {
- $output = '$this->scope';
- }
-
- while (count($m[1]) && $m[1][0] !== '->') {
- $m[2][0] = preg_replace('/(^\\\([\'"])|\\\([\'"])$)/x', '$2$3', $m[2][0]);
- if (substr($m[2][0], 0, 1) == '"' || substr($m[2][0], 0, 1) == "'") {
- $output .= '[' . $m[2][0] . ']';
- } else {
- $output .= '["' . $m[2][0] . '"]';
- }
- array_shift($m[2]);
- array_shift($m[1]);
- }
-
- if ($curBlock !== 'root') {
- $output = '(isset(' . $output . ') ? ' . $output . ':null)';
- }
- }
-
- if (count($m[2])) {
- unset($m[0]);
- $output = '$this->readVarInto(' . str_replace("\n", '', var_export($m, true)) . ', ' . $output . ', ' . ($curBlock == 'root' ? 'false' : 'true') . ')';
- }
- }
- } else {
- preg_match_all('#(\[|->|\.)?((?:[a-z0-9_]|-(?!>))+)\]?#i', $key, $m);
- unset($m[0]);
- $output = '$this->readVar(' . str_replace("\n", '', var_export($m, true)) . ')';
- }
-
- return $output;
- }
-
- /**
- * Flattens a variable tree, this helps in parsing very complex variables such as $var.foo[$foo.bar->baz].baz,
- * it computes the contents of the brackets first and works out from there.
- *
- * @param array $tree the variable tree parsed by he parseVar() method that must be flattened
- * @param bool $recursed leave that to false by default, it is only for internal use
- *
- * @return string flattened tree
- */
- protected function flattenVarTree(array $tree, $recursed = false)
- {
- $out = $recursed ? '".$this->readVarInto(' : '';
- foreach ($tree as $bit) {
- if (is_array($bit)) {
- $out .= '.' . $this->flattenVarTree($bit, false);
- } else {
- $key = str_replace('"', '\\"', $bit);
-
- if (substr($key, 0, 1) === '$') {
- $out .= '".' . $this->parseVar($key, 0, strlen($key), false, 'variable') . '."';
- } else {
- $cnt = substr_count($key, '$');
-
- if ($this->debug) {
- echo 'PARSING SUBVARS IN : ' . $key . "\n";
- }
- if ($cnt > 0) {
- while (-- $cnt >= 0) {
- if (isset($last)) {
- $last = strrpos($key, '$', - (strlen($key) - $last + 1));
- } else {
- $last = strrpos($key, '$');
- }
- preg_match('#\$[a-z0-9_]+((?:(?:\.|->)(?:[a-z0-9_]+|(?R))|\[(?:[a-z0-9_]+|(?R))\]))*' . '((?:(?:[+/*%-])(?:\$[a-z0-9.[\]>_:-]+(?:\([^)]*\))?|[0-9.,]*))*)#i', substr($key, $last), $submatch);
-
- $len = strlen($submatch[0]);
- $key = substr_replace(
- $key, preg_replace_callback(
- '#(\$[a-z0-9_]+((?:(?:\.|->)(?:[a-z0-9_]+|(?R))|\[(?:[a-z0-9_]+|(?R))\]))*)' . '((?:(?:[+/*%-])(?:\$[a-z0-9.[\]>_:-]+(?:\([^)]*\))?|[0-9.,]*))*)#i', array(
- $this,
- 'replaceVarKeyHelper'
- ), substr($key, $last, $len)
- ), $last, $len
- );
- if ($this->debug) {
- echo 'RECURSIVE VAR REPLACEMENT DONE : ' . $key . "\n";
- }
- }
- unset($last);
-
- $out .= $key;
- } else {
- $out .= $key;
- }
- }
- }
- }
- $out .= $recursed ? ', true)."' : '';
-
- return $out;
- }
-
- /**
- * Helper function that parses a variable.
- *
- * @param array $match the matched variable, array(1=>"string match")
- *
- * @return string parsed variable
- */
- protected function replaceVarKeyHelper($match)
- {
- return '".' . $this->parseVar($match[0], 0, strlen($match[0]), false, 'variable') . '."';
- }
-
- /**
- * Parses various constants, operators or non-quoted strings.
- *
- * @param string $in the string within which we must parse something
- * @param int $from the starting offset of the parsed area
- * @param int $to the ending offset of the parsed area
- * @param mixed $parsingParams must be an array if we are parsing a function or modifier's parameters, or false by
- * default
- * @param string $curBlock the current parser-block being processed
- * @param mixed $pointer a reference to a pointer that will be increased by the amount of characters parsed,
- * or null by default
- *
- * @return string parsed values
- * @throws Exception
- */
- protected function parseOthers($in, $from, $to, $parsingParams = false, $curBlock = '', &$pointer = null)
- {
- $substr = substr($in, $from, $to - $from);
-
- $end = strlen($substr);
-
- if ($curBlock === 'condition') {
- $breakChars = array(
- '(',
- ')',
- ' ',
- '||',
- '&&',
- '|',
- '&',
- '>=',
- '<=',
- '===',
- '==',
- '=',
- '!==',
- '!=',
- '<<',
- '<',
- '>>',
- '>',
- '^',
- '~',
- ',',
- '+',
- '-',
- '*',
- '/',
- '%',
- '!',
- '?',
- ':',
- $this->rd,
- ';'
- );
- } elseif ($curBlock === 'modifier') {
- $breakChars = array(' ', ',', ')', ':', '|', "\r", "\n", "\t", ';', $this->rd);
- } elseif ($curBlock === 'expression') {
- $breakChars = array('/', '%', '+', '-', '*', ' ', ',', ')', "\r", "\n", "\t", ';', $this->rd);
- } else {
- $breakChars = array(' ', ',', ')', "\r", "\n", "\t", ';', $this->rd);
- }
-
- $breaker = false;
- foreach ($breakChars as $k => $char) {
- $test = strpos($substr, $char);
- if ($test !== false && $test < $end) {
- $end = $test;
- $breaker = $k;
- }
- }
-
- if ($curBlock === 'condition') {
- if ($end === 0 && $breaker !== false) {
- $end = strlen($breakChars[$breaker]);
- }
- }
-
- if ($end !== false) {
- $substr = substr($substr, 0, $end);
- }
-
- if ($pointer !== null) {
- $pointer += strlen($substr);
- }
-
- $src = $substr;
- $substr = trim($substr);
-
- if (strtolower($substr) === 'false' || strtolower($substr) === 'no' || strtolower($substr) === 'off') {
- if ($this->debug) {
- echo 'BOOLEAN(FALSE) PARSED' . "\n";
- }
- $substr = 'false';
- $type = self::T_BOOL;
- } elseif (strtolower($substr) === 'true' || strtolower($substr) === 'yes' || strtolower($substr) === 'on') {
- if ($this->debug) {
- echo 'BOOLEAN(TRUE) PARSED' . "\n";
- }
- $substr = 'true';
- $type = self::T_BOOL;
- } elseif ($substr === 'null' || $substr === 'NULL') {
- if ($this->debug) {
- echo 'NULL PARSED' . "\n";
- }
- $substr = 'null';
- $type = self::T_NULL;
- } elseif (is_numeric($substr)) {
- $substr = (float)$substr;
- if ((int)$substr == $substr) {
- $substr = (int)$substr;
- }
- $type = self::T_NUMERIC;
- if ($this->debug) {
- echo 'NUMBER (' . $substr . ') PARSED' . "\n";
- }
- } elseif (preg_match('{^-?(\d+|\d*(\.\d+))\s*([/*%+-]\s*-?(\d+|\d*(\.\d+)))+$}', $substr)) {
- if ($this->debug) {
- echo 'SIMPLE MATH PARSED . "\n"';
- }
- $type = self::T_MATH;
- $substr = '(' . $substr . ')';
- } elseif ($curBlock === 'condition' && array_search($substr, $breakChars, true) !== false) {
- if ($this->debug) {
- echo 'BREAKCHAR (' . $substr . ') PARSED' . "\n";
- }
- $type = self::T_BREAKCHAR;
- //$substr = '"'.$substr.'"';
- } else {
- $substr = $this->replaceStringVars('\'' . str_replace('\'', '\\\'', $substr) . '\'', '\'', $curBlock);
- $type = self::T_UNQUOTED_STRING;
- if ($this->debug) {
- echo 'BLABBER (' . $substr . ') CASTED AS STRING' . "\n";
- }
- }
-
- if (is_array($parsingParams)) {
- $parsingParams[] = array($substr, $src, $type);
-
- return $parsingParams;
- } elseif ($curBlock === 'namedparam') {
- return array($substr, $src, $type);
- } elseif ($curBlock === 'expression') {
- return $substr;
- } else {
- throw new Exception('Something went wrong');
- }
- }
-
- /**
- * Replaces variables within a parsed string.
- *
- * @param string $string the parsed string
- * @param string $first the first character parsed in the string, which is the string delimiter (' or ")
- * @param string $curBlock the current parser-block being processed
- *
- * @return string the original string with variables replaced
- */
- protected function replaceStringVars($string, $first, $curBlock = '')
- {
- $pos = 0;
- if ($this->debug) {
- echo 'STRING VAR REPLACEMENT : ' . $string . "\n";
- }
- // replace vars
- while (($pos = strpos($string, '$', $pos)) !== false) {
- $prev = substr($string, $pos - 1, 1);
- if ($prev === '\\') {
- ++ $pos;
- continue;
- }
-
- $var = $this->parse($string, $pos, null, false, ($curBlock === 'modifier' ? 'modifier' : ($prev === '`' ? 'delimited_string' : 'string')));
- $len = $var[0];
- $var = $this->parse(str_replace('\\' . $first, $first, $string), $pos, null, false, ($curBlock === 'modifier' ? 'modifier' : ($prev === '`' ? 'delimited_string' : 'string')));
-
- if ($prev === '`' && substr($string, $pos + $len, 1) === '`') {
- $string = substr_replace($string, $first . '.' . $var[1] . '.' . $first, $pos - 1, $len + 2);
- } else {
- $string = substr_replace($string, $first . '.' . $var[1] . '.' . $first, $pos, $len);
- }
- $pos += strlen($var[1]) + 2;
- if ($this->debug) {
- echo 'STRING VAR REPLACEMENT DONE : ' . $string . "\n";
- }
- }
-
- // handle modifiers
- // TODO Obsolete?
- $string = preg_replace_callback(
- '#("|\')\.(.+?)\.\1((?:\|(?:@?[a-z0-9_]+(?:(?::("|\').+?\4|:[^`]*))*))+)#i', array(
- $this,
- 'replaceModifiers'
- ), $string
- );
-
- // replace escaped dollar operators by unescaped ones if required
- if ($first === "'") {
- $string = str_replace('\\$', '$', $string);
- }
-
- return $string;
- }
-
- /**
- * Replaces the modifiers applied to a string or a variable.
- *
- * @param array $m the regex matches that must be array(1=>"double or single quotes enclosing a string,
- * when applicable", 2=>"the string or var", 3=>"the modifiers matched")
- * @param string $curBlock the current parser-block being processed
- * @param null $pointer
- *
- * @return string the input enclosed with various function calls according to the modifiers found
- * @throws CompilationException
- * @throws Exception
- */
- protected function replaceModifiers(array $m, $curBlock = null, &$pointer = null)
- {
- if ($this->debug) {
- echo 'PARSING MODIFIERS : ' . $m[3] . "\n";
- }
-
- if ($pointer !== null) {
- $pointer += strlen($m[3]);
- }
- // remove first pipe
- $cmdstrsrc = substr($m[3], 1);
- // remove last quote if present
- if (substr($cmdstrsrc, - 1, 1) === $m[1]) {
- $cmdstrsrc = substr($cmdstrsrc, 0, - 1);
- $add = $m[1];
- }
-
- $output = $m[2];
-
- $continue = true;
- while (strlen($cmdstrsrc) > 0 && $continue) {
- if ($cmdstrsrc[0] === '|') {
- $cmdstrsrc = substr($cmdstrsrc, 1);
- continue;
- }
- if ($cmdstrsrc[0] === ' ' || $cmdstrsrc[0] === ';' || substr($cmdstrsrc, 0, strlen($this->rd)) === $this->rd) {
- if ($this->debug) {
- echo 'MODIFIER PARSING ENDED, RIGHT DELIMITER or ";" FOUND' . "\n";
- }
- $continue = false;
- if ($pointer !== null) {
- $pointer -= strlen($cmdstrsrc);
- }
- break;
- }
- $cmdstr = $cmdstrsrc;
- $paramsep = ':';
- if (!preg_match('/^(@{0,2}[a-z_][a-z0-9_]*)(:)?/i', $cmdstr, $match)) {
- throw new CompilationException($this, 'Invalid modifier name, started with : ' . substr($cmdstr, 0, 10));
- }
- $paramspos = !empty($match[2]) ? strlen($match[1]) : false;
- $func = $match[1];
-
- $state = 0;
- if ($paramspos === false) {
- $cmdstrsrc = substr($cmdstrsrc, strlen($func));
- $params = array();
- if ($this->debug) {
- echo 'MODIFIER (' . $func . ') CALLED WITH NO PARAMS' . "\n";
- }
- } else {
- $paramstr = substr($cmdstr, $paramspos + 1);
- if (substr($paramstr, - 1, 1) === $paramsep) {
- $paramstr = substr($paramstr, 0, - 1);
- }
-
- $ptr = 0;
- $params = array();
- while ($ptr < strlen($paramstr)) {
- if ($this->debug) {
- echo 'MODIFIER (' . $func . ') START PARAM PARSING WITH POINTER AT ' . $ptr . "\n";
- }
- if ($this->debug) {
- echo $paramstr . '--' . $ptr . '--' . strlen($paramstr) . '--modifier' . "\n";
- }
- $params = $this->parse($paramstr, $ptr, strlen($paramstr), $params, 'modifier', $ptr);
- if ($this->debug) {
- echo 'PARAM PARSED, POINTER AT ' . $ptr . "\n";
- }
-
- if ($ptr >= strlen($paramstr)) {
- if ($this->debug) {
- echo 'PARAM PARSING ENDED, PARAM STRING CONSUMED' . "\n";
- }
- break;
- }
-
- if ($paramstr[$ptr] === ' ' || $paramstr[$ptr] === '|' || $paramstr[$ptr] === ';' || substr($paramstr, $ptr, strlen($this->rd)) === $this->rd) {
- if ($this->debug) {
- echo 'PARAM PARSING ENDED, " ", "|", RIGHT DELIMITER or ";" FOUND, POINTER AT ' . $ptr . "\n";
- }
- if ($paramstr[$ptr] !== '|') {
- $continue = false;
- if ($pointer !== null) {
- $pointer -= strlen($paramstr) - $ptr;
- }
- }
- ++ $ptr;
- break;
- }
- if ($ptr < strlen($paramstr) && $paramstr[$ptr] === ':') {
- ++ $ptr;
- }
- }
- $cmdstrsrc = substr($cmdstrsrc, strlen($func) + 1 + $ptr);
- foreach ($params as $k => $p) {
- if (is_array($p) && is_array($p[1])) {
- $state |= 2;
- } else {
- if (($state & 2) && preg_match('#^(["\'])(.+?)\1$#', $p[0], $m)) {
- $params[$k] = array($m[2], array('true', 'true'));
- } else {
- if ($state & 2) {
- throw new CompilationException($this, 'You can not use an unnamed parameter after a named one');
- }
- $state |= 1;
- }
- }
- }
- }
-
- // check if we must use array_map with this plugin or not
- $mapped = false;
- if (substr($func, 0, 1) === '@') {
- $func = substr($func, 1);
- $mapped = true;
- }
-
- $pluginType = $this->getPluginType($func);
-
- if ($state & 2) {
- array_unshift($params, array('value', is_array($output) ? $output : array($output, $output)));
- } else {
- array_unshift($params, is_array($output) ? $output : array($output, $output));
- }
-
- if ($pluginType & Core::NATIVE_PLUGIN) {
- $params = $this->mapParams($params, null, $state);
-
- $params = $params['*'][0];
-
- $params = self::implode_r($params);
-
- if ($mapped) {
- $output = '$this->arrayMap(\'' . $func . '\', array(' . $params . '))';
- } else {
- $output = $func . '(' . $params . ')';
- }
- } elseif ($pluginType & Core::PROXY_PLUGIN) {
- $params = $this->mapParams($params, $this->getCore()->getPluginProxy()->getCallback($func), $state);
- foreach ($params as &$p) {
- $p = $p[0];
- }
- $output = call_user_func(array($this->getCore()->getPluginProxy(), 'getCode'), $func, $params);
- } elseif ($pluginType & Core::SMARTY_MODIFIER) {
- $params = $this->mapParams($params, null, $state);
- $params = $params['*'][0];
-
- $params = self::implode_r($params);
-
- if ($pluginType & Core::CUSTOM_PLUGIN) {
- $callback = $this->customPlugins[$func]['callback'];
- if (is_array($callback)) {
- if (is_object($callback[0])) {
- $output = ($mapped ? '$this->arrayMap' : 'call_user_func_array') . '(array($this->getCustomPlugin(\'' . $func . '\'), \'' . $callback[1] . '\'), array(' . $params . '))';
- } else {
- $output = ($mapped ? '$this->arrayMap' : 'call_user_func_array') . '(array(\'' . $callback[0] . '\', \'' . $callback[1] . '\'), array(' . $params . '))';
- }
- } elseif ($mapped) {
- $output = '$this->arrayMap(\'' . $callback . '\', array(' . $params . '))';
- } else {
- $output = $callback . '(' . $params . ')';
- }
- } elseif ($mapped) {
- $output = '$this->arrayMap(\'smarty_modifier_' . $func . '\', array(' . $params . '))';
- } else {
- $output = 'smarty_modifier_' . $func . '(' . $params . ')';
- }
- } else {
- if ($pluginType & Core::CUSTOM_PLUGIN) {
- $pluginName = $callback = $this->customPlugins[$func]['callback'];
- if (($pluginType & Core::CLASS_PLUGIN) && !is_array($callback)) {
- $pluginName = $this->customPlugins[$func]['callback'];
- $callback = array($pluginName, ($pluginType & Core::COMPILABLE_PLUGIN) ? 'compile' : 'process');
- }
- } else {
- if (class_exists('Plugin' . Core::toCamelCase($func)) !== false || function_exists('Plugin' .
- Core::toCamelCase($func) . (($pluginType & Core::COMPILABLE_PLUGIN) ? 'Compile' : ''))
- !== false) {
- $pluginName = 'Plugin' . Core::toCamelCase($func);
- } else {
- $pluginName = Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($func);
- }
- if ($pluginType & Core::CLASS_PLUGIN) {
- $callback = array($pluginName, ($pluginType & Core::COMPILABLE_PLUGIN) ? 'compile' : 'process');
- } else {
- $callback = $pluginName . (($pluginType & Core::COMPILABLE_PLUGIN) ? 'Compile' : '');
- }
- }
- $params = $this->mapParams($params, $callback, $state);
-
- foreach ($params as &$p) {
- $p = $p[0];
- }
-
- // Only for PHP function, who is not a PHP class
- if ($pluginType & Core::FUNC_PLUGIN && !($pluginType & Core::CLASS_PLUGIN)) {
- if ($pluginType & Core::COMPILABLE_PLUGIN) {
- if ($mapped) {
- throw new CompilationException($this, 'The @ operator can not be used on compiled plugins.');
- }
- if ($pluginType & Core::CUSTOM_PLUGIN) {
- $funcCompiler = $this->customPlugins[$func]['callback'];
- } else {
- if (function_exists('Plugin' . Core::toCamelCase($func) . 'Compile') !== false) {
- $funcCompiler = 'Plugin' . Core::toCamelCase($func) . 'Compile';
- } else {
- $funcCompiler = Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($func) .
- 'Compile';
- }
- }
- array_unshift($params, $this);
- $output = call_user_func_array($funcCompiler, $params);
- } else {
- array_unshift($params, '$this');
-
- $params = self::implode_r($params);
- if ($mapped) {
- $output = '$this->arrayMap(\'' . $pluginName . '\', array(' . $params . '))';
- } else {
- $output = $pluginName . '(' . $params . ')';
- }
- }
- } else {
- if ($pluginType & Core::COMPILABLE_PLUGIN) {
- if ($mapped) {
- throw new CompilationException($this, 'The @ operator can not be used on compiled plugins.');
- }
- if ($pluginType & Core::CUSTOM_PLUGIN) {
- $callback = $this->customPlugins[$func]['callback'];
- if (!is_array($callback)) {
- if (!method_exists($callback, 'compile')) {
- throw new Exception('Custom plugin ' . $func . ' must implement the "compile" method to be compilable, or you should provide a full callback to the method to use');
- }
- if (($ref = new ReflectionMethod($callback, 'compile')) && $ref->isStatic()) {
- $funcCompiler = array($callback, 'compile');
- } else {
- $funcCompiler = array(new $callback(), 'compile');
- }
- } else {
- $funcCompiler = $callback;
- }
- } else {
- if (class_exists('Plugin' . Core::toCamelCase($func)) !== false) {
- $funcCompiler = array('Plugin' . Core::toCamelCase($func), 'compile');
- } else {
- $funcCompiler = array(Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($func), 'compile');
- }
- array_unshift($params, $this);
- }
- $output = call_user_func_array($funcCompiler, $params);
- } else {
- $params = self::implode_r($params);
-
- if ($pluginType & Core::CUSTOM_PLUGIN) {
- if (is_object($callback[0])) {
- if (is_array($this->getCore()->getCustomPlugin($func))) {
- $output = ($mapped ? '$this->arrayMap' : 'call_user_func_array') . '(array($this->plugins[\'' . $func . '\'][\'callback\'][0], \'' . $callback[1] . '\'), array(' . $params . '))';
- } else {
- $output = ($mapped ? '$this->arrayMap' : 'call_user_func_array') . '(array($this->getCustomPlugin(\'' . $func . '\'), \'' . $callback[1] . '\'), array(' . $params . '))';
- }
- } else {
- $output = ($mapped ? '$this->arrayMap' : 'call_user_func_array') . '(array(\'' . $callback[0] . '\', \'' . $callback[1] . '\'), array(' . $params . '))';
- }
- } elseif ($mapped) {
- $output = '$this->arrayMap(array($this->getObjectPlugin(\''.
- Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($func) . '\'),
- \'process\'), array(' . $params . '))';
- } else {
- if (class_exists('Plugin' . Core::toCamelCase($func)) !== false) {
- $output = '$this->classCall(\'Plugin' . Core::toCamelCase($func) . '\', array(' . $params . '))';
- } elseif (class_exists(Core::NAMESPACE_PLUGINS_BLOCKS . 'Plugin' . Core::toCamelCase($func)) !== false) {
- $output = '$this->classCall(\'' . Core::NAMESPACE_PLUGINS_BLOCKS . 'Plugin' . $func . '\', array(' . $params . '))';
- } elseif (class_exists(Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($func)) !== false) {
- $output = '$this->classCall(\'' . Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . $func . '\', array(' . $params . '))';
- } else {
- $output = '$this->classCall(\'' . $func . '\', array(' . $params . '))';
- }
- }
- }
- }
- }
- }
-
- if ($curBlock === 'namedparam') {
- return array($output, $output);
- } elseif ($curBlock === 'var' || $m[1] === null) {
- return $output;
- } elseif ($curBlock === 'string' || $curBlock === 'root') {
- return $m[1] . '.' . $output . '.' . $m[1] . (isset($add) ? $add : null);
- }
-
- return '';
- }
-
- /**
- * Recursively implodes an array in a similar manner as var_export() does but with some tweaks
- * to handle pre-compiled values and the fact that we do not need to enclose everything with
- * "array" and do not require top-level keys to be displayed.
- *
- * @param array $params the array to implode
- * @param bool $recursiveCall if set to true, the function outputs key names for the top level
- *
- * @return string the imploded array
- */
- public static function implode_r(array $params, $recursiveCall = false)
- {
- $out = '';
- foreach ($params as $k => $p) {
- if (is_array($p)) {
- $out2 = 'array(';
- foreach ($p as $k2 => $v) {
- $out2 .= var_export($k2, true) . ' => ' . (is_array($v) ? 'array(' . self::implode_r($v, true) . ')' : $v) . ', ';
- }
- $p = rtrim($out2, ', ') . ')';
- }
- if ($recursiveCall) {
- $out .= var_export($k, true) . ' => ' . $p . ', ';
- } else {
- $out .= $p . ', ';
- }
- }
-
- return rtrim($out, ', ');
- }
-
- /**
- * Returns the plugin type of a plugin and adds it to the used plugins array if required.
- *
- * @param string $name plugin name, as found in the template
- *
- * @return int type as a multi bit flag composed of the Dwoo plugin types constants
- * @throws Exception
- * @throws SecurityException
- * @throws Exception
- */
- protected function getPluginType($name)
- {
- $pluginType = - 1;
-
- if (($this->securityPolicy === null && (function_exists($name) || strtolower($name) === 'isset' || strtolower($name) === 'empty')) || ($this->securityPolicy !== null && array_key_exists(strtolower($name), $this->securityPolicy->getAllowedPhpFunctions()) !== false)) {
- $phpFunc = true;
- } elseif ($this->securityPolicy !== null && function_exists($name) && array_key_exists(strtolower($name), $this->securityPolicy->getAllowedPhpFunctions()) === false) {
- throw new SecurityException('Call to a disallowed php function : ' . $name);
- }
-
- while ($pluginType <= 0) {
- // Template plugin compilable
- if (isset($this->templatePlugins[$name])) {
- $pluginType = Core::TEMPLATE_PLUGIN | Core::COMPILABLE_PLUGIN;
- } // Custom plugin
- elseif (isset($this->customPlugins[$name])) {
- $pluginType = $this->customPlugins[$name]['type'] | Core::CUSTOM_PLUGIN;
- } // Class blocks plugin
- elseif (class_exists(Core::NAMESPACE_PLUGINS_BLOCKS . 'Plugin' . Core::toCamelCase($name)) !== false) {
- $pluginType = Core::CLASS_PLUGIN;
- if (is_subclass_of(Core::NAMESPACE_PLUGINS_BLOCKS . 'Plugin' . Core::toCamelCase($name), 'Dwoo\Block\Plugin')) {
- $pluginType += Core::BLOCK_PLUGIN;
- }
- $interfaces = class_implements(Core::NAMESPACE_PLUGINS_BLOCKS . 'Plugin' . Core::toCamelCase($name));
- if (in_array('Dwoo\ICompilable', $interfaces) !== false || in_array('Dwoo\ICompilable\Block', $interfaces) !== false) {
- $pluginType |= Core::COMPILABLE_PLUGIN;
- }
- } // Class functions plugin
- elseif (class_exists(Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($name)) !== false) {
- $pluginType = Core::FUNC_PLUGIN + Core::CLASS_PLUGIN;
- $interfaces = class_implements(Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($name));
- if (in_array('Dwoo\ICompilable', $interfaces) !== false || in_array('Dwoo\ICompilable\Block', $interfaces) !== false) {
- $pluginType |= Core::COMPILABLE_PLUGIN;
- }
- } // Class without namespace
- elseif (class_exists('Plugin' . Core::toCamelCase($name)) !== false) {
- $pluginType = Core::CLASS_PLUGIN;
- $interfaces = class_implements('Plugin' . Core::toCamelCase($name));
- if (in_array('Dwoo\ICompilable', $interfaces) !== false || in_array('Dwoo\ICompilable\Block', $interfaces) !== false) {
- $pluginType |= Core::COMPILABLE_PLUGIN;
- }
- } // Function plugin (with/without namespaces)
- elseif (function_exists(Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase ($name)) !==
- false || function_exists('Plugin' . Core::toCamelCase($name)) !== false) {
- $pluginType = Core::FUNC_PLUGIN;
- } // Function plugin compile (with/without namespaces)
- elseif (function_exists(Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($name) .
- 'Compile') !== false || function_exists('Plugin' . Core::toCamelCase($name) . 'Compile') !==
- false) {
- $pluginType = Core::FUNC_PLUGIN | Core::COMPILABLE_PLUGIN;
- } // Helper plugin class compile
- elseif (class_exists(Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase($name)) !== false) {
- $pluginType = Core::CLASS_PLUGIN | Core::COMPILABLE_PLUGIN;
- } // Helper plugin function compile
- elseif (function_exists(Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase($name) . 'Compile') !== false) {
- $pluginType = Core::FUNC_PLUGIN | Core::COMPILABLE_PLUGIN;
- } // Smarty modifier
- elseif (function_exists('smarty_modifier_' . $name) !== false) {
- $pluginType = Core::SMARTY_MODIFIER;
- } // Smarty function
- elseif (function_exists('smarty_function_' . $name) !== false) {
- $pluginType = Core::SMARTY_FUNCTION;
- } // Smarty block
- elseif (function_exists('smarty_block_' . $name) !== false) {
- $pluginType = Core::SMARTY_BLOCK;
- } // Everything else
- else {
- if ($pluginType === - 1) {
- try {
- $this->getCore()->getLoader()->loadPlugin('Plugin' . Core::toCamelCase($name));
- }
- catch (Exception $e) {
- if (isset($phpFunc)) {
- $pluginType = Core::NATIVE_PLUGIN;
- } elseif (is_object($this->getCore()->getPluginProxy()) && $this->getCore()->getPluginProxy()->handles($name)) {
- $pluginType = Core::PROXY_PLUGIN;
- break;
- } else {
- throw $e;
- }
- }
- } else {
- throw new Exception('Plugin "' . $name . '" could not be found, type:' . $pluginType);
- }
- ++ $pluginType;
- }
- }
-
- if (($pluginType & Core::COMPILABLE_PLUGIN) === 0 && ($pluginType & Core::NATIVE_PLUGIN) === 0 && ($pluginType & Core::PROXY_PLUGIN) === 0) {
- $this->addUsedPlugin(Core::toCamelCase($name), $pluginType);
- }
-
- return $pluginType;
- }
-
- /**
- * Allows a plugin to load another one at compile time, this will also mark
- * it as used by this template so it will be loaded at runtime (which can be
- * useful for compiled plugins that rely on another plugin when their compiled
- * code runs).
- *
- * @param string $name the plugin name
- *
- * @return void
- */
- public function loadPlugin($name)
- {
- $this->getPluginType($name);
- }
-
- /**
- * Runs htmlentities over the matched blocks when the security policy enforces that.
- *
- * @param array $match matched php block
- *
- * @return string the htmlentities-converted string
- */
- protected function phpTagEncodingHelper($match)
- {
- return htmlspecialchars($match[0]);
- }
-
- /**
- * Maps the parameters received from the template onto the parameters required by the given callback.
- *
- * @param array $params the array of parameters
- * @param callback $callback the function or method to reflect on to find out the required parameters
- * @param int $callType the type of call in the template, 0 = no params, 1 = php-style call, 2 = named
- * parameters call
- * @param array $map the parameter map to use, if not provided it will be built from the callback
- *
- * @return array parameters sorted in the correct order with missing optional parameters filled
- * @throws CompilationException
- */
- protected function mapParams(array $params, $callback, $callType = 2, $map = null)
- {
- if (!$map) {
- $map = $this->getParamMap($callback);
- }
-
- $paramlist = array();
-
- // transforms the parameter array from (x=>array('paramname'=>array(values))) to (paramname=>array(values))
- $ps = array();
- foreach ($params as $p) {
- if (is_array($p[1])) {
- $ps[$p[0]] = $p[1];
- } else {
- $ps[] = $p;
- }
- }
-
- // loops over the param map and assigns values from the template or default value for unset optional params
- foreach ($map as $k => $v){
- if ($v[0] === '*') {
- // "rest" array parameter, fill every remaining params in it and then break
- if (count($ps) === 0) {
- if ($v[1] === false) {
- throw new CompilationException(
- $this, 'Rest argument missing for ' . str_replace(
- array(
- Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin',
- 'Compile'
- ), '', (is_array($callback) ? $callback[0] : $callback)
- )
- );
- } else {
- break;
- }
- }
- $tmp = array();
- $tmp2 = array();
- $tmp3 = array();
- foreach ($ps as $i => $p) {
- $tmp[$i] = $p[0];
- $tmp2[$i] = $p[1];
- $tmp3[$i] = isset($p[2]) ? $p[2] : 0;
- unset($ps[$i]);
- }
- $paramlist[$v[0]] = array($tmp, $tmp2, $tmp3);
- unset($tmp, $tmp2, $i, $p);
- break;
- } elseif (isset($ps[$v[0]])) {
- // parameter is defined as named param
- $paramlist[$v[0]] = $ps[$v[0]];
- unset($ps[$v[0]]);
- } elseif (isset($ps[$k])) {
- // parameter is defined as ordered param
- $paramlist[$v[0]] = $ps[$k];
- unset($ps[$k]);
- } elseif ($v[1] === false) {
- // parameter is not defined and not optional, throw error
- if (is_array($callback)) {
- if (is_object($callback[0])) {
- $name = get_class($callback[0]) . '::' . $callback[1];
- } else {
- $name = $callback[0];
- }
- } else {
- $name = $callback;
- }
-
- throw new CompilationException(
- $this, 'Argument ' . $k . '/' . $v[0] . ' missing for ' . str_replace(
- array(
- Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin',
- 'Compile'
- ), '', $name
- )
- );
- } elseif ($v[2] === null) {
- // enforce lowercased null if default value is null (php outputs NULL with var export)
- $paramlist[$v[0]] = array('null', null, self::T_NULL);
- } else {
- // outputs default value with var_export
- $paramlist[$v[0]] = array(var_export($v[2], true), $v[2]);
- }
- }
-
- if (count($ps)) {
- foreach ($ps as $i => $p) {
- array_push($paramlist, $p);
- }
- }
-
- return $paramlist;
- }
-
- /**
- * Returns the parameter map of the given callback, it filters out entries typed as Dwoo and Compiler and turns the
- * rest parameter into a "*".
- *
- * @param callback $callback the function/method to reflect on
- *
- * @return array processed parameter map
- */
- protected function getParamMap($callback)
- {
- if (is_null($callback)) {
- return array(array('*', true));
- }
- if (is_array($callback)) {
- $ref = new ReflectionMethod($callback[0], $callback[1]);
- } else {
- $ref = new ReflectionFunction($callback);
- }
-
- $out = array();
- foreach ($ref->getParameters() as $param) {
- if (($class = $param->getClass()) !== null && $class->name === 'Dwoo\Core') {
- continue;
- }
- if (($class = $param->getClass()) !== null && $class->name === 'Dwoo\Compiler') {
- continue;
- }
- if ($param->getName() === 'rest' && $param->isArray() === true) {
- $out[] = array('*', $param->isOptional(), null);
- continue;
- }
- $out[] = array(
- $param->getName(),
- $param->isOptional(),
- $param->isOptional() ? $param->getDefaultValue() : null
- );
- }
-
- return $out;
- }
-
- /**
- * Returns a default instance of this compiler, used by default by all Dwoo templates that do not have a
- * specific compiler assigned and when you do not override the default compiler factory function.
- *
- * @see Core::setDefaultCompilerFactory()
- * @return Compiler
- */
- public static function compilerFactory()
- {
- if (self::$instance === null) {
- self::$instance = new self();
- }
-
- return self::$instance;
- }
-}
diff --git a/core/l/Dwoo/Core.php b/core/l/Dwoo/Core.php
deleted file mode 100644
index a0386c0..0000000
--- a/core/l/Dwoo/Core.php
+++ /dev/null
@@ -1,1792 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2017 David Sanchez
- * @license http://dwoo.org/LICENSE LGPLv3
- * @version 1.3.6
- * @date 2017-03-23
- * @link http://dwoo.org/
- */
-
-namespace Dwoo;
-
-use ArrayAccess;
-use Closure;
-use Countable;
-use Dwoo\Plugins\Blocks\PluginDynamic;
-use Dwoo\Security\Policy as SecurityPolicy;
-use Dwoo\Block\Plugin as BlockPlugin;
-use Dwoo\Template\File as TemplateFile;
-use Iterator;
-use stdClass;
-use Traversable;
-
-/**
- * Main dwoo class, allows communication between the compiler, template and data classes.
- *
- * requirements :
- * php 5.3.0 or above (might work below, it's a rough estimate)
- * SPL and PCRE extensions (for php versions prior to 5.3.0)
- * mbstring extension for some string manipulation plugins (especially if you intend to use UTF-8)
- * recommended :
- * hash extension (for Dwoo\Template\Str - minor performance boost)
- * project created :
- * 2008-01-05
- *
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class Core
-{
- /**
- * Current version number.
- *
- * @var string
- */
- const VERSION = '1.3.6';
-
- /**
- * Unique number of this dwoo release, based on version number.
- * this can be used by templates classes to check whether the compiled template
- * has been compiled before this release or not, so that old templates are
- * recompiled automatically when Dwoo is updated
- */
- const RELEASE_TAG = 136;
-
- /**
- * Constants that represents all plugin types
- * these are bitwise-operation-safe values to allow multiple types
- * on a single plugin
- *
- * @var int
- */
- const CLASS_PLUGIN = 1;
- const FUNC_PLUGIN = 2;
- const NATIVE_PLUGIN = 4;
- const BLOCK_PLUGIN = 8;
- const COMPILABLE_PLUGIN = 16;
- const CUSTOM_PLUGIN = 32;
- const SMARTY_MODIFIER = 64;
- const SMARTY_BLOCK = 128;
- const SMARTY_FUNCTION = 256;
- const PROXY_PLUGIN = 512;
- const TEMPLATE_PLUGIN = 1024;
-
- /**
- * Constant to default namespaces of builtin plugins
- *
- * @var string
- */
- const NAMESPACE_PLUGINS_BLOCKS = 'Dwoo\Plugins\Blocks\\';
- const NAMESPACE_PLUGINS_FILTERS = 'Dwoo\Plugins\Filters\\';
- const NAMESPACE_PLUGINS_FUNCTIONS = 'Dwoo\Plugins\Functions\\';
- const NAMESPACE_PLUGINS_HELPERS = 'Dwoo\Plugins\Helpers\\';
- const NAMESPACE_PLUGINS_PROCESSORS = 'Dwoo\Plugins\Processors\\';
-
- /**
- * Character set of the template, used by string manipulation plugins.
- * it must be lowercase, but setCharset() will take care of that
- *
- * @see setCharset
- * @see getCharset
- * @var string
- */
- protected $charset = 'UTF-8';
-
- /**
- * Global variables that are accessible through $dwoo.* in the templates.
- * default values include:
- * $dwoo.version - current version number
- * $dwoo.ad - a Powered by Dwoo link pointing to dwoo.org
- * $dwoo.now - the current time
- * $dwoo.template - the current template filename
- * $dwoo.charset - the character set used by the template
- * on top of that, foreach and other plugins can store special values in there,
- * see their documentation for more details.
- *
- * @var array
- */
- protected $globals = array();
-
- /**
- * Directory where the compiled templates are stored.
- * defaults to DWOO_COMPILEDIR (= dwoo_dir/compiled by default)
- *
- * @var string
- */
- protected $compileDir;
-
- /**
- * Directory where the cached templates are stored.
- * defaults to DWOO_CACHEDIR (= dwoo_dir/cache by default)
- *
- * @var string
- */
- protected $cacheDir;
-
- /**
- * Directory where the template files are stored
- *
- * @var array
- */
- protected $templateDir = array();
-
- /**
- * Defines how long (in seconds) the cached files must remain valid.
- * can be overridden on a per-template basis
- * -1 = never delete
- * 0 = disabled
- * >0 = duration in seconds
- *
- * @var int
- */
- protected $cacheTime = 0;
-
- /**
- * Security policy object.
- *
- * @var SecurityPolicy
- */
- protected $securityPolicy = null;
-
- /**
- * Stores the custom plugins callbacks.
- *
- * @see addPlugin
- * @see removePlugin
- * @var array
- */
- protected $plugins = array();
-
- /**
- * Stores the filter callbacks.
- *
- * @see addFilter
- * @see removeFilter
- * @var array
- */
- protected $filters = array();
-
- /**
- * Stores the resource types and associated
- * classes / compiler classes.
- *
- * @var array
- */
- protected $resources = array(
- 'file' => array(
- 'class' => 'Dwoo\Template\File',
- 'compiler' => null,
- ),
- 'string' => array(
- 'class' => 'Dwoo\Template\Str',
- 'compiler' => null,
- ),
- );
-
- /**
- * The dwoo loader object used to load plugins by this dwoo instance.
- *
- * @var ILoader
- */
- protected $loader = null;
-
- /**
- * Currently rendered template, set to null when not-rendering.
- *
- * @var ITemplate
- */
- protected $template = null;
-
- /**
- * Stores the instances of the class plugins during template runtime.
- *
- * @var array
- */
- protected $runtimePlugins = array();
-
- /**
- * Stores the returned values during template runtime.
- *
- * @var array
- */
- protected $returnData = array();
-
- /**
- * Stores the data during template runtime.
- *
- * @var array
- */
- protected $data = array();
-
- /**
- * Stores the current scope during template runtime.
- * this should ideally not be accessed directly from outside template code
- *
- * @var mixed
- */
- public $scope;
-
- /**
- * Stores the scope tree during template runtime.
- *
- * @var array
- */
- protected $scopeTree = array();
-
- /**
- * Stores the block plugins stack during template runtime.
- *
- * @var array
- */
- protected $stack = array();
-
- /**
- * Stores the current block plugin at the top of the stack during template runtime.
- *
- * @var BlockPlugin
- */
- protected $curBlock;
-
- /**
- * Stores the output buffer during template runtime.
- *
- * @var string
- */
- protected $buffer;
-
- /**
- * Stores plugin proxy.
- *
- * @var IPluginProxy
- */
- protected $pluginProxy;
-
- /**
- * Constructor, sets the cache and compile dir to the default values if not provided.
- *
- * @param string $compileDir path to the compiled directory, defaults to lib/compiled
- * @param string $cacheDir path to the cache directory, defaults to lib/cache
- */
- public function __construct($compileDir = null, $cacheDir = null)
- {
- if ($compileDir !== null) {
- $this->setCompileDir($compileDir);
- }
- if ($cacheDir !== null) {
- $this->setCacheDir($cacheDir);
- }
- $this->initGlobals();
- }
-
- /**
- * Resets some runtime variables to allow a cloned object to be used to render sub-templates.
- *
- * @return void
- */
- public function __clone()
- {
- $this->template = null;
- unset($this->data);
- unset($this->returnData);
- }
-
- /**
- * Returns the given template rendered using the provided data and optional compiler.
- *
- * @param mixed $_tpl template, can either be a ITemplate object (i.e. TemplateFile), a
- * valid path to a template, or a template as a string it is recommended to
- * provide a ITemplate as it will probably make things faster, especially if
- * you render a template multiple times
- * @param mixed $data the data to use, can either be a IDataProvider object (i.e. Data) or
- * an associative array. if you're rendering the template from cache, it can be
- * left null
- * @param ICompiler $_compiler the compiler that must be used to compile the template, if left empty a default
- * Compiler will be used
- *
- * @return string|void or the template output if $output is false
- * @throws Exception
- */
- public function get($_tpl, $data = array(), $_compiler = null)
- {
- // a render call came from within a template, so we need a new dwoo instance in order to avoid breaking this one
- if ($this->template instanceof ITemplate) {
- $clone = clone $this;
-
- return $clone->get($_tpl, $data, $_compiler);
- }
-
- // auto-create template if required
- if ($_tpl instanceof ITemplate) {
- // valid, skip
- } elseif (is_string($_tpl)) {
- $_tpl = new TemplateFile($_tpl);
- $_tpl->setIncludePath($this->getTemplateDir());
- } else {
- throw new Exception('Dwoo->get\'s first argument must be a ITemplate (i.e. TemplateFile) or a valid path to a template file', E_USER_NOTICE);
- }
-
- // save the current template, enters render mode at the same time
- // if another rendering is requested it will be proxied to a new Core(instance
- $this->template = $_tpl;
-
- // load data
- if ($data instanceof IDataProvider) {
- $this->data = $data->getData();
- } elseif (is_array($data)) {
- $this->data = $data;
- } elseif ($data instanceof ArrayAccess) {
- $this->data = $data;
- } else {
- throw new Exception('Dwoo->get/Dwoo->output\'s data argument must be a IDataProvider object (i.e. Data) or an associative array', E_USER_NOTICE);
- }
-
- $this->addGlobal('template', $_tpl->getName());
- $this->initRuntimeVars($_tpl);
-
- // try to get cached template
- $file = $_tpl->getCachedTemplate($this);
- $doCache = $file === true;
- $cacheLoaded = is_string($file);
-
- if ($cacheLoaded === true) {
- // cache is present, run it
- ob_start();
- include $file;
- $this->template = null;
-
- return ob_get_clean();
- } else {
- $dynamicId = uniqid();
-
- // render template
- $compiledTemplate = $_tpl->getCompiledTemplate($this, $_compiler);
- $out = include $compiledTemplate;
-
- // template returned false so it needs to be recompiled
- if ($out === false) {
- $_tpl->forceCompilation();
- $compiledTemplate = $_tpl->getCompiledTemplate($this, $_compiler);
- $out = include $compiledTemplate;
- }
-
- if ($doCache === true) {
- $out = preg_replace('/(<%|%>|<\?php|<\?|\?>)/', '', $out);
- if (!class_exists(self::NAMESPACE_PLUGINS_BLOCKS . 'PluginDynamic')) {
- $this->getLoader()->loadPlugin('PluginDynamic');
- }
- $out = PluginDynamic::unescape($out, $dynamicId, $compiledTemplate);
- }
-
- // process filters
- foreach ($this->filters as $filter) {
- if (is_array($filter) && $filter[0] instanceof Filter) {
- $out = call_user_func($filter, $out);
- } else {
- $out = call_user_func($filter, $this, $out);
- }
- }
-
- if ($doCache === true) {
- // building cache
- $file = $_tpl->cache($this, $out);
-
- // run it from the cache to be sure dynamics are rendered
- ob_start();
- include $file;
- // exit render mode
- $this->template = null;
-
- return ob_get_clean();
- } else {
- // no need to build cache
- // exit render mode
- $this->template = null;
-
- return $out;
- }
- }
- }
-
- /**
- * Registers a Global.
- * New globals can be added before compiling or rendering a template
- * but after, you can only update existing globals.
- *
- * @param string $name
- * @param mixed $value
- *
- * @return $this
- * @throws Exception
- */
- public function addGlobal($name, $value)
- {
- if (null === $this->globals) {
- $this->initGlobals();
- }
-
- $this->globals[$name] = $value;
-
- return $this;
- }
-
- /**
- * Gets the registered Globals.
- *
- * @return array
- */
- public function getGlobals()
- {
- return $this->globals;
- }
-
- /**
- * Re-initializes the globals array before each template run.
- * this method is only callede once when the Dwoo object is created
- *
- * @return void
- */
- protected function initGlobals()
- {
- $this->globals = array(
- 'version' => self::VERSION,
- 'ad' => 'Powered by Dwoo',
- 'now' => $_SERVER['REQUEST_TIME'],
- 'charset' => $this->getCharset(),
- );
- }
-
- /**
- * Re-initializes the runtime variables before each template run.
- * override this method to inject data in the globals array if needed, this
- * method is called before each template execution
- *
- * @param ITemplate $tpl the template that is going to be rendered
- *
- * @return void
- */
- protected function initRuntimeVars(ITemplate $tpl)
- {
- $this->runtimePlugins = array();
- $this->scope = &$this->data;
- $this->scopeTree = array();
- $this->stack = array();
- $this->curBlock = null;
- $this->buffer = '';
- $this->returnData = array();
- }
-
- /**
- * Adds a custom plugin that is not in one of the plugin directories.
- *
- * @param string $name the plugin name to be used in the templates
- * @param callback $callback the plugin callback, either a function name,
- * a class name or an array containing an object
- * or class name and a method name
- * @param bool $compilable if set to true, the plugin is assumed to be compilable
- *
- * @return void
- * @throws Exception
- */
- public function addPlugin($name, $callback, $compilable = false)
- {
- $compilable = $compilable ? self::COMPILABLE_PLUGIN : 0;
- if (is_array($callback)) {
- if (is_subclass_of(is_object($callback[0]) ? get_class($callback[0]) : $callback[0], 'Dwoo\Block\Plugin')) {
- $this->plugins[$name] = array(
- 'type' => self::BLOCK_PLUGIN | $compilable,
- 'callback' => $callback,
- 'class' => (is_object($callback[0]) ? get_class($callback[0]) : $callback[0])
- );
- } else {
- $this->plugins[$name] = array(
- 'type' => self::CLASS_PLUGIN | $compilable,
- 'callback' => $callback,
- 'class' => (is_object($callback[0]) ? get_class($callback[0]) : $callback[0]),
- 'function' => $callback[1]
- );
- }
- } elseif (is_string($callback)) {
- if (class_exists($callback)) {
- if (is_subclass_of($callback, 'Dwoo\Block\Plugin')) {
- $this->plugins[$name] = array(
- 'type' => self::BLOCK_PLUGIN | $compilable,
- 'callback' => $callback,
- 'class' => $callback
- );
- } else {
- $this->plugins[$name] = array(
- 'type' => self::CLASS_PLUGIN | $compilable,
- 'callback' => $callback,
- 'class' => $callback,
- 'function' => ($compilable ? 'compile' : 'process')
- );
- }
- } elseif (function_exists($callback)) {
- $this->plugins[$name] = array(
- 'type' => self::FUNC_PLUGIN | $compilable,
- 'callback' => $callback
- );
- } else {
- throw new Exception('Callback could not be processed correctly, please check that the function/class you used exists');
- }
- } elseif ($callback instanceof Closure) {
- $this->plugins[$name] = array(
- 'type' => self::FUNC_PLUGIN | $compilable,
- 'callback' => $callback
- );
- } elseif (is_object($callback)) {
- if (is_subclass_of($callback, 'Dwoo\Block\Plugin')) {
- $this->plugins[$name] = array(
- 'type' => self::BLOCK_PLUGIN | $compilable,
- 'callback' => get_class($callback),
- 'class' => $callback
- );
- } else {
- $this->plugins[$name] = array(
- 'type' => self::CLASS_PLUGIN | $compilable,
- 'callback' => $callback,
- 'class' => $callback,
- 'function' => ($compilable ? 'compile' : 'process')
- );
- }
- } else {
- throw new Exception('Callback could not be processed correctly, please check that the function/class you used exists');
- }
- }
-
- /**
- * Removes a custom plugin.
- *
- * @param string $name the plugin name
- *
- * @return void
- */
- public function removePlugin($name)
- {
- if (isset($this->plugins[$name])) {
- unset($this->plugins[$name]);
- }
- }
-
- /**
- * Adds a filter to this Dwoo instance, it will be used to filter the output of all the templates rendered by this
- * instance.
- *
- * @param mixed $callback a callback or a filter name if it is autoloaded from a plugin directory
- * @param bool $autoload if true, the first parameter must be a filter name from one of the plugin directories
- *
- * @return void
- * @throws Exception
- */
- public function addFilter($callback, $autoload = false)
- {
- if ($autoload) {
- $class = self::NAMESPACE_PLUGINS_FILTERS . self::toCamelCase($callback);
- if (!class_exists($class) && !function_exists($class)) {
- try {
- $this->getLoader()->loadPlugin($callback);
- }
- catch (Exception $e) {
- if (strstr($callback, self::NAMESPACE_PLUGINS_FILTERS)) {
- throw new Exception('Wrong filter name : ' . $callback . ', the "Filter" prefix should not be used, please only use "' . str_replace('Filter', '', $callback) . '"');
- } else {
- throw new Exception('Wrong filter name : ' . $callback . ', when using autoload the filter must be in one of your plugin dir as "name.php" containig a class or function named "Filter"');
- }
- }
- }
-
- if (class_exists($class)) {
- $callback = array(new $class($this), 'process');
- } elseif (function_exists($class)) {
- $callback = $class;
- } else {
- throw new Exception('Wrong filter name : ' . $callback . ', when using autoload the filter must be in one of your plugin dir as "name.php" containig a class or function named "Filter"');
- }
-
- $this->filters[] = $callback;
- } else {
- $this->filters[] = $callback;
- }
- }
-
- /**
- * Removes a filter.
- *
- * @param mixed $callback callback or filter name if it was autoloaded
- *
- * @return void
- */
- public function removeFilter($callback)
- {
- if (($index = array_search(self::NAMESPACE_PLUGINS_FILTERS. 'Filter' . self::toCamelCase($callback), $this->filters,
- true)) !==
- false) {
- unset($this->filters[$index]);
- } elseif (($index = array_search($callback, $this->filters, true)) !== false) {
- unset($this->filters[$index]);
- } else {
- $class = self::NAMESPACE_PLUGINS_FILTERS . 'Filter' . $callback;
- foreach ($this->filters as $index => $filter) {
- if (is_array($filter) && $filter[0] instanceof $class) {
- unset($this->filters[$index]);
- break;
- }
- }
- }
- }
-
- /**
- * Adds a resource or overrides a default one.
- *
- * @param string $name the resource name
- * @param string $class the resource class (which must implement ITemplate)
- * @param callback $compilerFactory the compiler factory callback, a function that must return a compiler instance
- * used to compile this resource, if none is provided. by default it will produce
- * a Compiler object
- *
- * @return void
- * @throws Exception
- */
- public function addResource($name, $class, $compilerFactory = null)
- {
- if (strlen($name) < 2) {
- throw new Exception('Resource names must be at least two-character long to avoid conflicts with Windows paths');
- }
-
- if (!class_exists($class)) {
- throw new Exception(sprintf('Resource class %s does not exist', $class));
- }
-
- $interfaces = class_implements($class);
- if (in_array('Dwoo\ITemplate', $interfaces) === false) {
- throw new Exception('Resource class must implement ITemplate');
- }
-
- $this->resources[$name] = array(
- 'class' => $class,
- 'compiler' => $compilerFactory
- );
- }
-
- /**
- * Removes a custom resource.
- *
- * @param string $name the resource name
- *
- * @return void
- */
- public function removeResource($name)
- {
- unset($this->resources[$name]);
- if ($name === 'file') {
- $this->resources['file'] = array(
- 'class' => 'Dwoo\Template\File',
- 'compiler' => null
- );
- }
- }
-
- /**
- * Sets the loader object to use to load plugins.
- *
- * @param ILoader $loader loader
- *
- * @return void
- */
- public function setLoader(ILoader $loader)
- {
- $this->loader = $loader;
- }
-
- /**
- * Returns the current loader object or a default one if none is currently found.
- *
- * @return ILoader|Loader
- */
- public function getLoader()
- {
- if ($this->loader === null) {
- $this->loader = new Loader($this->getCompileDir());
- }
-
- return $this->loader;
- }
-
- /**
- * Returns the custom plugins loaded.
- * Used by the ITemplate classes to pass the custom plugins to their ICompiler instance.
- *
- * @return array
- */
- public function getCustomPlugins()
- {
- return $this->plugins;
- }
-
- /**
- * Return a specified custom plugin loaded by his name.
- * Used by the compiler, for executing a Closure.
- *
- * @param string $name
- *
- * @return mixed|null
- */
- public function getCustomPlugin($name)
- {
- if (isset($this->plugins[$name])) {
- return $this->plugins[$name]['callback'];
- }
-
- return null;
- }
-
- /**
- * Returns the cache directory with a trailing DIRECTORY_SEPARATOR.
- *
- * @return string
- */
- public function getCacheDir()
- {
- if ($this->cacheDir === null) {
- $this->setCacheDir(dirname(__DIR__) . DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR);
- }
-
- return $this->cacheDir;
- }
-
- /**
- * Sets the cache directory and automatically appends a DIRECTORY_SEPARATOR.
- *
- * @param string $dir the cache directory
- *
- * @return void
- * @throws Exception
- */
- public function setCacheDir($dir)
- {
- $this->cacheDir = rtrim($dir, '/\\') . DIRECTORY_SEPARATOR;
- if (!file_exists($this->cacheDir)) {
- mkdir($this->cacheDir, 0777, true);
- }
- if (is_writable($this->cacheDir) === false) {
- throw new Exception('The cache directory must be writable, chmod "' . $this->cacheDir . '" to make it writable');
- }
- }
-
- /**
- * Returns the compile directory with a trailing DIRECTORY_SEPARATOR.
- *
- * @return string
- */
- public function getCompileDir()
- {
- if ($this->compileDir === null) {
- $this->setCompileDir(dirname(__DIR__) . DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR);
- }
-
- return $this->compileDir;
- }
-
- /**
- * Sets the compile directory and automatically appends a DIRECTORY_SEPARATOR.
- *
- * @param string $dir the compile directory
- *
- * @return void
- * @throws Exception
- */
- public function setCompileDir($dir)
- {
- $this->compileDir = rtrim($dir, '/\\') . DIRECTORY_SEPARATOR;
- if (!file_exists($this->compileDir)) {
- mkdir($this->compileDir, 0777, true);
- }
- if (is_writable($this->compileDir) === false) {
- throw new Exception('The compile directory must be writable, chmod "' . $this->compileDir . '" to make it writable');
- }
- }
-
- /**
- * Returns an array of the template directory with a trailing DIRECTORY_SEPARATOR
- *
- * @return array
- */
- public function getTemplateDir()
- {
- return $this->templateDir;
- }
-
- /**
- * sets the template directory and automatically appends a DIRECTORY_SEPARATOR
- * template directory is stored in an array
- *
- * @param string $dir
- *
- * @throws Exception
- */
- public function setTemplateDir($dir)
- {
- $tmpDir = rtrim($dir, '/\\') . DIRECTORY_SEPARATOR;
- if (is_dir($tmpDir) === false) {
- throw new Exception('The template directory: "' . $tmpDir . '" does not exists, create the directory or specify an other location !');
- }
- $this->templateDir[] = $tmpDir;
- }
-
- /**
- * Returns the default cache time that is used with templates that do not have a cache time set.
- *
- * @return int the duration in seconds
- */
- public function getCacheTime()
- {
- return $this->cacheTime;
- }
-
- /**
- * Sets the default cache time to use with templates that do not have a cache time set.
- *
- * @param int $seconds the duration in seconds
- *
- * @return void
- */
- public function setCacheTime($seconds)
- {
- $this->cacheTime = (int)$seconds;
- }
-
- /**
- * Returns the character set used by the string manipulation plugins.
- * the charset is automatically lowercased
- *
- * @return string
- */
- public function getCharset()
- {
- return $this->charset;
- }
-
- /**
- * Sets the character set used by the string manipulation plugins.
- * the charset will be automatically lowercased
- *
- * @param string $charset the character set
- *
- * @return void
- */
- public function setCharset($charset)
- {
- $this->charset = strtolower((string)$charset);
- }
-
- /**
- * Returns the current template being rendered, when applicable, or null.
- *
- * @return ITemplate|null
- */
- public function getTemplate()
- {
- return $this->template;
- }
-
- /**
- * Sets the current template being rendered.
- *
- * @param ITemplate $tpl template object
- *
- * @return void
- */
- public function setTemplate(ITemplate $tpl)
- {
- $this->template = $tpl;
- }
-
- /**
- * Sets the default compiler factory function for the given resource name.
- * a compiler factory must return a ICompiler object pre-configured to fit your needs
- *
- * @param string $resourceName the resource name (i.e. file, string)
- * @param callback $compilerFactory the compiler factory callback
- *
- * @return void
- */
- public function setDefaultCompilerFactory($resourceName, $compilerFactory)
- {
- $this->resources[$resourceName]['compiler'] = $compilerFactory;
- }
-
- /**
- * Returns the default compiler factory function for the given resource name.
- *
- * @param string $resourceName the resource name
- *
- * @return callback the compiler factory callback
- */
- public function getDefaultCompilerFactory($resourceName)
- {
- return $this->resources[$resourceName]['compiler'];
- }
-
- /**
- * Sets the security policy object to enforce some php security settings.
- * use this if untrusted persons can modify templates
- *
- * @param SecurityPolicy $policy the security policy object
- *
- * @return void
- */
- public function setSecurityPolicy(SecurityPolicy $policy = null)
- {
- $this->securityPolicy = $policy;
- }
-
- /**
- * Returns the current security policy object or null by default.
- *
- * @return SecurityPolicy|null the security policy object if any
- */
- public function getSecurityPolicy()
- {
- return $this->securityPolicy;
- }
-
- /**
- * Sets the object that must be used as a plugin proxy when plugin can't be found
- * by dwoo's loader.
- *
- * @param IPluginProxy $pluginProxy the proxy object
- *
- * @return void
- */
- public function setPluginProxy(IPluginProxy $pluginProxy)
- {
- $this->pluginProxy = $pluginProxy;
- }
-
- /**
- * Returns the current plugin proxy object or null by default.
- *
- * @return IPluginProxy
- */
- public function getPluginProxy()
- {
- return $this->pluginProxy;
- }
-
- /**
- * Checks whether the given template is cached or not.
- *
- * @param ITemplate $tpl the template object
- *
- * @return bool
- */
- public function isCached(ITemplate $tpl)
- {
- return is_string($tpl->getCachedTemplate($this));
- }
-
- /**
- * Clear templates inside the compiled directory.
- *
- * @return int
- */
- public function clearCompiled()
- {
- $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->getCompileDir()), \RecursiveIteratorIterator::SELF_FIRST);
- $count = 0;
- foreach ($iterator as $file) {
- if ($file->isFile()) {
- $count += unlink($file->__toString()) ? 1 : 0;
- }
- }
-
- return $count;
- }
-
- /**
- * Clears the cached templates if they are older than the given time.
- *
- * @param int $olderThan minimum time (in seconds) required for a cached template to be cleared
- *
- * @return int the amount of templates cleared
- */
- public function clearCache($olderThan = - 1)
- {
- $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->getCacheDir()), \RecursiveIteratorIterator::SELF_FIRST);
- $expired = time() - $olderThan;
- $count = 0;
- foreach ($iterator as $file) {
- if ($file->isFile() && $file->getCTime() < $expired) {
- $count += unlink((string)$file) ? 1 : 0;
- }
- }
-
- return $count;
- }
-
- /**
- * Fetches a template object of the given resource.
- *
- * @param string $resourceName the resource name (i.e. file, string)
- * @param string $resourceId the resource identifier (i.e. file path)
- * @param int $cacheTime the cache time setting for this resource
- * @param string $cacheId the unique cache identifier
- * @param string $compileId the unique compiler identifier
- * @param ITemplate $parentTemplate the parent template
- *
- * @return ITemplate
- * @throws Exception
- */
- public function templateFactory($resourceName, $resourceId, $cacheTime = null, $cacheId = null, $compileId = null, ITemplate $parentTemplate = null)
- {
- if (isset($this->resources[$resourceName])) {
- /**
- * Interface ITemplate
- *
- * @var ITemplate $class
- */
- $class = $this->resources[$resourceName]['class'];
-
- return $class::templateFactory($this, $resourceId, $cacheTime, $cacheId, $compileId, $parentTemplate);
- }
-
- throw new Exception('Unknown resource type : ' . $resourceName);
- }
-
- /**
- * Checks if the input is an array or arrayaccess object, optionally it can also check if it's
- * empty.
- *
- * @param mixed $value the variable to check
- * @param bool $checkIsEmpty if true, the function will also check if the array|arrayaccess is empty,
- * and return true only if it's not empty
- *
- * @return int|bool true if it's an array|arrayaccess (or the item count if $checkIsEmpty is true) or false if it's
- * not an array|arrayaccess (or 0 if $checkIsEmpty is true)
- */
- public function isArray($value, $checkIsEmpty = false)
- {
- if (is_array($value) === true || $value instanceof ArrayAccess) {
- if ($checkIsEmpty === false) {
- return true;
- }
-
- return $this->count($value);
- }
-
- return false;
- }
-
- /**
- * Checks if the input is an array or a traversable object, optionally it can also check if it's
- * empty.
- *
- * @param mixed $value the variable to check
- * @param bool $checkIsEmpty if true, the function will also check if the array|traversable is empty,
- * and return true only if it's not empty
- *
- * @return int|bool true if it's an array|traversable (or the item count if $checkIsEmpty is true) or false if it's
- * not an array|traversable (or 0 if $checkIsEmpty is true)
- */
- public function isTraversable($value, $checkIsEmpty = false)
- {
- if (is_array($value) === true) {
- if ($checkIsEmpty === false) {
- return true;
- } else {
- return count($value) > 0;
- }
- } elseif ($value instanceof Traversable) {
- if ($checkIsEmpty === false) {
- return true;
- } else {
- return $this->count($value);
- }
- }
-
- return false;
- }
-
- /**
- * Counts an array or arrayaccess/traversable object.
- *
- * @param mixed $value the value to count
- *
- * @return int|bool the count for arrays and objects that implement countable, true for other objects that don't,
- * and 0 for empty elements
- */
- public function count($value)
- {
- if (is_array($value) === true || $value instanceof Countable) {
- return count($value);
- } elseif ($value instanceof ArrayAccess) {
- if ($value->offsetExists(0)) {
- return true;
- }
- } elseif ($value instanceof Iterator) {
- $value->rewind();
- if ($value->valid()) {
- return true;
- }
- } elseif ($value instanceof Traversable) {
- foreach ($value as $dummy) {
- return true;
- }
- }
-
- return 0;
- }
-
- /**
- * Triggers a dwoo error.
- *
- * @param string $message the error message
- * @param int $level the error level, one of the PHP's E_* constants
- *
- * @return void
- */
- public function triggerError($message, $level = E_USER_NOTICE)
- {
- if (!($tplIdentifier = $this->template->getResourceIdentifier())) {
- $tplIdentifier = $this->template->getResourceName();
- }
- trigger_error('Dwoo error (in ' . $tplIdentifier . ') : ' . $message, $level);
- }
-
- /**
- * Adds a block to the block stack.
- *
- * @param string $blockName the block name (without `Plugin` prefix)
- * @param array $args the arguments to be passed to the block's init() function
- *
- * @return BlockPlugin the newly created block
- */
- public function addStack($blockName, array $args = array())
- {
- if (isset($this->plugins[$blockName])) {
- $class = $this->plugins[$blockName]['class'];
- } else {
- $class = self::NAMESPACE_PLUGINS_BLOCKS . 'Plugin' . self::toCamelCase($blockName);
- }
-
- if ($this->curBlock !== null) {
- $this->curBlock->buffer(ob_get_contents());
- ob_clean();
- } else {
- $this->buffer .= ob_get_contents();
- ob_clean();
- }
-
- $block = new $class($this);
-
- call_user_func_array(array($block, 'init'), $args);
-
- $this->stack[] = $this->curBlock = $block;
-
- return $block;
- }
-
- /**
- * Removes the plugin at the top of the block stack.
- * Calls the block buffer() function, followed by a call to end() and finally a call to process()
- *
- * @return void
- */
- public function delStack()
- {
- $args = func_get_args();
-
- $this->curBlock->buffer(ob_get_contents());
- ob_clean();
-
- call_user_func_array(array($this->curBlock, 'end'), $args);
-
- $tmp = array_pop($this->stack);
-
- if (count($this->stack) > 0) {
- $this->curBlock = end($this->stack);
- $this->curBlock->buffer($tmp->process());
- } else {
- if ($this->buffer !== '') {
- echo $this->buffer;
- $this->buffer = '';
- }
- $this->curBlock = null;
- echo $tmp->process();
- }
-
- unset($tmp);
- }
-
- /**
- * Returns the parent block of the given block.
- *
- * @param BlockPlugin $block the block class plugin
- *
- * @return BlockPlugin|false if the given block isn't in the stack
- */
- public function getParentBlock(BlockPlugin $block)
- {
- $index = array_search($block, $this->stack, true);
- if ($index !== false && $index > 0) {
- return $this->stack[$index - 1];
- }
-
- return false;
- }
-
- /**
- * Finds the closest block of the given type, starting at the top of the stack.
- *
- * @param string $type the type of plugin you want to find
- *
- * @return BlockPlugin|false if no plugin of such type is in the stack
- */
- public function findBlock($type)
- {
- if (isset($this->plugins[$type])) {
- $type = $this->plugins[$type]['class'];
- } else {
- $type = self::NAMESPACE_PLUGINS_BLOCKS . 'Plugin_' . str_replace(self::NAMESPACE_PLUGINS_BLOCKS.'Plugin',
- '', $type);
- }
-
- $keys = array_keys($this->stack);
- while (($key = array_pop($keys)) !== false) {
- if ($this->stack[$key] instanceof $type) {
- return $this->stack[$key];
- }
- }
-
- return false;
- }
-
- /**
- * Returns a Plugin of the given class.
- * this is so a single instance of every class plugin is created at each template run,
- * allowing class plugins to have "per-template-run" static variables
- *
- * @param string $class the class name
- *
- * @return mixed an object of the given class
- */
- public function getObjectPlugin($class)
- {
- if (isset($this->runtimePlugins[$class])) {
- return $this->runtimePlugins[$class];
- }
-
- return $this->runtimePlugins[$class] = new $class($this);
- }
-
- /**
- * Calls the process() method of the given class-plugin name.
- *
- * @param string $plugName the class plugin name (without `Plugin` prefix)
- * @param array $params an array of parameters to send to the process() method
- *
- * @return string the process() return value
- */
- public function classCall($plugName, array $params = array())
- {
- $class = self::toCamelCase($plugName);
- $plugin = $this->getObjectPlugin($class);
-
- return call_user_func_array(array($plugin, 'process'), $params);
- }
-
- /**
- * Calls a php function.
- *
- * @param string $callback the function to call
- * @param array $params an array of parameters to send to the function
- *
- * @return mixed the return value of the called function
- */
- public function arrayMap($callback, array $params)
- {
- if ($params[0] === $this) {
- $addThis = true;
- array_shift($params);
- }
- if ((is_array($params[0]) || ($params[0] instanceof Iterator && $params[0] instanceof ArrayAccess))) {
- if (empty($params[0])) {
- return $params[0];
- }
-
- // array map
- $out = array();
- $cnt = count($params);
-
- if (isset($addThis)) {
- array_unshift($params, $this);
- $items = $params[1];
- $keys = array_keys($items);
-
- if (is_string($callback) === false) {
- while (($i = array_shift($keys)) !== null) {
- $out[] = call_user_func_array($callback, array(1 => $items[$i]) + $params);
- }
- } elseif ($cnt === 1) {
- while (($i = array_shift($keys)) !== null) {
- $out[] = $callback($this, $items[$i]);
- }
- } elseif ($cnt === 2) {
- while (($i = array_shift($keys)) !== null) {
- $out[] = $callback($this, $items[$i], $params[2]);
- }
- } elseif ($cnt === 3) {
- while (($i = array_shift($keys)) !== null) {
- $out[] = $callback($this, $items[$i], $params[2], $params[3]);
- }
- } else {
- while (($i = array_shift($keys)) !== null) {
- $out[] = call_user_func_array($callback, array(1 => $items[$i]) + $params);
- }
- }
- } else {
- $items = $params[0];
- $keys = array_keys($items);
-
- if (is_string($callback) === false) {
- while (($i = array_shift($keys)) !== null) {
- $out[] = call_user_func_array($callback, array($items[$i]) + $params);
- }
- } elseif ($cnt === 1) {
- while (($i = array_shift($keys)) !== null) {
- $out[] = $callback($items[$i]);
- }
- } elseif ($cnt === 2) {
- while (($i = array_shift($keys)) !== null) {
- $out[] = $callback($items[$i], $params[1]);
- }
- } elseif ($cnt === 3) {
- while (($i = array_shift($keys)) !== null) {
- $out[] = $callback($items[$i], $params[1], $params[2]);
- }
- } elseif ($cnt === 4) {
- while (($i = array_shift($keys)) !== null) {
- $out[] = $callback($items[$i], $params[1], $params[2], $params[3]);
- }
- } else {
- while (($i = array_shift($keys)) !== null) {
- $out[] = call_user_func_array($callback, array($items[$i]) + $params);
- }
- }
- }
-
- return $out;
- } else {
- return $params[0];
- }
- }
-
- /**
- * Reads a variable into the given data array.
- *
- * @param string $varstr the variable string, using dwoo variable syntax (i.e. "var.subvar[subsubvar]->property")
- * @param mixed $data the data array or object to read from
- * @param bool $safeRead if true, the function will check whether the index exists to prevent any notices from
- * being output
- *
- * @return mixed
- */
- public function readVarInto($varstr, $data, $safeRead = false)
- {
- if ($data === null) {
- return null;
- }
-
- if (is_array($varstr) === false) {
- preg_match_all('#(\[|->|\.)?((?:[^.[\]-]|-(?!>))+)\]?#i', $varstr, $m);
- } else {
- $m = $varstr;
- }
- unset($varstr);
-
- foreach ($m[1] as $k => $sep) {
- if ($sep === '.' || $sep === '[' || $sep === '') {
- // strip enclosing quotes if present
- $m[2][$k] = preg_replace('#^(["\']?)(.*?)\1$#', '$2', $m[2][$k]);
-
- if ((is_array($data) || $data instanceof ArrayAccess) && ($safeRead === false || isset($data[$m[2][$k]]))) {
- $data = $data[$m[2][$k]];
- } else {
- return null;
- }
- } else {
- if (is_object($data) && ($safeRead === false || isset($data->{$m[2][$k]}))) {
- $data = $data->{$m[2][$k]};
- } else {
- return null;
- }
- }
- }
-
- return $data;
- }
-
- /**
- * Reads a variable into the parent scope.
- *
- * @param int $parentLevels the amount of parent levels to go from the current scope
- * @param string $varstr the variable string, using dwoo variable syntax (i.e.
- * "var.subvar[subsubvar]->property")
- *
- * @return mixed
- */
- public function readParentVar($parentLevels, $varstr = null)
- {
- $tree = $this->scopeTree;
- $cur = $this->data;
-
- while ($parentLevels -- !== 0) {
- array_pop($tree);
- }
-
- while (($i = array_shift($tree)) !== null) {
- if (is_object($cur)) {
- $cur = $cur->{$i};
- } else {
- $cur = $cur[$i];
- }
- }
-
- if ($varstr !== null) {
- return $this->readVarInto($varstr, $cur);
- } else {
- return $cur;
- }
- }
-
- /**
- * Reads a variable into the current scope.
- *
- * @param string $varstr the variable string, using dwoo variable syntax (i.e. "var.subvar[subsubvar]->property")
- *
- * @return mixed
- */
- public function readVar($varstr)
- {
- if (is_array($varstr) === true) {
- $m = $varstr;
- unset($varstr);
- } else {
- if (strstr($varstr, '.') === false && strstr($varstr, '[') === false && strstr($varstr, '->') === false) {
- if ($varstr === 'dwoo') {
- return $this->getGlobals();
- } elseif ($varstr === '__' || $varstr === '_root') {
- return $this->data;
- } elseif ($varstr === '_' || $varstr === '_parent') {
- $varstr = '.' . $varstr;
- $tree = $this->scopeTree;
- $cur = $this->data;
- array_pop($tree);
-
- while (($i = array_shift($tree)) !== null) {
- if (is_object($cur)) {
- $cur = $cur->{$i};
- } else {
- $cur = $cur[$i];
- }
- }
-
- return $cur;
- }
-
- $cur = $this->scope;
-
- if (isset($cur[$varstr])) {
- return $cur[$varstr];
- } else {
- return null;
- }
- }
-
- if (substr($varstr, 0, 1) === '.') {
- $varstr = 'dwoo' . $varstr;
- }
-
- preg_match_all('#(\[|->|\.)?((?:[^.[\]-]|-(?!>))+)\]?#i', $varstr, $m);
- }
-
- $i = $m[2][0];
- if ($i === 'dwoo') {
- $cur = $this->getGlobals();
- array_shift($m[2]);
- array_shift($m[1]);
- switch ($m[2][0]) {
- case 'get':
- $cur = $_GET;
- break;
- case 'post':
- $cur = $_POST;
- break;
- case 'session':
- $cur = $_SESSION;
- break;
- case 'cookies':
- case 'cookie':
- $cur = $_COOKIE;
- break;
- case 'server':
- $cur = $_SERVER;
- break;
- case 'env':
- $cur = $_ENV;
- break;
- case 'request':
- $cur = $_REQUEST;
- break;
- case 'const':
- array_shift($m[2]);
- if (defined($m[2][0])) {
- return constant($m[2][0]);
- } else {
- return null;
- }
- }
- if ($cur !== $this->getGlobals()) {
- array_shift($m[2]);
- array_shift($m[1]);
- }
- } elseif ($i === '__' || $i === '_root') {
- $cur = $this->data;
- array_shift($m[2]);
- array_shift($m[1]);
- } elseif ($i === '_' || $i === '_parent') {
- $tree = $this->scopeTree;
- $cur = $this->data;
-
- while (true) {
- array_pop($tree);
- array_shift($m[2]);
- array_shift($m[1]);
- if (current($m[2]) === '_' || current($m[2]) === '_parent') {
- continue;
- }
-
- while (($i = array_shift($tree)) !== null) {
- if (is_object($cur)) {
- $cur = $cur->{$i};
- } else {
- $cur = $cur[$i];
- }
- }
- break;
- }
- } else {
- $cur = $this->scope;
- }
-
- foreach ($m[1] as $k => $sep) {
- if ($sep === '.' || $sep === '[' || $sep === '') {
- if ((is_array($cur) || $cur instanceof ArrayAccess) && isset($cur[$m[2][$k]])) {
- $cur = $cur[$m[2][$k]];
- } else {
- return null;
- }
- } elseif ($sep === '->') {
- if (is_object($cur)) {
- $cur = $cur->{$m[2][$k]};
- } else {
- return null;
- }
- } else {
- return null;
- }
- }
-
- return $cur;
- }
-
- /**
- * Assign the value to the given variable.
- *
- * @param mixed $value the value to assign
- * @param string $scope the variable string, using dwoo variable syntax (i.e. "var.subvar[subsubvar]->property")
- *
- * @return bool true if assigned correctly or false if a problem occured while parsing the var string
- */
- public function assignInScope($value, $scope)
- {
- if (!is_string($scope)) {
- $this->triggerError('Assignments must be done into strings, (' . gettype($scope) . ') ' . var_export($scope, true) . ' given', E_USER_ERROR);
- }
- if (strstr($scope, '.') === false && strstr($scope, '->') === false) {
- $this->scope[$scope] = $value;
- } else {
- // TODO handle _root/_parent scopes ?
- preg_match_all('#(\[|->|\.)?([^.[\]-]+)\]?#i', $scope, $m);
-
- $cur = &$this->scope;
- $last = array(
- array_pop($m[1]),
- array_pop($m[2])
- );
-
- foreach ($m[1] as $k => $sep) {
- if ($sep === '.' || $sep === '[' || $sep === '') {
- if (is_array($cur) === false) {
- $cur = array();
- }
- $cur = &$cur[$m[2][$k]];
- } elseif ($sep === '->') {
- if (is_object($cur) === false) {
- $cur = new stdClass();
- }
- $cur = &$cur->{$m[2][$k]};
- } else {
- return false;
- }
- }
-
- if ($last[0] === '.' || $last[0] === '[' || $last[0] === '') {
- if (is_array($cur) === false) {
- $cur = array();
- }
- $cur[$last[1]] = $value;
- } elseif ($last[0] === '->') {
- if (is_object($cur) === false) {
- $cur = new stdClass();
- }
- $cur->{$last[1]} = $value;
- } else {
- return false;
- }
- }
- }
-
- /**
- * Sets the scope to the given scope string or array.
- *
- * @param mixed $scope a string i.e. "level1.level2" or an array i.e. array("level1", "level2")
- * @param bool $absolute if true, the scope is set from the top level scope and not from the current scope
- *
- * @return array the current scope tree
- */
- public function setScope($scope, $absolute = false)
- {
- $old = $this->scopeTree;
-
- if (is_string($scope) === true) {
- $scope = explode('.', $scope);
- }
-
- if ($absolute === true) {
- $this->scope = &$this->data;
- $this->scopeTree = array();
- }
-
- while (($bit = array_shift($scope)) !== null) {
- if ($bit === '_' || $bit === '_parent') {
- array_pop($this->scopeTree);
- $this->scope = &$this->data;
- $cnt = count($this->scopeTree);
- for ($i = 0; $i < $cnt; ++ $i) {
- $this->scope = &$this->scope[$this->scopeTree[$i]];
- }
- } elseif ($bit === '__' || $bit === '_root') {
- $this->scope = &$this->data;
- $this->scopeTree = array();
- } elseif (isset($this->scope[$bit])) {
- if ($this->scope instanceof ArrayAccess) {
- $tmp = $this->scope[$bit];
- $this->scope = &$tmp;
- } else {
- $this->scope = &$this->scope[$bit];
- }
- $this->scopeTree[] = $bit;
- } else {
- unset($this->scope);
- $this->scope = null;
- }
- }
-
- return $old;
- }
-
- /**
- * Returns the entire data array.
- *
- * @return array
- */
- public function getData()
- {
- return $this->data;
- }
-
- /**
- * Sets a return value for the currently running template.
- *
- * @param string $name var name
- * @param mixed $value var value
- *
- * @return void
- */
- public function setReturnValue($name, $value)
- {
- $this->returnData[$name] = $value;
- }
-
- /**
- * Retrieves the return values set by the template.
- *
- * @return array
- */
- public function getReturnValues()
- {
- return $this->returnData;
- }
-
- /**
- * Returns a reference to the current scope.
- *
- * @return mixed
- */
- public function &getScope()
- {
- return $this->scope;
- }
-
- /**
- * Redirects all calls to unexisting to plugin proxy.
- *
- * @param string $method the method name
- * @param array $args array of arguments
- *
- * @return mixed
- * @throws Exception
- */
- public function __call($method, $args)
- {
- $proxy = $this->getPluginProxy();
- if (!$proxy) {
- throw new Exception('Call to undefined method ' . __CLASS__ . '::' . $method . '()');
- }
-
- return call_user_func_array($proxy->getCallback($method), $args);
- }
-
- /**
- * Convert plugin name from `auto_escape` to `AutoEscape`.
- * @param string $input
- * @param string $separator
- *
- * @return mixed
- */
- public static function toCamelCase($input, $separator = '_')
- {
- return join(array_map('ucfirst', explode($separator, $input)));
-
- // TODO >= PHP5.4.32
- //return str_replace($separator, '', ucwords($input, $separator));
- }
-}
diff --git a/core/l/Dwoo/Data.php b/core/l/Dwoo/Data.php
deleted file mode 100644
index 85226e7..0000000
--- a/core/l/Dwoo/Data.php
+++ /dev/null
@@ -1,264 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2017 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.4
- * @date 2017-03-01
- * @link http://dwoo.org/
- */
-
-namespace Dwoo;
-
-/**
- * Dwoo data object, use it for complex data assignments or if you want to easily pass it
- * around multiple functions to avoid passing an array by reference.
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class Data implements IDataProvider
-{
- /**
- * Data array.
- *
- * @var array
- */
- protected $data = array();
-
- /**
- * Returns the data array.
- *
- * @return array
- */
- public function getData()
- {
- return $this->data;
- }
-
- /**
- * Clears a the entire data or only the given key.
- *
- * @param array|string $name clears only one value if you give a name, multiple values if
- * you give an array of names, or the entire data if left null
- */
- public function clear($name = null)
- {
- if ($name === null) {
- $this->data = array();
- } elseif (is_array($name)) {
- foreach ($name as $index) {
- unset($this->data[$index]);
- }
- } else {
- unset($this->data[$name]);
- }
- }
-
- /**
- * Overwrites the entire data with the given array.
- *
- * @param array $data the new data array to use
- */
- public function setData(array $data)
- {
- $this->data = $data;
- }
-
- /**
- * merges the given array(s) with the current data with array_merge.
- *
- * @param array $data the array to merge
- */
- public function mergeData(array $data)
- {
- $args = func_get_args();
- foreach ($args as $key => $v) {
- if (is_array($v)) {
- $this->data = array_merge($this->data, $v);
- }
- }
- }
-
- /**
- * Assigns a value or an array of values to the data object.
- *
- * @param array|string $name an associative array of multiple (index=>value) or a string
- * that is the index to use, i.e. a value assigned to "foo" will be
- * accessible in the template through {$foo}
- * @param mixed $val the value to assign, or null if $name was an array
- */
- public function assign($name, $val = null)
- {
- if (is_array($name)) {
- reset($name);
- foreach ($name as $k => $v){
- $this->data[$k] = $v;
- }
- } else {
- $this->data[$name] = $val;
- }
- }
-
- /**
- * Allows to assign variables using the object syntax.
- *
- * @param string $name the variable name
- * @param string $value the value to assign to it
- */
- public function __set($name, $value)
- {
- $this->assign($name, $value);
- }
-
- /**
- * Assigns a value by reference to the data object.
- *
- * @param string $name the index to use, i.e. a value assigned to "foo" will be
- * accessible in the template through {$foo}
- * @param mixed $val the value to assign by reference
- */
- public function assignByRef($name, &$val)
- {
- $this->data[$name] = &$val;
- }
-
- /**
- * Appends values or an array of values to the data object.
- *
- * @param array|string $name an associative array of multiple (index=>value) or a string
- * that is the index to use, i.e. a value assigned to "foo" will be
- * accessible in the template through {$foo}
- * @param mixed $val the value to assign, or null if $name was an array
- * @param bool $merge true to merge data or false to append, defaults to false
- */
- public function append($name, $val = null, $merge = false)
- {
- if (is_array($name)) {
- foreach ($name as $key => $val) {
- if (isset($this->data[$key]) && !is_array($this->data[$key])) {
- settype($this->data[$key], 'array');
- }
-
- if ($merge === true && is_array($val)) {
- $this->data[$key] = $val + $this->data[$key];
- } else {
- $this->data[$key][] = $val;
- }
- }
- } elseif ($val !== null) {
- if (isset($this->data[$name]) && !is_array($this->data[$name])) {
- settype($this->data[$name], 'array');
- } elseif (!isset($this->data[$name])) {
- $this->data[$name] = array();
- }
-
- if ($merge === true && is_array($val)) {
- $this->data[$name] = $val + $this->data[$name];
- } else {
- $this->data[$name][] = $val;
- }
- }
- }
-
- /**
- * Appends a value by reference to the data object.
- *
- * @param string $name the index to use, i.e. a value assigned to "foo" will be
- * accessible in the template through {$foo}
- * @param mixed $val the value to append by reference
- * @param bool $merge true to merge data or false to append, defaults to false
- */
- public function appendByRef($name, &$val, $merge = false)
- {
- if (isset($this->data[$name]) && !is_array($this->data[$name])) {
- settype($this->data[$name], 'array');
- }
-
- if ($merge === true && is_array($val)) {
- foreach ($val as $key => &$value) {
- $this->data[$name][$key] = &$value;
- }
- } else {
- $this->data[$name][] = &$val;
- }
- }
-
- /**
- * Returns true if the variable has been assigned already, false otherwise.
- *
- * @param string $name the variable name
- *
- * @return bool
- */
- public function isAssigned($name)
- {
- return isset($this->data[$name]);
- }
-
- /**
- * Supports calls to isset($dwoo->var).
- *
- * @param string $name the variable name
- *
- * @return bool
- */
- public function __isset($name)
- {
- return isset($this->data[$name]);
- }
-
- /**
- * Unassigns/removes a variable.
- *
- * @param string $name the variable name
- */
- public function unassign($name)
- {
- unset($this->data[$name]);
- }
-
- /**
- * Supports unsetting variables using the object syntax.
- *
- * @param string $name the variable name
- */
- public function __unset($name)
- {
- unset($this->data[$name]);
- }
-
- /**
- * Returns a variable if it was assigned.
- *
- * @param string $name the variable name
- *
- * @return mixed
- */
- public function get($name)
- {
- return $this->__get($name);
- }
-
- /**
- * Allows to read variables using the object syntax.
- *
- * @param string $name the variable name
- *
- * @return mixed
- * @throws Exception
- */
- public function __get($name)
- {
- if (isset($this->data[$name])) {
- return $this->data[$name];
- } else {
- throw new Exception('Tried to read a value that was not assigned yet : "' . $name . '"');
- }
- }
-}
diff --git a/core/l/Dwoo/Exception.php b/core/l/Dwoo/Exception.php
deleted file mode 100644
index f61795f..0000000
--- a/core/l/Dwoo/Exception.php
+++ /dev/null
@@ -1,26 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2016 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.0
- * @date 2016-09-19
- * @link http://dwoo.org/
- */
-
-namespace Dwoo;
-
-/**
- * Main dwoo exception class.
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class Exception extends \Exception
-{
-}
diff --git a/core/l/Dwoo/Filter.php b/core/l/Dwoo/Filter.php
deleted file mode 100644
index 5fdb4ed..0000000
--- a/core/l/Dwoo/Filter.php
+++ /dev/null
@@ -1,52 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2016 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.0
- * @date 2016-09-19
- * @link http://dwoo.org/
- */
-
-namespace Dwoo;
-
-/**
- * Base class for filters.
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-abstract class Filter
-{
- /**
- * The dwoo instance that runs this filter.
- *
- * @var Core
- */
- protected $dwoo;
-
- /**
- * Constructor, if you override it, call parent::__construct($dwoo); or assign
- * the dwoo instance yourself if you need it.
- *
- * @param Core $dwoo the dwoo instance that runs this plugin
- */
- public function __construct(Core $dwoo)
- {
- $this->dwoo = $dwoo;
- }
-
- /**
- * Processes the input and returns it filtered.
- *
- * @param string $input the template to process
- *
- * @return string
- */
- abstract public function process($input);
-}
diff --git a/core/l/Dwoo/ICompilable.php b/core/l/Dwoo/ICompilable.php
deleted file mode 100644
index 40e1155..0000000
--- a/core/l/Dwoo/ICompilable.php
+++ /dev/null
@@ -1,31 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2016 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.0
- * @date 2016-09-23
- * @link http://dwoo.org/
- */
-
-namespace Dwoo;
-
-/**
- * Interface that represents a compilable plugin.
- * implement this to notify the compiler that this plugin does not need to be loaded at runtime.
- * to implement it right, you must implement public static function compile(Compiler $compiler, $arg, $arg,
- * ...), which replaces the process() method (that means compile() should have all arguments it
- * requires). This software is provided 'as-is', without any express or implied warranty. In no event will the authors
- * be held liable for any damages arising from the use of this software.
- */
-interface ICompilable
-{
- // this replaces the process function
- //public static function compile(Compiler $compiler, $arg, $arg, ...);
-}
diff --git a/core/l/Dwoo/ICompilable/Block.php b/core/l/Dwoo/ICompilable/Block.php
deleted file mode 100644
index 241db4e..0000000
--- a/core/l/Dwoo/ICompilable/Block.php
+++ /dev/null
@@ -1,27 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2016 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.0
- * @date 2016-09-19
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\ICompilable;
-
-/**
- * Interface that represents a compilable block plugin.
- * implement this to notify the compiler that this plugin does not need to be loaded at runtime.
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-interface Block
-{
-}
diff --git a/core/l/Dwoo/ICompiler.php b/core/l/Dwoo/ICompiler.php
deleted file mode 100644
index 619aaab..0000000
--- a/core/l/Dwoo/ICompiler.php
+++ /dev/null
@@ -1,59 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2017 David Sanchez
- * @license http://dwoo.org/LICENSE LGPLv3
- * @version 1.3.6
- * @date 2017-03-21
- * @link http://dwoo.org/
- */
-
-namespace Dwoo;
-
-use Dwoo\Security\Policy as SecurityPolicy;
-
-/**
- * Interface that represents a dwoo compiler.
- * while implementing this is enough to interact with Dwoo/Templates, it is not
- * sufficient to interact with Dwoo/Plugins, however the main purpose of creating a
- * new compiler would be to interact with other/different plugins, that is why this
- * interface has been left with the minimum requirements.
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-interface ICompiler
-{
- /**
- * Compiles the provided string down to php code.
- *
- * @param Core $core
- * @param ITemplate $template the template to compile
- *
- * @return string a compiled php code string
- */
- public function compile(Core $core, ITemplate $template);
-
- /**
- * Adds the custom plugins loaded into Dwoo to the compiler so it can load them.
- *
- * @see Core::addPlugin
- *
- * @param array $customPlugins an array of custom plugins
- */
- public function setCustomPlugins(array $customPlugins);
-
- /**
- * Sets the security policy object to enforce some php security settings.
- * use this if untrusted persons can modify templates,
- * set it on the Dwoo object as it will be passed onto the compiler automatically
- *
- * @param SecurityPolicy $policy the security policy object
- */
- public function setSecurityPolicy(SecurityPolicy $policy = null);
-}
diff --git a/core/l/Dwoo/IDataProvider.php b/core/l/Dwoo/IDataProvider.php
deleted file mode 100644
index 9392b2d..0000000
--- a/core/l/Dwoo/IDataProvider.php
+++ /dev/null
@@ -1,32 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2016 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.0
- * @date 2016-09-23
- * @link http://dwoo.org/
- */
-
-namespace Dwoo;
-
-/**
- * Interface that represents a dwoo data object.
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-interface IDataProvider
-{
- /**
- * Returns the data as an associative array that will be used in the template.
- *
- * @return array
- */
- public function getData();
-}
diff --git a/core/l/Dwoo/IElseable.php b/core/l/Dwoo/IElseable.php
deleted file mode 100644
index b8f3483..0000000
--- a/core/l/Dwoo/IElseable.php
+++ /dev/null
@@ -1,30 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2016 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.0
- * @date 2016-09-19
- * @link http://dwoo.org/
- */
-
-namespace Dwoo;
-
-/**
- * Interface that represents a block plugin that supports the else functionality.
- * the else block will enter an "hasElse" parameter inside the parameters array
- * of the closest parent implementing this interface, the hasElse parameter contains
- * the else output that should be appended to the block's content (see foreach or other
- * block for examples)
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-interface IElseable
-{
-}
diff --git a/core/l/Dwoo/ILoader.php b/core/l/Dwoo/ILoader.php
deleted file mode 100644
index febf202..0000000
--- a/core/l/Dwoo/ILoader.php
+++ /dev/null
@@ -1,37 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2016 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.0
- * @date 2016-09-23
- * @link http://dwoo.org/
- */
-
-namespace Dwoo;
-
-/**
- * Interface for dwoo plugin loaders.
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-interface ILoader
-{
- /**
- * Loads a plugin file.
- * the second parameter is used to avoid permanent rehashing when using php functions,
- * however this means that if you have add a plugin that overrides a php function you have
- * to delete the classpath.cache file(s) by hand to force a rehash of the plugins
- *
- * @param string $class the plugin name, without the `Plugin` prefix
- * @param bool $forceRehash if true, the class path caches will be rebuilt if the plugin is not found, in case it
- * has just been added, defaults to true
- */
- public function loadPlugin($class, $forceRehash = true);
-}
diff --git a/core/l/Dwoo/IPluginProxy.php b/core/l/Dwoo/IPluginProxy.php
deleted file mode 100644
index d20f3f7..0000000
--- a/core/l/Dwoo/IPluginProxy.php
+++ /dev/null
@@ -1,74 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2016 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.0
- * @date 2016-09-23
- * @link http://dwoo.org/
- */
-
-namespace Dwoo;
-
-/**
- * Interface that represents a dwoo plugin proxy.
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-interface IPluginProxy
-{
- /**
- * Returns true or false to say whether the given plugin is handled by this proxy or not.
- *
- * @param string $name the plugin name
- *
- * @return bool true if the plugin is known and usable, otherwise false
- */
- public function handles($name);
-
- /**
- * Returns the code (as a string) to call the plugin
- * (this will be executed at runtime inside the Dwoo class).
- *
- * @param string $name the plugin name
- * @param array $params a parameter array, array key "*" is the rest array
- *
- * @return string
- */
- public function getCode($name, $params);
-
- /**
- * Returns a callback to the plugin, this is used with the reflection API to
- * find out about the plugin's parameter names etc.
- * should you need a rest array without the possibility to edit the
- * plugin's code, you can provide a callback to some
- * other function with the correct parameter signature, i.e. :
- *
- * return array($this, "callbackHelper");
- * // and callbackHelper would be as such:
- * public function callbackHelper(array $rest=array()){}
- *
- *
- * @param string $name the plugin name
- *
- * @return callback
- */
- public function getCallback($name);
-
- /**
- * Returns some code that will check if the plugin is loaded and if not load it
- * this is optional, if your plugins are autoloaded or whatever, just return an
- * empty string.
- *
- * @param string $name the plugin name
- *
- * @return string
- */
- public function getLoader($name);
-}
diff --git a/core/l/Dwoo/ITemplate.php b/core/l/Dwoo/ITemplate.php
deleted file mode 100644
index 6fa65f3..0000000
--- a/core/l/Dwoo/ITemplate.php
+++ /dev/null
@@ -1,161 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2017 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.4
- * @date 2017-03-07
- * @link http://dwoo.org/
- */
-
-namespace Dwoo;
-
-/**
- * Interface that represents a dwoo template.
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-interface ITemplate
-{
- /**
- * Returns the cache duration for this template.
- * defaults to null if it was not provided
- *
- * @return int|null
- */
- public function getCacheTime();
-
- /**
- * Sets the cache duration for this template.
- * can be used to set it after the object is created if you did not provide
- * it in the constructor
- *
- * @param int $seconds duration of the cache validity for this template, if
- * null it defaults to the Dwoo instance's cache time. 0 = disable and
- * -1 = infinite cache
- */
- public function setCacheTime($seconds = null);
-
- /**
- * Returns the cached template output file name, true if it's cache-able but not cached
- * or false if it's not cached.
- *
- * @param Core $core the dwoo instance that requests it
- *
- * @return string|bool
- */
- public function getCachedTemplate(Core $core);
-
- /**
- * Caches the provided output into the cache file.
- *
- * @param Core $core the dwoo instance that requests it
- * @param string $output the template output
- *
- * @return mixed full path of the cached file or false upon failure
- */
- public function cache(Core $core, $output);
-
- /**
- * Clears the cached template if it's older than the given time.
- *
- * @param Core $core the dwoo instance that was used to cache that template
- * @param int $olderThan minimum time (in seconds) required for the cache to be cleared
- *
- * @return bool true if the cache was not present or if it was deleted, false if it remains there
- */
- public function clearCache(Core $core, $olderThan = - 1);
-
- /**
- * Returns the compiled template file name.
- *
- * @param Core $core the dwoo instance that requests it
- * @param ICompiler $compiler the compiler that must be used
- *
- * @return string
- */
- public function getCompiledTemplate(Core $core, ICompiler $compiler = null);
-
- /**
- * Returns the template name.
- *
- * @return string
- */
- public function getName();
-
- /**
- * Returns the resource name for this template class.
- *
- * @return string
- */
- public function getResourceName();
-
- /**
- * Returns the resource identifier for this template or false if it has no identifier.
- *
- * @return string|false
- */
- public function getResourceIdentifier();
-
- /**
- * Returns the template source of this template.
- *
- * @return string
- */
- public function getSource();
-
- /**
- * Returns an unique string identifying the current version of this template,
- * for example a timestamp of the last modified date or a hash of the template source.
- *
- * @return string
- */
- public function getUid();
-
- /**
- * Returns the compiler used by this template, if it was just compiled, or null.
- *
- * @return ICompiler
- */
- public function getCompiler();
-
- /**
- * Returns some php code that will check if this template has been modified or not.
- * if the function returns null, the template will be instanciated and then the Uid checked
- *
- * @return string
- */
- public function getIsModifiedCode();
-
- /**
- * Returns a new template object from the given resource identifier, null if no include is
- * possible (resource not found), or false if include is not permitted by this resource type.
- * this method should also check if $dwoo->getSecurityPolicy() is null or not and do the
- * necessary permission checks if required, if the security policy prevents the template
- * generation it should throw a new Security\Exception with a relevant message
- *
- * @param Core $core
- * @param mixed $resourceId the resource identifier
- * @param int $cacheTime duration of the cache validity for this template, if null it defaults to the
- * Dwoo instance that will render this template if null it defaults to the Dwoo
- * instance that will render this template
- * @param string $cacheId the unique cache identifier of this page or anything else that makes this
- * template's content unique, if null it defaults to the current url makes this
- * template's content unique, if null it defaults to the current url
- * @param string $compileId the unique compiled identifier, which is used to distinguish this template from
- * others, if null it defaults to the filename+bits of the path template from
- * others, if null it defaults to the filename+bits of the path
- * @param ITemplate $parentTemplate the template that is requesting a new template object (through an include,
- * extends or any other plugin) an include, extends or any other plugin)
- *
- * @return ITemplate|false|null
- */
- public static function templateFactory(Core $core, $resourceId, $cacheTime = null, $cacheId = null,
- $compileId = null, ITemplate $parentTemplate = null);
-}
diff --git a/core/l/Dwoo/Loader.php b/core/l/Dwoo/Loader.php
deleted file mode 100644
index db6f88a..0000000
--- a/core/l/Dwoo/Loader.php
+++ /dev/null
@@ -1,181 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2017 David Sanchez
- * @license http://dwoo.org/LICENSE LGPLv3
- * @version 1.4.0
- * @date 2017-03-16
- * @link http://dwoo.org/
- */
-
-namespace Dwoo;
-
-/**
- * Handles plugin loading and caching of plugins names/paths relationships.
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class Loader implements ILoader
-{
- /**
- * Stores the plugin directories.
- *
- * @see addDirectory
- * @var array
- */
- protected $paths = array();
-
- /**
- * Stores the plugins names/paths relationships
- * don't edit this on your own, use addDirectory.
- *
- * @see addDirectory
- * @var array
- */
- protected $classPath = array();
-
- /**
- * Path where class paths cache files are written.
- *
- * @var string
- */
- protected $cacheDir;
-
- /**
- * Path where builtin plugins are stored.
- *
- * @var string
- */
- protected $corePluginDir;
-
- /**
- * Loader constructor.
- *
- * @param $cacheDir
- */
- public function __construct($cacheDir)
- {
- $this->corePluginDir = __DIR__ . DIRECTORY_SEPARATOR;
- $this->cacheDir = rtrim($cacheDir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
-
- // include class paths or rebuild paths if the cache file isn't there
- $cacheFile = $this->cacheDir . 'classpath.cache.d' . Core::RELEASE_TAG . '.php';
- if (file_exists($cacheFile)) {
- $classpath = file_get_contents($cacheFile);
- $this->classPath = unserialize($classpath) + $this->classPath;
- } else {
- $this->rebuildClassPathCache($this->corePluginDir, $cacheFile);
- }
- }
-
- /**
- * Rebuilds class paths, scans the given directory recursively and saves all paths in the given file.
- *
- * @param string $path the plugin path to scan
- * @param string|boolean $cacheFile the file where to store the plugin paths cache, it will be overwritten
- *
- * @throws Exception
- */
- protected function rebuildClassPathCache($path, $cacheFile)
- {
- $tmp = array();
- if ($cacheFile !== false) {
- $tmp = $this->classPath;
- $this->classPath = array();
- }
-
- // iterates over all files/folders
- foreach (new \DirectoryIterator($path) as $fileInfo) {
- if (!$fileInfo->isDot()) {
- if ($fileInfo->isDir()) {
- $this->rebuildClassPathCache($fileInfo->getPathname(), false);
- } else {
- $this->classPath[$fileInfo->getBasename('.php')] = $fileInfo->getPathname();
- }
- }
- }
-
- // save in file if it's the first call (not recursed)
- if ($cacheFile !== false) {
- if (!file_put_contents($cacheFile, serialize($this->classPath))) {
- throw new Exception('Could not write into ' . $cacheFile . ', either because the folder is not there (create it) or because of the chmod configuration (please ensure this directory is writable by php), alternatively you can change the directory used with $dwoo->setCompileDir() or provide a custom loader object with $dwoo->setLoader()');
- }
- $this->classPath += $tmp;
- }
- }
-
- /**
- * Loads a plugin file.
- *
- * @param string $class the plugin name, without the `Plugin` prefix
- * @param bool $forceRehash if true, the class path caches will be rebuilt if the plugin is not found, in case it
- * has just been added, defaults to true
- *
- * @throws Exception
- */
- public function loadPlugin($class, $forceRehash = true)
- {
- /**
- * An unknown class was requested (maybe newly added) or the
- * include failed so we rebuild the cache. include() will fail
- * with an uncatchable error if the file doesn't exist, which
- * usually means that the cache is stale and must be rebuilt,
- * so we check for that before trying to include() the plugin.
- */
- if ((!isset($this->classPath[$class]) || !is_readable($this->classPath[$class])) || (!isset
- ($this->classPath[$class . 'Compile']) || !is_readable($this->classPath[$class . 'Compile']))) {
- if ($forceRehash) {
- $this->rebuildClassPathCache($this->corePluginDir, $this->cacheDir . 'classpath.cache.d' .
- Core::RELEASE_TAG . '.php');
- foreach ($this->paths as $path => $file) {
- $this->rebuildClassPathCache($path, $file);
- }
- if (isset($this->classPath[$class])) {
- include_once $this->classPath[$class];
- } elseif (isset($this->classPath[$class . 'Compile'])) {
- include_once $this->classPath[$class . 'Compile'];
- } else {
- throw new Exception('Plugin "' . $class . '" can not be found, maybe you forgot to bind it if it\'s a custom plugin ?', E_USER_NOTICE);
- }
- } else {
- throw new Exception('Plugin "' . $class . '" can not be found, maybe you forgot to bind it if it\'s a custom plugin ?', E_USER_NOTICE);
- }
- }
- }
-
- /**
- * Adds a plugin directory, the plugins found in the new plugin directory
- * will take precedence over the other directories (including the default
- * dwoo plugin directory), you can use this for example to override plugins
- * in a specific directory for a specific application while keeping all your
- * usual plugins in the same place for all applications.
- * TOCOM don't forget that php functions overrides are not rehashed so you
- * need to clear the classpath caches by hand when adding those.
- *
- * @param string $pluginDirectory the plugin path to scan
- *
- * @throws Exception
- */
- public function addDirectory($pluginDirectory)
- {
- $pluginDir = realpath($pluginDirectory);
- if (!$pluginDir) {
- throw new Exception('Plugin directory does not exist or can not be read : ' . $pluginDirectory);
- }
- $cacheFile = $this->cacheDir . 'classpath-' . substr(strtr($pluginDir, '/\\:' . PATH_SEPARATOR, '----'),
- strlen($pluginDir) > 80 ? - 80 : 0) . '.d' . Core::RELEASE_TAG . '.php';
- $this->paths[$pluginDir] = $cacheFile;
- if (file_exists($cacheFile)) {
- $classpath = file_get_contents($cacheFile);
- $this->classPath = unserialize($classpath) + $this->classPath;
- } else {
- $this->rebuildClassPathCache($pluginDir, $cacheFile);
- }
- }
-}
diff --git a/core/l/Dwoo/Plugin.php b/core/l/Dwoo/Plugin.php
deleted file mode 100644
index c607806..0000000
--- a/core/l/Dwoo/Plugin.php
+++ /dev/null
@@ -1,105 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2016 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.0
- * @date 2016-09-23
- * @link http://dwoo.org/
- */
-
-namespace Dwoo;
-
-/**
- * Base plugin class.
- * you have to implement the process() method, it will receive the parameters that
- * are in the template code
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-abstract class Plugin
-{
- /**
- * The dwoo instance that runs this plugin.
- *
- * @var Core
- */
- protected $core;
-
- /**
- * Constructor, if you override it, call parent::__construct($core); or assign
- * the dwoo instance yourself if you need it.
- *
- * @param Core $core the dwoo instance that runs this plugin
- */
- public function __construct(Core $core)
- {
- $this->core = $core;
- }
-
- // plugins should always implement :
- // public function process($arg, $arg, ...)
- // or for block plugins :
- // public function init($arg, $arg, ...)
-
- // this could be enforced with :
- // abstract public function process(...);
- // if my feature request gets enough interest one day
- // see => http://bugs.php.net/bug.php?id=44043
-
- /**
- * Utility function that converts an array of compiled parameters (or rest array) to a string of xml/html tag
- * attributes. this is to be used in preProcessing or postProcessing functions, example :
- * $p = $compiler->getCompiledParams($params);
- * // get only the rest array as attributes
- * $attributes = Plugin::paramsToAttributes($p['*']);
- * // get all the parameters as attributes (if there is a rest array, it will be included)
- * $attributes = Plugin::paramsToAttributes($p);
- *
- * @param array $params an array of attributeName=>value items that will be compiled to be ready for inclusion in a php string
- * inclusion in a php string
- * @param string $delim the string delimiter you want to use (defaults to ')
- * @param Compiler $compiler the compiler instance (optional for BC, but recommended to pass it for proper escaping behavior)
- * escaping behavior)
- *
- * @return string
- */
- public static function paramsToAttributes(array $params, $delim = '\'', Compiler $compiler = null)
- {
- if (isset($params['*'])) {
- $params = array_merge($params, $params['*']);
- unset($params['*']);
- }
-
- $out = '';
- foreach ($params as $attr => $val) {
- $out .= ' ' . $attr . '=';
- if (trim($val, '"\'') == '' || $val == 'null') {
- $out .= str_replace($delim, '\\' . $delim, '""');
- } elseif (substr($val, 0, 1) === $delim && substr($val, - 1) === $delim) {
- $out .= str_replace($delim, '\\' . $delim, '"' . substr($val, 1, - 1) . '"');
- } else {
- if (!$compiler) {
- // disable double encoding since it can not be determined if it was encoded
- $escapedVal = '.(is_string($tmp2=' . $val . ') ? htmlspecialchars($tmp2, ENT_QUOTES, $this->charset, false) : $tmp2).';
- } elseif (!$compiler->getAutoEscape() || false === strpos($val, 'isset($this->scope')) {
- // escape if auto escaping is disabled, or there was no variable in the string
- $escapedVal = '.(is_string($tmp2=' . $val . ') ? htmlspecialchars($tmp2, ENT_QUOTES, $this->charset) : $tmp2).';
- } else {
- // print as is
- $escapedVal = '.' . $val . '.';
- }
-
- $out .= str_replace($delim, '\\' . $delim, '"') . $delim . $escapedVal . $delim . str_replace($delim, '\\' . $delim, '"');
- }
- }
-
- return ltrim($out);
- }
-}
diff --git a/core/l/Dwoo/Plugins/Blocks/PluginA.php b/core/l/Dwoo/Plugins/Blocks/PluginA.php
deleted file mode 100644
index 6210d84..0000000
--- a/core/l/Dwoo/Plugins/Blocks/PluginA.php
+++ /dev/null
@@ -1,95 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2016 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.0
- * @date 2016-09-19
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Blocks;
-
-use Dwoo\Compiler;
-use Dwoo\Block\Plugin as BlockPlugin;
-use Dwoo\ICompilable\Block as ICompilableBlock;
-
-/**
- * Outputs a html <a> tag
- *
- * * href : the target URI where the link must point
- * * rest : any other attributes you want to add to the tag can be added as named parameters
- *
.
- * Example :
- *
- * {* Create a simple link out of an url variable and add a special class attribute: *}
- * {a $url class="external" /}
- * {* Mark a link as active depending on some other variable : *}
- * {a $link.url class=tif($link.active "active"); $link.title /}
- * {* This is similar to: {$link.title} *}
- *
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginA extends BlockPlugin implements ICompilableBlock
-{
- /**
- * @param $href
- * @param array $rest
- */
- public function init($href, array $rest = array())
- {
- }
-
- /**
- * @param Compiler $compiler
- * @param array $params
- * @param string $prepend
- * @param string $append
- * @param string $type
- *
- * @return string
- */
- public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type)
- {
- $p = $compiler->getCompiledParams($params);
-
- $out = Compiler::PHP_OPEN . 'echo \'\';' . Compiler::PHP_CLOSE;
- }
-
- /**
- * @param Compiler $compiler
- * @param array $params
- * @param string $prepend
- * @param string $append
- * @param string $content
- *
- * @return string
- */
- public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content)
- {
- $p = $compiler->getCompiledParams($params);
-
- // no content was provided so use the url as display text
- if ($content == '') {
- // merge into the href if href is a string
- if (substr($p['href'], - 1) === '"' || substr($p['href'], - 1) === '\'') {
- return Compiler::PHP_OPEN . 'echo ' . substr($p['href'], 0, - 1) . '' . substr($p['href'], - 1) . ';' . Compiler::PHP_CLOSE;
- }
-
- // otherwise append
- return Compiler::PHP_OPEN . 'echo ' . $p['href'] . '.\'\';' . Compiler::PHP_CLOSE;
- }
-
- // return content
- return $content . '';
- }
-}
diff --git a/core/l/Dwoo/Plugins/Blocks/PluginAutoEscape.php b/core/l/Dwoo/Plugins/Blocks/PluginAutoEscape.php
deleted file mode 100644
index 7b45ec9..0000000
--- a/core/l/Dwoo/Plugins/Blocks/PluginAutoEscape.php
+++ /dev/null
@@ -1,98 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2016 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.0
- * @date 2016-09-19
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Blocks;
-
-use Dwoo\Compiler;
-use Dwoo\Block\Plugin as BlockPlugin;
-use Dwoo\ICompilable\Block as ICompilableBlock;
-use Dwoo\Compilation\Exception as CompilationException;
-
-/**
- * Overrides the compiler auto-escape setting within the block
- *
- * * enabled : if set to "on", "enable", true or 1 then the compiler autoescaping is enabled inside this block. set to
- * "off", "disable", false or 0 to disable it
- *
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginAutoEscape extends BlockPlugin implements ICompilableBlock
-{
- protected static $stack = array();
-
- /**
- * @param $enabled
- */
- public function init($enabled)
- {
- }
-
- /**
- * @param Compiler $compiler
- * @param array $params
- * @param string $prepend
- * @param string $append
- * @param string $type
- *
- * @return string
- * @throws CompilationException
- */
- public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type)
- {
- $params = $compiler->getCompiledParams($params);
- switch (strtolower(trim((string)$params['enabled'], '"\''))) {
-
- case 'on':
- case 'true':
- case 'enabled':
- case 'enable':
- case '1':
- $enable = true;
- break;
- case 'off':
- case 'false':
- case 'disabled':
- case 'disable':
- case '0':
- $enable = false;
- break;
- default:
- throw new CompilationException($compiler, 'Auto_Escape : Invalid parameter (' . $params['enabled'] . '), valid parameters are "enable"/true or "disable"/false');
- }
-
- self::$stack[] = $compiler->getAutoEscape();
- $compiler->setAutoEscape($enable);
-
- return '';
- }
-
- /**
- * @param Compiler $compiler
- * @param array $params
- * @param string $prepend
- * @param string $append
- * @param string $content
- *
- * @return string
- */
- public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content)
- {
- $compiler->setAutoEscape(array_pop(self::$stack));
-
- return $content;
- }
-}
diff --git a/core/l/Dwoo/Plugins/Blocks/PluginBlock.php b/core/l/Dwoo/Plugins/Blocks/PluginBlock.php
deleted file mode 100644
index 7e66182..0000000
--- a/core/l/Dwoo/Plugins/Blocks/PluginBlock.php
+++ /dev/null
@@ -1,66 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2016 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.0
- * @date 2016-09-19
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Blocks;
-
-use Dwoo\Compiler;
-use Dwoo\Block\Plugin as BlockPlugin;
-use Dwoo\ICompilable\Block as ICompilableBlock;
-
-/**
- * This is used only when rendering a template that has blocks but is not extending anything,
- * it doesn't do anything by itself and should not be used outside of template inheritance context,
- * see {@link http://wiki.dwoo.org/index.php/TemplateInheritance} to read more about it.
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginBlock extends BlockPlugin implements ICompilableBlock
-{
- /**
- * @param string $name
- */
- public function init($name = '')
- {
- }
-
- /**
- * @param Compiler $compiler
- * @param array $params
- * @param string $prepend
- * @param string $append
- * @param string $type
- *
- * @return string
- */
- public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type)
- {
- return '';
- }
-
- /**
- * @param Compiler $compiler
- * @param array $params
- * @param string $prepend
- * @param string $append
- * @param string $content
- *
- * @return string
- */
- public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content)
- {
- return $content;
- }
-}
diff --git a/core/l/Dwoo/Plugins/Blocks/PluginCapture.php b/core/l/Dwoo/Plugins/Blocks/PluginCapture.php
deleted file mode 100644
index f8c9c03..0000000
--- a/core/l/Dwoo/Plugins/Blocks/PluginCapture.php
+++ /dev/null
@@ -1,95 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2016 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.0
- * @date 2016-09-19
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Blocks;
-
-use Dwoo\Compiler;
-use Dwoo\Block\Plugin as BlockPlugin;
-use Dwoo\ICompilable\Block as ICompilableBlock;
-
-/**
- * Captures all the output within this block and saves it into {$.capture.default} by default,
- * or {$.capture.name} if you provide another name.
- *
- * * name : capture name, used to read the value afterwards
- * * assign : if set, the value is also saved in the given variable
- * * cat : if true, the value is appended to the previous one (if any) instead of overwriting it
- *
- * If the cat parameter is true, the content
- * will be appended to the existing content.
- * Example :
- *
- * {capture "foo"}
- * Anything in here won't show, it will be saved for later use..
- * {/capture}
- * Output was : {$.capture.foo}
- *
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginCapture extends BlockPlugin implements ICompilableBlock
-{
- /**
- * @param string $name
- * @param null $assign
- * @param bool $cat
- * @param bool $trim
- */
- public function init($name = 'default', $assign = null, $cat = false, $trim = false)
- {
- }
-
- /**
- * @param Compiler $compiler
- * @param array $params
- * @param string $prepend
- * @param string $append
- * @param string $type
- *
- * @return string
- */
- public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type)
- {
- return Compiler::PHP_OPEN . $prepend . 'ob_start();' . $append . Compiler::PHP_CLOSE;
- }
-
- /**
- * @param Compiler $compiler
- * @param array $params
- * @param string $prepend
- * @param string $append
- * @param string $content
- *
- * @return string
- */
- public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content)
- {
- $params = $compiler->getCompiledParams($params);
-
- $out = $content . Compiler::PHP_OPEN . $prepend . "\n" . '$tmp = ob_get_clean();';
- if ($params['trim'] !== 'false' && $params['trim'] !== 0) {
- $out .= "\n" . '$tmp = trim($tmp);';
- }
- if ($params['cat'] === 'true' || $params['cat'] === 1) {
- $out .= "\n" . '$tmp = $this->readVar(\'dwoo.capture.\'.' . $params['name'] . ') . $tmp;';
- }
- if ($params['assign'] !== 'null') {
- $out .= "\n" . '$this->scope[' . $params['assign'] . '] = $tmp;';
- }
-
- return $out . "\n" . '$this->globals[\'capture\'][' . $params['name'] . '] = $tmp;' . $append . Compiler::PHP_CLOSE;
- }
-}
diff --git a/core/l/Dwoo/Plugins/Blocks/PluginDynamic.php b/core/l/Dwoo/Plugins/Blocks/PluginDynamic.php
deleted file mode 100644
index 3b1f61a..0000000
--- a/core/l/Dwoo/Plugins/Blocks/PluginDynamic.php
+++ /dev/null
@@ -1,116 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2016 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.0
- * @date 2016-09-19
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Blocks;
-
-use Dwoo\Compiler;
-use Dwoo\Block\Plugin as BlockPlugin;
-use Dwoo\ICompilable\Block as ICompilableBlock;
-use Dwoo\Compilation\Exception as CompilationException;
-
-/**
- * Marks the contents of the block as dynamic. Which means that it will not be cached.
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginDynamic extends BlockPlugin implements ICompilableBlock
-{
- /**
- *
- */
- public function init()
- {
- }
-
- /**
- * @param Compiler $compiler
- * @param array $params
- * @param string $prepend
- * @param string $append
- * @param string $type
- *
- * @return string
- */
- public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type)
- {
- return '';
- }
-
- /**
- * @param Compiler $compiler
- * @param array $params
- * @param string $prepend
- * @param string $append
- * @param string $content
- *
- * @return string
- */
- public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content)
- {
- try {
- $compiler->findBlock('dynamic');
-
- return $content;
- }
- catch (CompilationException $e) {
- }
- $output = Compiler::PHP_OPEN . 'if($doCache) {' . "\n\t" . 'echo \'' . str_replace('\'', '\\\'', $content) . '\';' . "\n} else {\n\t";
- if (substr($content, 0, strlen(Compiler::PHP_OPEN)) == Compiler::PHP_OPEN) {
- $output .= substr($content, strlen(Compiler::PHP_OPEN));
- } else {
- $output .= Compiler::PHP_CLOSE . $content;
- }
- if (substr($output, - strlen(Compiler::PHP_CLOSE)) == Compiler::PHP_CLOSE) {
- $output = substr($output, 0, - strlen(Compiler::PHP_CLOSE));
- } else {
- $output .= Compiler::PHP_OPEN;
- }
- $output .= "\n}" . Compiler::PHP_CLOSE;
-
- return $output;
- }
-
- /**
- * @param $output
- * @param $dynamicId
- * @param $compiledFile
- *
- * @return mixed|string
- */
- public static function unescape($output, $dynamicId, $compiledFile)
- {
- $output = preg_replace_callback('/(.+?)<\/dwoo:dynamic_' . $dynamicId . '>/s', array(
- 'self',
- 'unescapePhp'
- ), $output, - 1, $count);
- // re-add the includes on top of the file
- if ($count && preg_match('#/\* template head \*/(.+?)/\* end template head \*/#s', file_get_contents($compiledFile), $m)) {
- $output = '' . $output;
- }
-
- return $output;
- }
-
- /**
- * @param $match
- *
- * @return mixed
- */
- public static function unescapePhp($match)
- {
- return preg_replace('{<\?php /\*' . $match[1] . '\*/ echo \'(.+?)\'; \?>}s', '$1', $match[2]);
- }
-}
diff --git a/core/l/Dwoo/Plugins/Blocks/PluginElse.php b/core/l/Dwoo/Plugins/Blocks/PluginElse.php
deleted file mode 100644
index 14143a2..0000000
--- a/core/l/Dwoo/Plugins/Blocks/PluginElse.php
+++ /dev/null
@@ -1,96 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2016 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.0
- * @date 2016-09-19
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Blocks;
-
-use Dwoo\Compiler;
-use Dwoo\Block\Plugin as BlockPlugin;
-use Dwoo\ICompilable\Block as ICompilableBlock;
-use Dwoo\Compilation\Exception as CompilationException;
-
-/**
- * Generic else block, it supports all builtin optional-display blocks which are if/for/foreach/loop/with.
- * If any of those block contains an else statement, the content between {else} and {/block} (you do not
- * need to close the else block) will be shown if the block's condition has no been met
- * Example :
- *
- * {foreach $array val}
- * $array is not empty so we display it's values : {$val}
- * {else}
- * if this shows, it means that $array is empty or doesn't exist.
- * {/foreach}
- *
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginElse extends BlockPlugin implements ICompilableBlock
-{
- public function init()
- {
- }
-
- /**
- * @param Compiler $compiler
- * @param array $params
- * @param string $prepend
- * @param string $append
- * @param string $type
- *
- * @return string
- * @throws CompilationException
- */
- public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type)
- {
- $preContent = '';
- while (true) {
- $preContent .= $compiler->removeTopBlock();
- $block = &$compiler->getCurrentBlock();
- if (!$block) {
- throw new CompilationException($compiler, 'An else block was found but it was not preceded by an if or other else-able construct');
- }
- $interfaces = class_implements($block['class']);
- if (in_array('Dwoo\IElseable', $interfaces) !== false) {
- break;
- }
- }
-
- $params['initialized'] = true;
- $compiler->injectBlock($type, $params);
-
- return $preContent;
- }
-
- /**
- * @param Compiler $compiler
- * @param array $params
- * @param string $prepend
- * @param string $append
- * @param string $content
- *
- * @return string
- */
- public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content)
- {
- if (!isset($params['initialized'])) {
- return '';
- }
-
- $block = &$compiler->getCurrentBlock();
- $block['params']['hasElse'] = Compiler::PHP_OPEN . "else {\n" . Compiler::PHP_CLOSE . $content . Compiler::PHP_OPEN . "\n}" . Compiler::PHP_CLOSE;
-
- return '';
- }
-}
diff --git a/core/l/Dwoo/Plugins/Blocks/PluginElseif.php b/core/l/Dwoo/Plugins/Blocks/PluginElseif.php
deleted file mode 100644
index 033aa59..0000000
--- a/core/l/Dwoo/Plugins/Blocks/PluginElseif.php
+++ /dev/null
@@ -1,95 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2016 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.0
- * @date 2016-09-19
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Blocks;
-
-use Dwoo\Compiler;
-use Dwoo\IElseable;
-use Dwoo\ICompilable\Block as ICompilableBlock;
-
-/**
- * Acts as a php elseif block, allowing you to add one more condition
- * if the previous one(s) didn't match. See the {if} plugin for syntax details.
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginElseif extends PluginIf implements ICompilableBlock, IElseable
-{
- /**
- * @param array $rest
- */
- public function init(array $rest)
- {
- }
-
- /**
- * @param Compiler $compiler
- * @param array $params
- * @param string $prepend
- * @param string $append
- * @param string $type
- *
- * @return string
- */
- public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type)
- {
- $preContent = '';
- while (true) {
- $preContent .= $compiler->removeTopBlock();
- $block = &$compiler->getCurrentBlock();
- $interfaces = class_implements($block['class']);
- if (in_array('Dwoo\IElseable', $interfaces) !== false) {
- break;
- }
- }
-
- $params['initialized'] = true;
- $compiler->injectBlock($type, $params);
-
- return $preContent;
- }
-
- /**
- * @param Compiler $compiler
- * @param array $params
- * @param string $prepend
- * @param string $append
- * @param string $content
- *
- * @return string
- */
- public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content)
- {
- if (!isset($params['initialized'])) {
- return '';
- }
-
- $tokens = $compiler->getParamTokens($params);
- $params = $compiler->getCompiledParams($params);
-
- $pre = Compiler::PHP_OPEN . 'elseif (' . implode(' ', self::replaceKeywords($params['*'], $tokens['*'], $compiler)) . ") {\n" . Compiler::PHP_CLOSE;
- $post = Compiler::PHP_OPEN . "\n}" . Compiler::PHP_CLOSE;
-
- if (isset($params['hasElse'])) {
- $post .= $params['hasElse'];
- }
-
- $block = &$compiler->getCurrentBlock();
- $block['params']['hasElse'] = $pre . $content . $post;
-
- return '';
- }
-}
diff --git a/core/l/Dwoo/Plugins/Blocks/PluginFor.php b/core/l/Dwoo/Plugins/Blocks/PluginFor.php
deleted file mode 100644
index b696094..0000000
--- a/core/l/Dwoo/Plugins/Blocks/PluginFor.php
+++ /dev/null
@@ -1,192 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2016 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.0
- * @date 2016-09-19
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Blocks;
-
-use Dwoo\Compiler;
-use Dwoo\IElseable;
-use Dwoo\Block\Plugin as BlockPlugin;
-use Dwoo\ICompilable\Block as ICompilableBlock;
-
-/**
- * Similar to the php for block
- *
- * * name : for name to access it's iterator variables through {$.for.name.var} see {@link
- * http://wiki.dwoo.org/index.php/IteratorVariables} for details
- * * from : array to iterate from (which equals 0) or a number as a start value
- * * to : value to stop iterating at (equals count($array) by default if you set an array in from)
- * * step : defines the incrementation of the pointer at each iteration
- *
- * * from : the array that you want to iterate over
- * * key : variable name for the key (or for the item if item is not defined)
- * * item : variable name for each item
- * * name : foreach name to access it's iterator variables through {$.foreach.name.var} see {@link
- * http://wiki.dwoo.org/index.php/IteratorVariables} for details
- *
- * Example :
- *
- * {foreach $array val}
- * {$val.something}
- * {/foreach}
- *
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginForeach extends BlockPlugin implements ICompilableBlock, IElseable
-{
- public static $cnt = 0;
-
- /**
- * @param $from
- * @param null $key
- * @param null $item
- * @param string $name
- * @param null $implode
- */
- public function init($from, $key = null, $item = null, $name = 'default', $implode = null)
- {
- }
-
- /**
- * @param Compiler $compiler
- * @param array $params
- * @param string $prepend
- * @param string $append
- * @param string $type
- *
- * @return string
- */
- public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type)
- {
- // get block params and save the current template pointer to use it in the postProcessing method
- $currentBlock = &$compiler->getCurrentBlock();
- $currentBlock['params']['tplPointer'] = $compiler->getPointer();
-
- return '';
- }
-
- /**
- * @param Compiler $compiler
- * @param array $params
- * @param string $prepend
- * @param string $append
- * @param string $content
- *
- * @return string
- * @throws CompilationException
- */
- public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content)
- {
- $params = $compiler->getCompiledParams($params);
- $tpl = $compiler->getTemplateSource($params['tplPointer']);
-
- // assigns params
- $src = $params['from'];
-
- if ($params['item'] !== 'null') {
- if ($params['key'] !== 'null') {
- $key = $params['key'];
- }
- $val = $params['item'];
- } elseif ($params['key'] !== 'null') {
- $val = $params['key'];
- } else {
- throw new CompilationException($compiler, 'Foreach item parameter missing');
- }
- $name = $params['name'];
-
- if (substr($val, 0, 1) !== '"' && substr($val, 0, 1) !== '\'') {
- throw new CompilationException($compiler, 'Foreach item parameter must be of type string');
- }
- if (isset($key) && substr($val, 0, 1) !== '"' && substr($val, 0, 1) !== '\'') {
- throw new CompilationException($compiler, 'Foreach key parameter must be of type string');
- }
-
- // evaluates which global variables have to be computed
- $varName = '$dwoo.foreach.' . trim($name, '"\'') . '.';
- $shortVarName = '$.foreach.' . trim($name, '"\'') . '.';
- $usesAny = strpos($tpl, $varName) !== false || strpos($tpl, $shortVarName) !== false;
- $usesFirst = strpos($tpl, $varName . 'first') !== false || strpos($tpl, $shortVarName . 'first') !== false;
- $usesLast = strpos($tpl, $varName . 'last') !== false || strpos($tpl, $shortVarName . 'last') !== false;
- $usesIndex = $usesFirst || strpos($tpl, $varName . 'index') !== false || strpos($tpl, $shortVarName . 'index') !== false;
- $usesIteration = $usesLast || strpos($tpl, $varName . 'iteration') !== false || strpos($tpl, $shortVarName . 'iteration') !== false;
- $usesShow = strpos($tpl, $varName . 'show') !== false || strpos($tpl, $shortVarName . 'show') !== false;
- $usesTotal = $usesLast || strpos($tpl, $varName . 'total') !== false || strpos($tpl, $shortVarName . 'total') !== false;
-
- if (strpos($name, '$this->scope[') !== false) {
- $usesAny = $usesFirst = $usesLast = $usesIndex = $usesIteration = $usesShow = $usesTotal = true;
- }
-
- // override globals vars if implode is used
- if ($params['implode'] !== 'null') {
- $implode = $params['implode'];
- $usesAny = true;
- $usesLast = true;
- $usesIteration = true;
- $usesTotal = true;
- }
-
- // gets foreach id
- $cnt = self::$cnt ++;
-
- // build pre content output
- $pre = Compiler::PHP_OPEN . "\n" . '$_fh' . $cnt . '_data = ' . $src . ';';
- // adds foreach properties
- if ($usesAny) {
- $pre .= "\n" . '$this->globals["foreach"][' . $name . '] = array' . "\n(";
- if ($usesIndex) {
- $pre .= "\n\t" . '"index" => 0,';
- }
- if ($usesIteration) {
- $pre .= "\n\t" . '"iteration" => 1,';
- }
- if ($usesFirst) {
- $pre .= "\n\t" . '"first" => null,';
- }
- if ($usesLast) {
- $pre .= "\n\t" . '"last" => null,';
- }
- if ($usesShow) {
- $pre .= "\n\t" . '"show" => $this->isArray($_fh' . $cnt . '_data, true),';
- }
- if ($usesTotal) {
- $pre .= "\n\t" . '"total" => $this->count($_fh' . $cnt . '_data),';
- }
- $pre .= "\n);\n" . '$_fh' . $cnt . '_glob =& $this->globals["foreach"][' . $name . '];';
- }
- // checks if foreach must be looped
- $pre .= "\n" . 'if ($this->isTraversable($_fh' . $cnt . '_data' . (isset($params['hasElse']) ? ', true' : '') . ') == true)' . "\n{";
- // iterates over keys
- $pre .= "\n\t" . 'foreach ($_fh' . $cnt . '_data as ' . (isset($key) ? '$this->scope[' . $key . ']=>' : '') . '$this->scope[' . $val . '])' . "\n\t{";
- // updates properties
- if ($usesFirst) {
- $pre .= "\n\t\t" . '$_fh' . $cnt . '_glob["first"] = (string) ($_fh' . $cnt . '_glob["index"] === 0);';
- }
- if ($usesLast) {
- $pre .= "\n\t\t" . '$_fh' . $cnt . '_glob["last"] = (string) ($_fh' . $cnt . '_glob["iteration"] === $_fh' . $cnt . '_glob["total"]);';
- }
- $pre .= "\n/* -- foreach start output */\n" . Compiler::PHP_CLOSE;
-
- // build post content output
- $post = Compiler::PHP_OPEN . "\n";
-
- if (isset($implode)) {
- $post .= '/* -- implode */' . "\n" . 'if (!$_fh' . $cnt . '_glob["last"]) {' . "\n\t" . 'echo ' . $implode . ";\n}\n";
- }
- $post .= '/* -- foreach end output */';
- // update properties
- if ($usesIndex) {
- $post .= "\n\t\t" . '$_fh' . $cnt . '_glob["index"]+=1;';
- }
- if ($usesIteration) {
- $post .= "\n\t\t" . '$_fh' . $cnt . '_glob["iteration"]+=1;';
- }
- // end loop
- $post .= "\n\t}\n}" . Compiler::PHP_CLOSE;
- if (isset($params['hasElse'])) {
- $post .= $params['hasElse'];
- }
-
- return $pre . $content . $post;
- }
-}
diff --git a/core/l/Dwoo/Plugins/Blocks/PluginForeachelse.php b/core/l/Dwoo/Plugins/Blocks/PluginForeachelse.php
deleted file mode 100644
index 5a09327..0000000
--- a/core/l/Dwoo/Plugins/Blocks/PluginForeachelse.php
+++ /dev/null
@@ -1,73 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2016 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.0
- * @date 2016-09-19
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Blocks;
-
-use Dwoo\Compiler;
-use Dwoo\Block\Plugin as BlockPlugin;
-use Dwoo\ICompilable\Block as ICompilableBlock;
-
-/**
- * This plugin serves as a {else} block specifically for the {foreach} plugin.
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginForeachelse extends BlockPlugin implements ICompilableBlock
-{
- public function init()
- {
- }
-
- /**
- * @param Compiler $compiler
- * @param array $params
- * @param string $prepend
- * @param string $append
- * @param string $type
- *
- * @return string
- */
- public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type)
- {
- $with = &$compiler->findBlock('foreach', true);
-
- $params['initialized'] = true;
- $compiler->injectBlock($type, $params);
-
- return '';
- }
-
- /**
- * @param Compiler $compiler
- * @param array $params
- * @param string $prepend
- * @param string $append
- * @param string $content
- *
- * @return string
- */
- public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content)
- {
- if (!isset($params['initialized'])) {
- return '';
- }
-
- $block = &$compiler->getCurrentBlock();
- $block['params']['hasElse'] = Compiler::PHP_OPEN . "else {\n" . Compiler::PHP_CLOSE . $content . Compiler::PHP_OPEN . "\n}" . Compiler::PHP_CLOSE;
-
- return '';
- }
-}
diff --git a/core/l/Dwoo/Plugins/Blocks/PluginForelse.php b/core/l/Dwoo/Plugins/Blocks/PluginForelse.php
deleted file mode 100644
index 4d4a588..0000000
--- a/core/l/Dwoo/Plugins/Blocks/PluginForelse.php
+++ /dev/null
@@ -1,73 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2016 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.0
- * @date 2016-09-19
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Blocks;
-
-use Dwoo\Compiler;
-use Dwoo\Block\Plugin as BlockPlugin;
-use Dwoo\ICompilable\Block as ICompilableBlock;
-
-/**
- * This plugin serves as a {else} block specifically for the {for} plugin.
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginForelse extends BlockPlugin implements ICompilableBlock
-{
- public function init()
- {
- }
-
- /**
- * @param Compiler $compiler
- * @param array $params
- * @param string $prepend
- * @param string $append
- * @param string $type
- *
- * @return string
- */
- public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type)
- {
- $with = &$compiler->findBlock('for', true);
-
- $params['initialized'] = true;
- $compiler->injectBlock($type, $params);
-
- return '';
- }
-
- /**
- * @param Compiler $compiler
- * @param array $params
- * @param string $prepend
- * @param string $append
- * @param string $content
- *
- * @return string
- */
- public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content)
- {
- if (!isset($params['initialized'])) {
- return '';
- }
-
- $block = &$compiler->getCurrentBlock();
- $block['params']['hasElse'] = Compiler::PHP_OPEN . "else {\n" . Compiler::PHP_CLOSE . $content . Compiler::PHP_OPEN . "\n}" . Compiler::PHP_CLOSE;
-
- return '';
- }
-}
diff --git a/core/l/Dwoo/Plugins/Blocks/PluginIf.php b/core/l/Dwoo/Plugins/Blocks/PluginIf.php
deleted file mode 100644
index d982327..0000000
--- a/core/l/Dwoo/Plugins/Blocks/PluginIf.php
+++ /dev/null
@@ -1,274 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2016 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.0
- * @date 2016-09-19
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Blocks;
-
-use Dwoo\Compiler;
-use Dwoo\IElseable;
-use Dwoo\Block\Plugin as BlockPlugin;
-use Dwoo\ICompilable\Block as ICompilableBlock;
-use Dwoo\Compilation\Exception as CompilationException;
-
-/**
- * Conditional block, the syntax is very similar to the php one, allowing () || && and
- * other php operators. Additional operators and their equivalent php syntax are as follow :.
- * eq -> ==
- * neq or ne -> !=
- * gte or ge -> >=
- * lte or le -> <=
- * gt -> >
- * lt -> <
- * mod -> %
- * not -> !
- * X is [not] div by Y -> (X % Y) == 0
- * X is [not] even [by Y] -> (X % 2) == 0 or ((X/Y) % 2) == 0
- * X is [not] odd [by Y] -> (X % 2) != 0 or ((X/Y) % 2) != 0
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginIf extends BlockPlugin implements ICompilableBlock, IElseable
-{
- /**
- * @param array $rest
- */
- public function init(array $rest)
- {
- }
-
- /**
- * @param array $params
- * @param array $tokens
- * @param Compiler $compiler
- *
- * @return array
- * @throws CompilationException
- */
- public static function replaceKeywords(array $params, array $tokens, Compiler $compiler)
- {
- $p = array();
-
- reset($params);
- while (list($k, $v) = each($params)) {
- $v = (string)$v;
- if (substr($v, 0, 1) === '"' || substr($v, 0, 1) === '\'') {
- $vmod = strtolower(substr($v, 1, - 1));
- } else {
- $vmod = strtolower($v);
- }
- switch ($vmod) {
-
- case 'and':
- if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) {
- $p[] = '&&';
- } else {
- $p[] = $v;
- }
- break;
- case 'or':
- if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) {
- $p[] = '||';
- } else {
- $p[] = $v;
- }
- break;
- case 'xor':
- if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) {
- $p[] = '^';
- } else {
- $p[] = $v;
- }
- break;
- case 'eq':
- if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) {
- $p[] = '==';
- } else {
- $p[] = $v;
- }
- break;
- case 'ne':
- case 'neq':
- if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) {
- $p[] = '!=';
- } else {
- $p[] = $v;
- }
- break;
- case 'gte':
- case 'ge':
- if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) {
- $p[] = '>=';
- } else {
- $p[] = $v;
- }
- break;
- case 'lte':
- case 'le':
- if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) {
- $p[] = '<=';
- } else {
- $p[] = $v;
- }
- break;
- case 'gt':
- if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) {
- $p[] = '>';
- } else {
- $p[] = $v;
- }
- break;
- case 'lt':
- if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) {
- $p[] = '<';
- } else {
- $p[] = $v;
- }
- break;
- case 'mod':
- if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) {
- $p[] = '%';
- } else {
- $p[] = $v;
- }
- break;
- case 'not':
- if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) {
- $p[] = '!';
- } else {
- $p[] = $v;
- }
- break;
- case '<>':
- $p[] = '!=';
- break;
- case '==':
- case '!=':
- case '>=':
- case '<=':
- case '>':
- case '<':
- case '===':
- case '!==':
- case '%':
- case '!':
- case '^':
- $p[] = $vmod;
- break;
- case 'is':
- if ($tokens[$k] !== Compiler::T_UNQUOTED_STRING) {
- $p[] = $v;
- break;
- }
- if (isset($params[$k + 1]) && strtolower(trim($params[$k + 1], '"\'')) === 'not' && $tokens[$k + 1] === Compiler::T_UNQUOTED_STRING) {
- $negate = true;
- next($params);
- } else {
- $negate = false;
- }
- $ptr = 1 + (int)$negate;
- if ($tokens[$k + $ptr] !== Compiler::T_UNQUOTED_STRING) {
- break;
- }
- if (!isset($params[$k + $ptr])) {
- $params[$k + $ptr] = '';
- } else {
- $params[$k + $ptr] = trim($params[$k + $ptr], '"\'');
- }
- switch ($params[$k + $ptr]) {
-
- case 'div':
- if (isset($params[$k + $ptr + 1]) && strtolower(trim($params[$k + $ptr + 1], '"\'')) === 'by') {
- $p[] = ' % ' . $params[$k + $ptr + 2] . ' ' . ($negate ? '!' : '=') . '== 0';
- next($params);
- next($params);
- next($params);
- } else {
- throw new CompilationException($compiler, 'If : Syntax error : syntax should be "if $a is [not] div by $b", found ' . $params[$k - 1] . ' is ' . ($negate ? 'not ' : '') . 'div ' . $params[$k + $ptr + 1] . ' ' . $params[$k + $ptr + 2]);
- }
- break;
- case 'even':
- $a = array_pop($p);
- if (isset($params[$k + $ptr + 1]) && strtolower(trim($params[$k + $ptr + 1], '"\'')) === 'by') {
- $b = $params[$k + $ptr + 2];
- $p[] = '(' . $a . ' / ' . $b . ') % 2 ' . ($negate ? '!' : '=') . '== 0';
- next($params);
- next($params);
- } else {
- $p[] = $a . ' % 2 ' . ($negate ? '!' : '=') . '== 0';
- }
- next($params);
- break;
- case 'odd':
- $a = array_pop($p);
- if (isset($params[$k + $ptr + 1]) && strtolower(trim($params[$k + $ptr + 1], '"\'')) === 'by') {
- $b = $params[$k + $ptr + 2];
- $p[] = '(' . $a . ' / ' . $b . ') % 2 ' . ($negate ? '=' : '!') . '== 0';
- next($params);
- next($params);
- } else {
- $p[] = $a . ' % 2 ' . ($negate ? '=' : '!') . '== 0';
- }
- next($params);
- break;
- default:
- throw new CompilationException($compiler, 'If : Syntax error : syntax should be "if $a is [not] (div|even|odd) [by $b]", found ' . $params[$k - 1] . ' is ' . $params[$k + $ptr + 1]);
- }
- break;
- default:
- $p[] = $v;
- }
- }
-
- return $p;
- }
-
- /**
- * @param Compiler $compiler
- * @param array $params
- * @param string $prepend
- * @param string $append
- * @param string $type
- *
- * @return string
- */
- public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type)
- {
- return '';
- }
-
- /**
- * @param Compiler $compiler
- * @param array $params
- * @param string $prepend
- * @param string $append
- * @param string $content
- *
- * @return string
- */
- public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content)
- {
- $tokens = $compiler->getParamTokens($params);
- $params = $compiler->getCompiledParams($params);
- $pre = Compiler::PHP_OPEN . 'if (' . implode(' ', self::replaceKeywords($params['*'], $tokens['*'], $compiler)) . ") {\n" . Compiler::PHP_CLOSE;
-
- $post = Compiler::PHP_OPEN . "\n}" . Compiler::PHP_CLOSE;
-
- if (isset($params['hasElse'])) {
- $post .= $params['hasElse'];
- }
-
- return $pre . $content . $post;
- }
-}
diff --git a/core/l/Dwoo/Plugins/Blocks/PluginLoop.php b/core/l/Dwoo/Plugins/Blocks/PluginLoop.php
deleted file mode 100644
index 5efbf43..0000000
--- a/core/l/Dwoo/Plugins/Blocks/PluginLoop.php
+++ /dev/null
@@ -1,170 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2016 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.0
- * @date 2016-09-19
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Blocks;
-
-use Dwoo\Compiler;
-use Dwoo\IElseable;
-use Dwoo\Block\Plugin as BlockPlugin;
-use Dwoo\ICompilable\Block as ICompilableBlock;
-
-/**
- * Loops over an array and moves the scope into each value, allowing for shorter loop constructs.
- * Note that to access the array key within a loop block, you have to use the {$_key} variable,
- * you can not specify it yourself.
- *
- * * from : the array that you want to iterate over
- * * name : loop name to access it's iterator variables through {$.loop.name.var} see {@link
- * http://wiki.dwoo.org/index.php/IteratorVariables} for details
- *
- * * mode : sets the content being stripped, available mode are 'default' or 'js'
- * for javascript, which strips the comments to prevent syntax errors
- *
.
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginStrip extends BlockPlugin implements ICompilableBlock
-{
- /**
- * @param string $mode
- */
- public function init($mode = 'default')
- {
- }
-
- /**
- * @param Compiler $compiler
- * @param array $params
- * @param string $prepend
- * @param string $append
- * @param string $type
- *
- * @return string
- */
- public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type)
- {
- return '';
- }
-
- /**
- * @param Compiler $compiler
- * @param array $params
- * @param string $prepend
- * @param string $append
- * @param string $content
- *
- * @return mixed|string
- */
- public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content)
- {
- $params = $compiler->getCompiledParams($params);
-
- $mode = trim($params['mode'], '"\'');
- switch ($mode) {
- case 'js':
- case 'javascript':
- $content = preg_replace('#(?
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2016 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.0
- * @date 2016-09-20
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Blocks;
-
-use Dwoo\Core;
-use Dwoo\Compiler;
-use Dwoo\Block\Plugin as BlockPlugin;
-use Dwoo\ICompilable\Block as ICompilableBlock;
-use Dwoo\Compilation\Exception as CompilationException;
-
-/**
- * Defines a sub-template that can then be called (even recursively) with the defined arguments
- *
- * * name : template name
- * * rest : list of arguments and optional default values
- *
- * * wrap : maximum line length
- * * wrap_char : the character(s) to use to break the line
- * * wrap_cut : if true, the words that are longer than $wrap are cut instead of overflowing
- * * indent : amount of $indent_char to insert before every line
- * * indent_char : character(s) to insert before every line
- * * indent_first : amount of additional $indent_char to insert before the first line of each paragraphs
- * * style : some predefined formatting styles that set up every required variables, can be "email" or "html"
- * * assign : if set, the formatted text is assigned to that variable instead of being output
- *
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginTextformat extends BlockPlugin
-{
- protected $wrap;
- protected $wrapChar;
- protected $wrapCut;
- protected $indent;
- protected $indChar;
- protected $indFirst;
- protected $assign;
-
- /**
- * @param int $wrap
- * @param string $wrap_char
- * @param bool $wrap_cut
- * @param int $indent
- * @param string $indent_char
- * @param int $indent_first
- * @param string $style
- * @param string $assign
- */
- public function init($wrap = 80, $wrap_char = "\r\n", $wrap_cut = false, $indent = 0, $indent_char = ' ', $indent_first = 0, $style = '', $assign = '')
- {
- if ($indent_char === 'tab') {
- $indent_char = "\t";
- }
-
- switch ($style) {
-
- case 'email':
- $wrap = 72;
- $indent_first = 0;
- break;
- case 'html':
- $wrap_char = ' ';
- $indent_char = $indent_char == "\t" ? ' ' : ' ';
- break;
- }
-
- $this->wrap = (int)$wrap;
- $this->wrapChar = (string)$wrap_char;
- $this->wrapCut = (bool)$wrap_cut;
- $this->indent = (int)$indent;
- $this->indChar = (string)$indent_char;
- $this->indFirst = (int)$indent_first + $this->indent;
- $this->assign = (string)$assign;
- }
-
- /**
- * @return string
- */
- public function process()
- {
- // gets paragraphs
- $pgs = explode("\n", str_replace(array(
- "\r\n",
- "\r"
- ), "\n", $this->buffer));
-
- while (list($i) = each($pgs)) {
- if (empty($pgs[$i])) {
- continue;
- }
-
- // removes line breaks and extensive white space
- $pgs[$i] = preg_replace(array(
- '#\s+#',
- '#^\s*(.+?)\s*$#m'
- ), array(
- ' ',
- '$1'
- ), str_replace("\n", '', $pgs[$i]));
-
- // wordwraps + indents lines
- $pgs[$i] = str_repeat($this->indChar, $this->indFirst) . wordwrap($pgs[$i], max($this->wrap - $this->indent, 1), $this->wrapChar . str_repeat($this->indChar, $this->indent), $this->wrapCut);
- }
-
- if ($this->assign !== '') {
- $this->core->assignInScope(implode($this->wrapChar . $this->wrapChar, $pgs), $this->assign);
- } else {
- return implode($this->wrapChar . $this->wrapChar, $pgs);
- }
- }
-}
diff --git a/core/l/Dwoo/Plugins/Blocks/PluginTopLevelBlock.php b/core/l/Dwoo/Plugins/Blocks/PluginTopLevelBlock.php
deleted file mode 100644
index 2694be2..0000000
--- a/core/l/Dwoo/Plugins/Blocks/PluginTopLevelBlock.php
+++ /dev/null
@@ -1,60 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2016 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.0
- * @date 2016-09-19
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Blocks;
-
-use Dwoo\Compiler;
-use Dwoo\Block\Plugin as BlockPlugin;
-use Dwoo\ICompilable\Block as ICompilableBlock;
-
-/**
- * Internal plugin used to wrap the template output, do not use in your templates as it will break them.
- * This software is provided 'as-is', without any express or implied warranty.
- */
-final class PluginTopLevelBlock extends BlockPlugin implements ICompilableBlock
-{
- public function init()
- {
- }
-
- /**
- * @param Compiler $compiler
- * @param array $params
- * @param string $prepend
- * @param string $append
- * @param string $type
- *
- * @return string
- */
- public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type)
- {
- return '/* end template head */ ob_start(); /* template body */ ' . Compiler::PHP_CLOSE;
- }
-
- /**
- * @param Compiler $compiler
- * @param array $params
- * @param string $prepend
- * @param string $append
- * @param string $content
- *
- * @return string
- */
- public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content)
- {
- return $content . Compiler::PHP_OPEN . ' /* end template body */' . "\n" . 'return $this->buffer . ob_get_clean();';
- }
-}
diff --git a/core/l/Dwoo/Plugins/Blocks/PluginWith.php b/core/l/Dwoo/Plugins/Blocks/PluginWith.php
deleted file mode 100644
index f5e94fc..0000000
--- a/core/l/Dwoo/Plugins/Blocks/PluginWith.php
+++ /dev/null
@@ -1,99 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2016 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.0
- * @date 2016-09-19
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Blocks;
-
-use Dwoo\IElseable;
-use Dwoo\Compiler;
-use Dwoo\Block\Plugin as BlockPlugin;
-use Dwoo\ICompilable\Block as ICompilableBlock;
-
-/**
- * Moves the scope down into the provided variable, allowing you to use shorter
- * variable names if you repeatedly access values into a single array.
- * The with block won't display anything at all if the provided scope is empty,
- * so in effect it acts as {if $var}*content*{/if}
- *
- * * var : the variable name to move into
- *
- * Example :
- * instead of the following :
- *
- * {if $long.boring.prefix}
- * {$long.boring.prefix.val} - {$long.boring.prefix.secondVal} - {$long.boring.prefix.thirdVal}
- * {/if}
- *
- * you can use :
- *
- * {with $long.boring.prefix}
- * {$val} - {$secondVal} - {$thirdVal}
- * {/with}
- *
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginWith extends BlockPlugin implements ICompilableBlock, IElseable
-{
- protected static $cnt = 0;
-
- /**
- * @param $var
- */
- public function init($var)
- {
- }
-
- /**
- * @param Compiler $compiler
- * @param array $params
- * @param string $prepend
- * @param string $append
- * @param string $type
- *
- * @return string
- */
- public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type)
- {
- return '';
- }
-
- /**
- * @param Compiler $compiler
- * @param array $params
- * @param string $prepend
- * @param string $append
- * @param string $content
- *
- * @return string
- */
- public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content)
- {
- $rparams = $compiler->getRealParams($params);
- $cparams = $compiler->getCompiledParams($params);
-
- $compiler->setScope($rparams['var']);
-
- $pre = Compiler::PHP_OPEN . 'if (' . $cparams['var'] . ')' . "\n{\n" . '$_with' . (self::$cnt) . ' = $this->setScope("' . $rparams['var'] . '");' . "\n/* -- start with output */\n" . Compiler::PHP_CLOSE;
-
- $post = Compiler::PHP_OPEN . "\n/* -- end with output */\n" . '$this->setScope($_with' . (self::$cnt ++) . ', true);' . "\n}\n" . Compiler::PHP_CLOSE;
-
- if (isset($params['hasElse'])) {
- $post .= $params['hasElse'];
- }
-
- return $pre . $content . $post;
- }
-}
diff --git a/core/l/Dwoo/Plugins/Blocks/PluginWithelse.php b/core/l/Dwoo/Plugins/Blocks/PluginWithelse.php
deleted file mode 100644
index a614322..0000000
--- a/core/l/Dwoo/Plugins/Blocks/PluginWithelse.php
+++ /dev/null
@@ -1,73 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2016 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.0
- * @date 2016-09-19
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Blocks;
-
-use Dwoo\Compiler;
-use Dwoo\Block\Plugin as BlockPlugin;
-use Dwoo\ICompilable\Block as ICompilableBlock;
-
-/**
- * This plugin serves as a {else} block specifically for the {with} plugin.
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginWithelse extends BlockPlugin implements ICompilableBlock
-{
- public function init()
- {
- }
-
- /**
- * @param Compiler $compiler
- * @param array $params
- * @param string $prepend
- * @param string $append
- * @param string $type
- *
- * @return string
- */
- public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type)
- {
- $with = &$compiler->findBlock('with', true);
-
- $params['initialized'] = true;
- $compiler->injectBlock($type, $params);
-
- return '';
- }
-
- /**
- * @param Compiler $compiler
- * @param array $params
- * @param string $prepend
- * @param string $append
- * @param string $content
- *
- * @return string
- */
- public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content)
- {
- if (!isset($params['initialized'])) {
- return '';
- }
-
- $block = &$compiler->getCurrentBlock();
- $block['params']['hasElse'] = Compiler::PHP_OPEN . "else {\n" . Compiler::PHP_CLOSE . $content . Compiler::PHP_OPEN . "\n}" . Compiler::PHP_CLOSE;
-
- return '';
- }
-}
diff --git a/core/l/Dwoo/Plugins/Filters/PluginHtmlFormat.php b/core/l/Dwoo/Plugins/Filters/PluginHtmlFormat.php
deleted file mode 100644
index f923de4..0000000
--- a/core/l/Dwoo/Plugins/Filters/PluginHtmlFormat.php
+++ /dev/null
@@ -1,190 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2016 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.0
- * @date 2016-09-18
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Filters;
-
-use Dwoo\Filter;
-
-/**
- * Formats any html output (must be valid xml where every tag opened is closed)
- * using a single tab for indenting. 'pre' and other whitespace sensitive
- * tags should not be affected.
- * It is not recommended to use this on every template if you render multiple
- * templates per page, you should only use it once on the main page template so that
- * everything is formatted in one pass.
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginHtmlFormat extends Filter
-{
- /**
- * tab count to auto-indent the source.
- *
- * @var int
- */
- protected static $tabCount = - 1;
-
- /**
- * stores the additional data (following a tag) of the last call to open/close/singleTag.
- *
- * @var string
- */
- protected static $lastCallAdd = '';
-
- /**
- * formats the input using the singleTag/closeTag/openTag functions.
- * It is auto indenting the whole code, excluding ') {
- return self::singleTag($input[1], $input[3], $input[2]);
- }
- // it's the closing tag
- if ($input[0][1] == '/') {
- return self::closeTag($input[1], $input[3], $input[2]);
- }
-
- // opening tag
- return self::openTag($input[1], $input[3], $input[2]);
- }
-
- /**
- * returns an open tag and adds a tab into the auto indenting.
- *
- * @param string $tag content of the tag
- * @param string $add additional data (anything before the following tag)
- * @param string $whitespace white space between the tag and the additional data
- *
- * @return string
- */
- protected static function openTag($tag, $add, $whitespace)
- {
- $tabs = str_pad('', self::$tabCount ++, "\t");
-
- if (preg_match('#^<(a|label|option|textarea|h1|h2|h3|h4|h5|h6|strong|b|em|i|abbr|acronym|cite|span|sub|sup|u|s|title)(?: [^>]*|)>#', $tag)) {
- // if it's one of those tag it's inline so it does not require a leading line break
- $result = $tag . $whitespace . str_replace("\n", "\n" . $tabs, $add);
- } elseif (substr($tag, 0, 9) == '#', $tag)) {
- $result = $tag . $whitespace . str_replace("\n", "\n" . $tabs, $add);
- } else {
- $result = "\n" . $tabs . $tag;
-
- if (!empty($add)) {
- $result .= "\n" . $tabs . "\t" . str_replace("\n", "\n\t" . $tabs, $add);
- }
- }
-
- self::$lastCallAdd = $add;
-
- return $result;
- }
-
- /**
- * returns a single tag with auto indenting.
- *
- * @param string $tag content of the tag
- * @param string $add additional data (anything before the following tag)
- *
- * @return string
- */
- protected static function singleTag($tag, $add, $whitespace)
- {
- $tabs = str_pad('', self::$tabCount, "\t");
-
- // if it's img, br it's inline so it does not require a leading line break
- // if it's a closing textarea, code or pre tag, it does not require a leading line break either or it creates whitespace at the end of those blocks
- if (preg_match('#^<(img|br|/textarea|/pre|/code)(?: [^>]*|)>#', $tag)) {
- $result = $tag . $whitespace;
-
- if (!empty($add)) {
- $result .= str_replace("\n", "\n" . $tabs, $add);
- }
- } else {
- $result = "\n" . $tabs . $tag;
-
- if (!empty($add)) {
- $result .= "\n" . $tabs . str_replace("\n", "\n" . $tabs, $add);
- }
- }
-
- self::$lastCallAdd = $add;
-
- return $result;
- }
-}
diff --git a/core/l/Dwoo/Plugins/Functions/PluginAssign.php b/core/l/Dwoo/Plugins/Functions/PluginAssign.php
deleted file mode 100644
index 0e3f69d..0000000
--- a/core/l/Dwoo/Plugins/Functions/PluginAssign.php
+++ /dev/null
@@ -1,46 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2017 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.2
- * @date 2017-01-06
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Functions;
-
-use Dwoo\Compiler;
-use Dwoo\ICompilable;
-use Dwoo\Plugin;
-
-/**
- * Assigns a value to a variable
- *
- * * value : the value that you want to save
- * * var : the variable name (without the leading $)
- *
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginAssign extends Plugin implements ICompilable
-{
-
- /**
- * @param Compiler $compiler
- * @param mixed $value
- * @param mixed $var
- *
- * @return string
- */
- public static function compile(Compiler $compiler, $value, $var)
- {
- return '$this->assignInScope(' . $value . ', ' . $var . ')';
- }
-}
\ No newline at end of file
diff --git a/core/l/Dwoo/Plugins/Functions/PluginCapitalize.php b/core/l/Dwoo/Plugins/Functions/PluginCapitalize.php
deleted file mode 100644
index b54a602..0000000
--- a/core/l/Dwoo/Plugins/Functions/PluginCapitalize.php
+++ /dev/null
@@ -1,56 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2017 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.4
- * @date 2017-03-01
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Functions;
-
-use Dwoo\Plugin;
-
-/**
- * Capitalizes the first letter of each word
- *
- * * value : the string to capitalize
- * * numwords : if true, the words containing numbers are capitalized as well
- *
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginCapitalize extends Plugin
-{
- /**
- * @param string $value
- * @param bool $numwords
- *
- * @return string
- */
- public function process($value, $numwords = false)
- {
- if ($numwords || preg_match('#^[^0-9]+$#', $value)) {
- return mb_convert_case((string)$value, MB_CASE_TITLE, $this->core->getCharset());
- } else {
- $bits = explode(' ', (string)$value);
- $out = '';
- foreach ($bits as $k => $v){
- if (preg_match('#^[^0-9]+$#', $v)) {
- $out .= ' ' . mb_convert_case($v, MB_CASE_TITLE, $this->core->getCharset());
- } else {
- $out .= ' ' . $v;
- }
- }
-
- return substr($out, 1);
- }
- }
-}
diff --git a/core/l/Dwoo/Plugins/Functions/PluginCat.php b/core/l/Dwoo/Plugins/Functions/PluginCat.php
deleted file mode 100644
index 20a88bc..0000000
--- a/core/l/Dwoo/Plugins/Functions/PluginCat.php
+++ /dev/null
@@ -1,44 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2017 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.2
- * @date 2017-01-06
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Functions;
-
-use Dwoo\Compiler;
-use Dwoo\ICompilable;
-use Dwoo\Plugin;
-
-/**
- * Concatenates any number of variables or strings fed into it
- *
- * * rest : two or more strings that will be merged into one
- *
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginCat extends Plugin implements ICompilable
-{
- /**
- * @param Compiler $compiler
- * @param string $value
- * @param array $rest
- *
- * @return string
- */
- public static function compile(Compiler $compiler, $value, array $rest)
- {
- return '(' . $value . ').(' . implode(').(', $rest) . ')';
- }
-}
diff --git a/core/l/Dwoo/Plugins/Functions/PluginCountCharacters.php b/core/l/Dwoo/Plugins/Functions/PluginCountCharacters.php
deleted file mode 100644
index f2c01b2..0000000
--- a/core/l/Dwoo/Plugins/Functions/PluginCountCharacters.php
+++ /dev/null
@@ -1,49 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2017 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.2
- * @date 2017-01-06
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Functions;
-
-use Dwoo\Compiler;
-use Dwoo\ICompilable;
-use Dwoo\Plugin;
-
-/**
- * Counts the characters in a string
- *
- * * value : the string to process
- * * count_spaces : if true, the white-space characters are counted as well
- *
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginCountCharacters extends Plugin implements ICompilable
-{
- /**
- * @param Compiler $compiler
- * @param string $value
- * @param bool $count_spaces
- *
- * @return string
- */
- public static function compile(Compiler $compiler, $value, $count_spaces = false)
- {
- if ($count_spaces === 'false') {
- return 'preg_match_all(\'#[^\s\pZ]#u\', ' . $value . ', $tmp)';
- }
-
- return 'mb_strlen(' . $value . ', $this->charset)';
- }
-}
\ No newline at end of file
diff --git a/core/l/Dwoo/Plugins/Functions/PluginCountParagraphs.php b/core/l/Dwoo/Plugins/Functions/PluginCountParagraphs.php
deleted file mode 100644
index 2ab75e3..0000000
--- a/core/l/Dwoo/Plugins/Functions/PluginCountParagraphs.php
+++ /dev/null
@@ -1,43 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2017 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.2
- * @date 2017-01-06
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Functions;
-
-use Dwoo\Compiler;
-use Dwoo\ICompilable;
-use Dwoo\Plugin;
-
-/**
- * Counts the paragraphs in a string
- *
- * * value : the string to process
- *
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginCountParagraphs extends Plugin implements ICompilable
-{
- /**
- * @param Compiler $compiler
- * @param string $value
- *
- * @return string
- */
- public static function compile(Compiler $compiler, $value)
- {
- return '(preg_match_all(\'#[\r\n]+#\', ' . $value . ', $tmp)+1)';
- }
-}
\ No newline at end of file
diff --git a/core/l/Dwoo/Plugins/Functions/PluginCountSentences.php b/core/l/Dwoo/Plugins/Functions/PluginCountSentences.php
deleted file mode 100644
index ebbfd34..0000000
--- a/core/l/Dwoo/Plugins/Functions/PluginCountSentences.php
+++ /dev/null
@@ -1,43 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2017 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.2
- * @date 2017-01-06
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Functions;
-
-use Dwoo\Compiler;
-use Dwoo\ICompilable;
-use Dwoo\Plugin;
-
-/**
- * Counts the sentences in a string
- *
- * * value : the string to process
- *
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginCountSentences extends Plugin implements ICompilable
-{
- /**
- * @param Compiler $compiler
- * @param string $value
- *
- * @return string
- */
- public static function compile(Compiler $compiler, $value)
- {
- return "preg_match_all('#[\\w\\pL]\\.(?![\\w\\pL])#u', $value, \$tmp)";
- }
-}
\ No newline at end of file
diff --git a/core/l/Dwoo/Plugins/Functions/PluginCountWords.php b/core/l/Dwoo/Plugins/Functions/PluginCountWords.php
deleted file mode 100644
index e5d165e..0000000
--- a/core/l/Dwoo/Plugins/Functions/PluginCountWords.php
+++ /dev/null
@@ -1,37 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2017 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.2
- * @date 2017-01-06
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Functions;
-
-use Dwoo\Compiler;
-use Dwoo\ICompilable;
-use Dwoo\Plugin;
-
-/**
- * Counts the words in a string
- *
- * * value : the string to process
- *
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginCountWords extends Plugin implements ICompilable
-{
- public static function compile(Compiler $compiler, $value)
- {
- return 'preg_match_all(strcasecmp($this->charset, \'utf-8\')===0 ? \'#[\w\pL]+#u\' : \'#\w+#\', ' . $value . ', $tmp)';
- }
-}
\ No newline at end of file
diff --git a/core/l/Dwoo/Plugins/Functions/PluginCounter.php b/core/l/Dwoo/Plugins/Functions/PluginCounter.php
deleted file mode 100644
index c5fb721..0000000
--- a/core/l/Dwoo/Plugins/Functions/PluginCounter.php
+++ /dev/null
@@ -1,94 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2016 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.0
- * @date 2016-09-19
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Functions;
-
-use Dwoo\Plugin;
-
-/**
- * Initiates a counter that is incremented every time you call it
- *
- * * name : the counter name, define it if you want to have multiple concurrent counters
- * * start : the start value, if it's set, it will reset the counter to this value, defaults to 1
- * * skip : the value to add to the counter at each call, defaults to 1
- * * direction : "up" (default) or "down" to define whether the counter increments or decrements
- * * print : if false, the counter will not output the current count, defaults to true
- * * assign : if set, the counter is saved into the given variable and does not output anything, overriding the print
- * parameter
- *
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginCounter extends Plugin
-{
- protected $counters = array();
-
- /**
- * @param string $name
- * @param null $start
- * @param null $skip
- * @param null $direction
- * @param null $print
- * @param null $assign
- *
- * @return mixed
- */
- public function process($name = 'default', $start = null, $skip = null, $direction = null, $print = null, $assign = null)
- {
- // init counter
- if (!isset($this->counters[$name])) {
- $this->counters[$name] = array(
- 'count' => $start === null ? 1 : (int)$start,
- 'skip' => $skip === null ? 1 : (int)$skip,
- 'print' => $print === null ? true : (bool)$print,
- 'assign' => $assign === null ? null : (string)$assign,
- 'direction' => strtolower($direction) === 'down' ? - 1 : 1,
- );
- } // increment
- else {
- // override setting if present
- if ($skip !== null) {
- $this->counters[$name]['skip'] = (int)$skip;
- }
-
- if ($direction !== null) {
- $this->counters[$name]['direction'] = strtolower($direction) === 'down' ? - 1 : 1;
- }
-
- if ($print !== null) {
- $this->counters[$name]['print'] = (bool)$print;
- }
-
- if ($assign !== null) {
- $this->counters[$name]['assign'] = (string)$assign;
- }
-
- if ($start !== null) {
- $this->counters[$name]['count'] = (int)$start;
- } else {
- $this->counters[$name]['count'] += ($this->counters[$name]['skip'] * $this->counters[$name]['direction']);
- }
- }
-
- $out = $this->counters[$name]['count'];
-
- if ($this->counters[$name]['assign'] !== null) {
- $this->core->assignInScope($out, $this->counters[$name]['assign']);
- } elseif ($this->counters[$name]['print'] === true) {
- return $out;
- }
- }
-}
diff --git a/core/l/Dwoo/Plugins/Functions/PluginCycle.php b/core/l/Dwoo/Plugins/Functions/PluginCycle.php
deleted file mode 100644
index 3741da4..0000000
--- a/core/l/Dwoo/Plugins/Functions/PluginCycle.php
+++ /dev/null
@@ -1,91 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2017 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.2
- * @date 2017-01-06
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Functions;
-
-use Dwoo\Plugin;
-
-/**
- * Cycles between several values and returns one of them on each call
- *
- * * name : the cycler name, specify if you need to have multiple concurrent cycles running
- * * values : an array of values or a string of values delimited by $delimiter
- * * print : if false, the pointer will go to the next one but not print anything
- * * advance : if false, the pointer will not advance to the next value
- * * delimiter : the delimiter used to split values if they are provided as a string
- * * assign : if set, the value is saved in that variable instead of being output
- * * reset : if true, the pointer is reset to the first value
- *
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginCycle extends Plugin
-{
- protected $cycles = array();
-
- /**
- * @param string $name
- * @param null $values
- * @param bool $print
- * @param bool $advance
- * @param string $delimiter
- * @param null $assign
- * @param bool $reset
- *
- * @return string|null
- */
- public function process($name = 'default', $values = null, $print = true, $advance = true, $delimiter = ',', $assign = null, $reset = false)
- {
- if ($values !== null) {
- if (is_string($values)) {
- $values = explode($delimiter, $values);
- }
-
- if (!isset($this->cycles[$name]) || $this->cycles[$name]['values'] !== $values) {
- $this->cycles[$name]['index'] = 0;
- }
-
- $this->cycles[$name]['values'] = array_values($values);
- } elseif (isset($this->cycles[$name])) {
- $values = $this->cycles[$name]['values'];
- }
-
- if ($reset) {
- $this->cycles[$name]['index'] = 0;
- }
-
- if ($print) {
- $out = $values[$this->cycles[$name]['index']];
- } else {
- $out = null;
- }
-
- if ($advance) {
- if ($this->cycles[$name]['index'] >= count($values) - 1) {
- $this->cycles[$name]['index'] = 0;
- } else {
- ++ $this->cycles[$name]['index'];
- }
- }
-
- if ($assign === null) {
- return $out;
- }
- $this->core->assignInScope($out, $assign);
-
- return null;
- }
-}
diff --git a/core/l/Dwoo/Plugins/Functions/PluginDateFormat.php b/core/l/Dwoo/Plugins/Functions/PluginDateFormat.php
deleted file mode 100644
index c6c5258..0000000
--- a/core/l/Dwoo/Plugins/Functions/PluginDateFormat.php
+++ /dev/null
@@ -1,92 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2017 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.2
- * @date 2017-01-06
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Functions;
-
-use Dwoo\Core;
-use Dwoo\Plugin;
-
-/**
- * Formats a date
- *
- * * value : the date, as a unix timestamp, mysql datetime or whatever strtotime() can parse
- * * format : output format, see {@link http://php.net/strftime} for details
- * * default : a default timestamp value, if the first one is empty
- *
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginDateFormat extends Plugin
-{
- /**
- * @param mixed $value
- * @param string $format
- * @param null $default
- *
- * @return string
- */
- public function process($value, $format = '%b %e, %Y', $default = null)
- {
- if (!empty($value)) {
- // convert if it's not a valid unix timestamp
- if (preg_match('#^-?\d{1,10}$#', $value) === 0) {
- $value = strtotime($value);
- }
- } elseif (!empty($default)) {
- // convert if it's not a valid unix timestamp
- if (preg_match('#^-?\d{1,10}$#', $default) === 0) {
- $value = strtotime($default);
- } else {
- $value = $default;
- }
- } else {
- return '';
- }
-
- // Credits for that windows compat block to Monte Ohrt who made smarty's date_format plugin
- if (DIRECTORY_SEPARATOR == '\\') {
- $_win_from = array(
- '%D',
- '%h',
- '%n',
- '%r',
- '%R',
- '%t',
- '%T'
- );
- $_win_to = array(
- '%m/%d/%y',
- '%b',
- "\n",
- '%I:%M:%S %p',
- '%H:%M',
- "\t",
- '%H:%M:%S'
- );
- if (strpos($format, '%e') !== false) {
- $_win_from[] = '%e';
- $_win_to[] = sprintf('%\' 2d', date('j', $value));
- }
- if (strpos($format, '%l') !== false) {
- $_win_from[] = '%l';
- $_win_to[] = sprintf('%\' 2d', date('h', $value));
- }
- $format = str_replace($_win_from, $_win_to, $format);
- }
-
- return strftime($format, $value);
- }
-}
\ No newline at end of file
diff --git a/core/l/Dwoo/Plugins/Functions/PluginDefault.php b/core/l/Dwoo/Plugins/Functions/PluginDefault.php
deleted file mode 100644
index a9c3076..0000000
--- a/core/l/Dwoo/Plugins/Functions/PluginDefault.php
+++ /dev/null
@@ -1,45 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2017 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.2
- * @date 2017-01-06
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Functions;
-
-use Dwoo\Compiler;
-use Dwoo\ICompilable;
-use Dwoo\Plugin;
-
-/**
- * Returns a variable or a default value if it's empty
- *
- * * value : the variable to check
- * * default : fallback value if the first one is empty
- *
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginDefault extends Plugin implements ICompilable
-{
- /**
- * @param Compiler $compiler
- * @param mixed $value
- * @param string $default
- *
- * @return string
- */
- public static function compile(Compiler $compiler, $value, $default = '')
- {
- return '(($tmp = ' . $value . ')===null||$tmp===\'\' ? ' . $default . ' : $tmp)';
- }
-}
\ No newline at end of file
diff --git a/core/l/Dwoo/Plugins/Functions/PluginDump.php b/core/l/Dwoo/Plugins/Functions/PluginDump.php
deleted file mode 100644
index 09e9afd..0000000
--- a/core/l/Dwoo/Plugins/Functions/PluginDump.php
+++ /dev/null
@@ -1,210 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2017 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.2
- * @date 2017-01-06
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Functions;
-
-use Dwoo\Plugin;
-use Iterator;
-use ReflectionObject;
-
-/**
- * Dumps values of the given variable, or the entire data if nothing provided
- *
- * * var : the variable to display
- * * show_methods : if set to true, the public methods of any object encountered are also displayed
- *
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginDump extends Plugin
-{
- protected $outputObjects;
- protected $outputMethods;
-
- /**
- * @param string $var
- * @param bool $show_methods
- *
- * @return string
- */
- public function process($var = '$', $show_methods = false)
- {
- $this->outputMethods = $show_methods;
- if ($var === '$') {
- $var = $this->core->getData();
- $out = '
';
- }
-}
diff --git a/core/l/Dwoo/Plugins/Functions/PluginEol.php b/core/l/Dwoo/Plugins/Functions/PluginEol.php
deleted file mode 100644
index f4f8504..0000000
--- a/core/l/Dwoo/Plugins/Functions/PluginEol.php
+++ /dev/null
@@ -1,39 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2017 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.2
- * @date 2017-01-06
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Functions;
-
-use Dwoo\Compiler;
-use Dwoo\ICompilable;
-use Dwoo\Plugin;
-
-/**
- * Returns the correct end of line character(s) for the current operating system.
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginEol extends Plugin implements ICompilable
-{
- /**
- * @param Compiler $compiler
- *
- * @return string
- */
- public static function compile(Compiler $compiler)
- {
- return 'PHP_EOL';
- }
-}
diff --git a/core/l/Dwoo/Plugins/Functions/PluginEscape.php b/core/l/Dwoo/Plugins/Functions/PluginEscape.php
deleted file mode 100644
index 1bb8745..0000000
--- a/core/l/Dwoo/Plugins/Functions/PluginEscape.php
+++ /dev/null
@@ -1,103 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2017 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.2
- * @date 2017-01-06
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Functions;
-
-use Dwoo\Plugin;
-
-/**
- * Applies various escaping schemes on the given string
- *
- * * value : the string to process
- * * format : escaping format to use, valid formats are : html, htmlall, url, urlpathinfo, quotes, hex, hexentity,
- * javascript and mail
- * * charset : character set to use for the conversion (applies to some formats only), defaults to the current Dwoo
- * charset
- *
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- *
- * @return mixed|string
- */
-class PluginEscape extends Plugin
-{
- /**
- * @param string $value
- * @param string $format
- * @param null $charset
- *
- * @return mixed|string
- */
- public function process($value = '', $format = 'html', $charset = null)
- {
- if ($charset === null) {
- $charset = $this->core->getCharset();
- }
-
- switch ($format) {
- case 'html':
- return htmlspecialchars((string)$value, ENT_QUOTES, $charset);
- case 'htmlall':
- return htmlentities((string)$value, ENT_QUOTES, $charset);
- case 'url':
- return rawurlencode((string)$value);
- case 'urlpathinfo':
- return str_replace('%2F', '/', rawurlencode((string)$value));
- case 'quotes':
- return preg_replace("#(? '\\\\',
- "'" => "\\'",
- '"' => '\\"',
- "\r" => '\\r',
- "\n" => '\\n',
- '' => '<\/'
- ));
- case 'mail':
- return str_replace(array(
- '@',
- '.'
- ),
- array(
- ' (AT) ',
- ' (DOT) '
- ),
- (string)$value);
- default:
- $this->core->triggerError('Escape\'s format argument must be one of : html, htmlall, url, urlpathinfo, hex, hexentity, javascript, js or mail, "' . $format . '" given.',
- E_USER_WARNING);
- }
- }
-}
\ No newline at end of file
diff --git a/core/l/Dwoo/Plugins/Functions/PluginEval.php b/core/l/Dwoo/Plugins/Functions/PluginEval.php
deleted file mode 100644
index f787c14..0000000
--- a/core/l/Dwoo/Plugins/Functions/PluginEval.php
+++ /dev/null
@@ -1,62 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2017 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.2
- * @date 2017-01-06
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Functions;
-
-use Dwoo\Core;
-use Dwoo\Plugin;
-use Dwoo\Template\Str as TemplateString;
-
-/**
- * Evaluates the given string as if it was a template.
- * Although this plugin is kind of optimized and will
- * not recompile your string each time, it is still not
- * a good practice to use it. If you want to have templates
- * stored in a database or something you should probably use
- * the Dwoo\Template\Str class or make another class that
- * extends it
- *
- * * var : the string to use as a template
- * * assign : if set, the output of the template will be saved in this variable instead of being output
- *
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginEval extends Plugin
-{
- /**
- * @param string $var
- * @param null $assign
- *
- * @return string
- */
- public function process($var, $assign = null)
- {
- if ($var == '') {
- return '';
- }
-
- $tpl = new TemplateString($var);
- $clone = clone $this->core;
- $out = $clone->get($tpl, $this->core->readVar('_parent'));
-
- if ($assign !== null) {
- $this->core->assignInScope($out, $assign);
- } else {
- return $out;
- }
- }
-}
\ No newline at end of file
diff --git a/core/l/Dwoo/Plugins/Functions/PluginExtends.php b/core/l/Dwoo/Plugins/Functions/PluginExtends.php
deleted file mode 100644
index 3ab5f98..0000000
--- a/core/l/Dwoo/Plugins/Functions/PluginExtends.php
+++ /dev/null
@@ -1,206 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2017 David Sanchez
- * @license http://dwoo.org/LICENSE LGPLv3
- * @version 1.3.6
- * @date 2017-03-21
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Functions;
-
-use Dwoo\Compiler;
-use Dwoo\ICompilable;
-use Dwoo\Plugin;
-use Dwoo\Exception as Exception;
-use Dwoo\Security\Exception as SecurityException;
-use Dwoo\Compilation\Exception as CompilationException;
-
-/**
- * Extends another template, read more about template inheritance at {@link
- * http://wiki.dwoo.org/index.php/TemplateInheritance}
- *
- * * file : path or URI of the file to read (however reading from another website is not recommended for performance
- * reasons)
- * * assign : if set, the file will be saved in this variable instead of being output
- *
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginFetch extends Plugin
-{
- /**
- * @param string $file
- * @param null $assign
- *
- * @return string
- */
- public function process($file, $assign = null)
- {
- if ($file === '') {
- return '';
- }
-
- if ($policy = $this->core->getSecurityPolicy()) {
- while (true) {
- if (preg_match('{^([a-z]+?)://}i', $file)) {
- $this->core->triggerError('The security policy prevents you to read files from external sources.',
- E_USER_WARNING);
- }
-
- $file = realpath($file);
- $dirs = $policy->getAllowedDirectories();
- foreach ($dirs as $dir => $dummy) {
- if (strpos($file, $dir) === 0) {
- break 2;
- }
- }
- $this->core->triggerError('The security policy prevents you to read ' . $file . '',
- E_USER_WARNING);
- }
- }
- $file = str_replace(array(
- "\t",
- "\n",
- "\r"
- ),
- array(
- '\\t',
- '\\n',
- '\\r'
- ),
- $file);
-
- $out = file_get_contents($file);
-
- if ($assign === null) {
- return $out;
- }
- $this->core->assignInScope($out, $assign);
- }
-}
\ No newline at end of file
diff --git a/core/l/Dwoo/Plugins/Functions/PluginInclude.php b/core/l/Dwoo/Plugins/Functions/PluginInclude.php
deleted file mode 100644
index ce3a370..0000000
--- a/core/l/Dwoo/Plugins/Functions/PluginInclude.php
+++ /dev/null
@@ -1,110 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2017 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.2
- * @date 2017-01-06
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Functions;
-
-use Dwoo\Exception as Exception;
-use Dwoo\Plugin;
-use Dwoo\Security\Exception as SecurityException;
-
-/**
- * Inserts another template into the current one
- *
- * * file : the resource name of the template
- * * cache_time : cache length in seconds
- * * cache_id : cache identifier for the included template
- * * compile_id : compilation identifier for the included template
- * * data : data to feed into the included template, it can be any array and will default to $_root (the current data)
- * * assign : if set, the output of the included template will be saved in this variable instead of being output
- * * rest : any additional parameter/value provided will be added to the data array
- *
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginInclude extends Plugin
-{
- /**
- * @param $file
- * @param null $cache_time
- * @param null $cache_id
- * @param null $compile_id
- * @param string $data
- * @param null $assign
- * @param array $rest
- *
- * @return string
- */
- public function process($file, $cache_time = null, $cache_id = null, $compile_id = null, $data = '_root', $assign = null, array $rest = array())
- {
- $include = null;
- if ($file === '') {
- return '';
- }
-
- if (preg_match('#^([a-z]{2,}):(.*)$#i', $file, $m)) {
- // resource:identifier given, extract them
- $resource = $m[1];
- $identifier = $m[2];
- } else {
- // get the current template's resource
- $resource = $this->core->getTemplate()->getResourceName();
- $identifier = $file;
- }
-
- try {
- $include = $this->core->templateFactory($resource, $identifier, $cache_time, $cache_id, $compile_id);
- }
- catch (SecurityException $e) {
- $this->core->triggerError('Include : Security restriction : ' . $e->getMessage(), E_USER_WARNING);
- }
- catch (Exception $e) {
- $this->core->triggerError('Include : ' . $e->getMessage(), E_USER_WARNING);
- }
-
- if ($include === null) {
- $this->core->triggerError('Include : Resource "' . $resource . ':' . $identifier . '" not found.',
- E_USER_WARNING);
- } elseif ($include === false) {
- $this->core->triggerError('Include : Resource "' . $resource . '" does not support includes.',
- E_USER_WARNING);
- }
-
- if (is_string($data)) {
- $vars = $this->core->readVar($data);
- } else {
- $vars = $data;
- }
-
- if (count($rest)) {
- $vars = $rest + $vars;
- }
-
- $clone = clone $this->core;
- $out = $clone->get($include, $vars);
-
- if ($assign !== null) {
- $this->core->assignInScope($out, $assign);
- }
-
- foreach ($clone->getReturnValues() as $name => $value) {
- $this->core->assignInScope($value, $name);
- }
-
- if ($assign === null) {
- return $out;
- }
- }
-}
\ No newline at end of file
diff --git a/core/l/Dwoo/Plugins/Functions/PluginIndent.php b/core/l/Dwoo/Plugins/Functions/PluginIndent.php
deleted file mode 100644
index 5d1105e..0000000
--- a/core/l/Dwoo/Plugins/Functions/PluginIndent.php
+++ /dev/null
@@ -1,47 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2017 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.2
- * @date 2017-01-06
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Functions;
-
-use Dwoo\Compiler;
-use Dwoo\ICompilable;
-use Dwoo\Plugin;
-
-/**
- * Indents every line of a text by the given amount of characters
- *
- * * value : the string to indent
- * * by : how many characters should be inserted before each line
- * * char : the character(s) to insert
- *
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginIndent extends Plugin implements ICompilable
-{
- /**
- * @param Compiler $compiler
- * @param string $value
- * @param int $by
- * @param string $char
- *
- * @return string
- */
- public static function compile(Compiler $compiler, $value, $by = 4, $char = ' ')
- {
- return "preg_replace('#^#m', '" . str_repeat(substr($char, 1, - 1), trim($by, '"\'')) . "', $value)";
- }
-}
\ No newline at end of file
diff --git a/core/l/Dwoo/Plugins/Functions/PluginIsset.php b/core/l/Dwoo/Plugins/Functions/PluginIsset.php
deleted file mode 100644
index 756312a..0000000
--- a/core/l/Dwoo/Plugins/Functions/PluginIsset.php
+++ /dev/null
@@ -1,43 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2017 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.2
- * @date 2017-01-06
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Functions;
-
-use Dwoo\Compiler;
-use Dwoo\ICompilable;
-use Dwoo\Plugin;
-
-/**
- * Checks whether a variable is not null
- *
- * * var : variable to check
- *
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginIsset extends Plugin implements ICompilable
-{
- /**
- * @param Compiler $compiler
- * @param mixed $var
- *
- * @return string
- */
- public static function compile(Compiler $compiler, $var)
- {
- return '(' . $var . ' !== null)';
- }
-}
\ No newline at end of file
diff --git a/core/l/Dwoo/Plugins/Functions/PluginLoadTemplates.php b/core/l/Dwoo/Plugins/Functions/PluginLoadTemplates.php
deleted file mode 100644
index 65a2cae..0000000
--- a/core/l/Dwoo/Plugins/Functions/PluginLoadTemplates.php
+++ /dev/null
@@ -1,99 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2017 David Sanchez
- * @license http://dwoo.org/LICENSE LGPLv3
- * @version 1.3.6
- * @date 2017-03-21
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Functions;
-
-use Dwoo\Compiler;
-use Dwoo\Compilation\Exception as CompilationException;
-use Dwoo\ICompilable;
-use Dwoo\Plugin;
-
-/**
- * Loads sub-templates contained in an external file
- *
- * * file : the resource name of the file to load
- *
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginLoadTemplates extends Plugin implements ICompilable
-{
- /**
- * @param Compiler $compiler
- * @param string $file
- *
- * @return string
- * @throws CompilationException
- */
- public static function compile(Compiler $compiler, $file)
- {
- $file = substr($file, 1, - 1);
-
- if ($file === '') {
- return '';
- }
-
- if (preg_match('#^([a-z]{2,}):(.*)$#i', $file, $m)) {
- // resource:identifier given, extract them
- $resource = $m[1];
- $identifier = $m[2];
- } else {
- // get the current template's resource
- $resource = $compiler->getCore()->getTemplate()->getResourceName();
- $identifier = $file;
- }
-
- $tpl = $compiler->getCore()->templateFactory($resource, $identifier);
-
- if ($tpl === null) {
- throw new CompilationException($compiler,
- 'Load Templates : Resource "' . $resource . ':' . $identifier . '" not found.');
- } elseif ($tpl === false) {
- throw new CompilationException($compiler,
- 'Load Templates : Resource "' . $resource . '" does not support includes.');
- }
-
- $cmp = clone $compiler;
- $cmp->compile($compiler->getCore(), $tpl);
- foreach ($cmp->getTemplatePlugins() as $template => $args) {
- $compiler->addTemplatePlugin($template, $args['params'], $args['uuid'], $args['body']);
- }
- foreach ($cmp->getUsedPlugins() as $plugin => $type) {
- $compiler->addUsedPlugin($plugin, $type);
- }
-
- $out = '\'\';// checking for modification in ' . $resource . ':' . $identifier . "\r\n";
-
- $modCheck = $tpl->getIsModifiedCode();
-
- if ($modCheck) {
- $out .= 'if (!(' . $modCheck . ')) { ob_end_clean(); return false; }';
- } else {
- $out .= 'try {
- $tpl = $this->templateFactory("' . $resource . '", "' . $identifier . '");
-} catch (Dwoo\Exception $e) {
- $this->triggerError(\'Load Templates : Resource ' . $resource . ' was not added to Dwoo, can not extend ' . $identifier . '\', E_USER_WARNING);
-}
-if ($tpl === null)
- $this->triggerError(\'Load Templates : Resource "' . $resource . ':' . $identifier . '" was not found.\', E_USER_WARNING);
-elseif ($tpl === false)
- $this->triggerError(\'Load Templates : Resource "' . $resource . '" does not support extends.\', E_USER_WARNING);
-if ($tpl->getUid() != "' . $tpl->getUid() . '") { ob_end_clean(); return false; }';
- }
-
- return $out;
- }
-}
\ No newline at end of file
diff --git a/core/l/Dwoo/Plugins/Functions/PluginLower.php b/core/l/Dwoo/Plugins/Functions/PluginLower.php
deleted file mode 100644
index f729dd1..0000000
--- a/core/l/Dwoo/Plugins/Functions/PluginLower.php
+++ /dev/null
@@ -1,43 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2017 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.2
- * @date 2017-01-06
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Functions;
-
-use Dwoo\Compiler;
-use Dwoo\ICompilable;
-use Dwoo\Plugin;
-
-/**
- * Makes the input string lower cased
- *
- * * value : the string to process
- *
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginLower extends Plugin implements ICompilable
-{
- /**
- * @param Compiler $compiler
- * @param string $value
- *
- * @return string
- */
- public static function compile(Compiler $compiler, $value)
- {
- return 'mb_strtolower((string) ' . $value . ', $this->charset)';
- }
-}
\ No newline at end of file
diff --git a/core/l/Dwoo/Plugins/Functions/PluginMailto.php b/core/l/Dwoo/Plugins/Functions/PluginMailto.php
deleted file mode 100644
index 00fb768..0000000
--- a/core/l/Dwoo/Plugins/Functions/PluginMailto.php
+++ /dev/null
@@ -1,144 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2017 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.2
- * @date 2017-01-06
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Functions;
-
-use Dwoo\Plugin;
-
-/**
- * Outputs a mailto link with optional spam-proof (okay probably not) encoding
- *
- * * address : target email address
- * * text : display text to show for the link, defaults to the address if not provided
- * * subject : the email subject
- * * encode : one of the available encoding (none, js, jscharcode or hex)
- * * cc : address(es) to carbon copy, comma separated
- * * bcc : address(es) to blind carbon copy, comma separated
- * * newsgroups : newsgroup(s) to post to, comma separated
- * * followupto : address(es) to follow up, comma separated
- * * extra : additional attributes to add to the <a> tag
- *
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginMailto extends Plugin
-{
- /**
- * @param $address
- * @param null $text
- * @param null $subject
- * @param null $encode
- * @param null $cc
- * @param null $bcc
- * @param null $newsgroups
- * @param null $followupto
- * @param null $extra
- *
- * @return string
- */
- public function process($address, $text = null, $subject = null, $encode = null, $cc = null, $bcc = null, $newsgroups = null, $followupto = null, $extra = null)
- {
- if (empty($address)) {
- return '';
- }
- if (empty($text)) {
- $text = $address;
- }
-
- // build address string
- $address .= '?';
-
- if (!empty($subject)) {
- $address .= 'subject=' . rawurlencode($subject) . '&';
- }
- if (!empty($cc)) {
- $address .= 'cc=' . rawurlencode($cc) . '&';
- }
- if (!empty($bcc)) {
- $address .= 'bcc=' . rawurlencode($bcc) . '&';
- }
- if (!empty($newsgroups)) {
- $address .= 'newsgroups=' . rawurlencode($newsgroups) . '&';
- }
- if (!empty($followupto)) {
- $address .= 'followupto=' . rawurlencode($followupto) . '&';
- }
-
- $address = rtrim($address, '?&');
-
- // output
- switch ($encode) {
-
- case 'none':
- case null:
- return '' . $text . '';
-
- case 'js':
- case 'javascript':
- $str = 'document.write(\'' . $text . '\');';
- $len = strlen($str);
-
- $out = '';
- for ($i = 0; $i < $len; ++ $i) {
- $out .= '%' . bin2hex($str[$i]);
- }
-
- return '';
-
- break;
- case 'javascript_charcode':
- case 'js_charcode':
- case 'jscharcode':
- case 'jschar':
- $str = '' . $text . '';
- $len = strlen($str);
-
- $out = '\n";
-
- break;
-
- case 'hex':
- if (strpos($address, '?') !== false) {
- $this->core->triggerError('Mailto: Hex encoding is not possible with extra attributes, use one of : js, jscharcode or none.', E_USER_WARNING);
- }
-
- $out = '';
- $len = strlen($text);
- for ($i = 0; $i < $len; ++ $i) {
- $out .= '' . bin2hex($text[$i]);
- }
-
- return $out . '';
-
- default:
- $this->core->triggerError('Mailto: encode argument is invalid, it must be one of : none (= no value), js, js_charcode or hex', E_USER_WARNING);
- }
- }
-}
\ No newline at end of file
diff --git a/core/l/Dwoo/Plugins/Functions/PluginMath.php b/core/l/Dwoo/Plugins/Functions/PluginMath.php
deleted file mode 100644
index 0e93ee4..0000000
--- a/core/l/Dwoo/Plugins/Functions/PluginMath.php
+++ /dev/null
@@ -1,199 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2017 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.2
- * @date 2017-01-06
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Functions;
-
-use Dwoo\Compiler;
-use Dwoo\Compilation\Exception as CompilationException;
-use Dwoo\ICompilable;
-use Dwoo\Plugin;
-
-/**
- * Computes a mathematical equation
- *
- * * equation : the equation to compute, it can include normal variables with $foo or special math variables without
- * the dollar sign
- * * format : output format, see {@link http://php.net/sprintf} for details
- * * assign : if set, the output is assigned into the given variable name instead of being output
- * * rest : all math specific variables that you use must be defined, see the example
- *
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginNl2br extends Plugin implements ICompilable
-{
- /**
- * @param Compiler $compiler
- * @param string $value
- *
- * @return string
- */
- public static function compile(Compiler $compiler, $value)
- {
- return 'nl2br((string) ' . $value . ')';
- }
-}
\ No newline at end of file
diff --git a/core/l/Dwoo/Plugins/Functions/PluginOptional.php b/core/l/Dwoo/Plugins/Functions/PluginOptional.php
deleted file mode 100644
index d9a10b8..0000000
--- a/core/l/Dwoo/Plugins/Functions/PluginOptional.php
+++ /dev/null
@@ -1,43 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2017 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.2
- * @date 2017-01-06
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Functions;
-
-use Dwoo\Compiler;
-use Dwoo\ICompilable;
-use Dwoo\Plugin;
-
-/**
- * Prints out a variable without any notice if it doesn't exist.
- *
- * * value : the variable to print
- *
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginOptional extends Plugin implements ICompilable
-{
- /**
- * @param Compiler $compiler
- * @param string $value
- *
- * @return mixed
- */
- public static function compile(Compiler $compiler, $value)
- {
- return $value;
- }
-}
\ No newline at end of file
diff --git a/core/l/Dwoo/Plugins/Functions/PluginRegexReplace.php b/core/l/Dwoo/Plugins/Functions/PluginRegexReplace.php
deleted file mode 100644
index bfd587f..0000000
--- a/core/l/Dwoo/Plugins/Functions/PluginRegexReplace.php
+++ /dev/null
@@ -1,63 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2017 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.2
- * @date 2017-01-06
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Functions;
-
-use Dwoo\Plugin;
-
-/**
- * Replaces the search string by the replace string using regular expressions
- *
- * * value : the string to search into
- * * search : the string to search for, must be a complete regular expression including delimiters
- * * replace : the string to use as a replacement, must be a complete regular expression including delimiters
- *
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginRegexReplace extends Plugin
-{
- /**
- * @param string $value
- * @param string $search
- * @param string $replace
- *
- * @return mixed
- */
- public function process($value, $search, $replace)
- {
- $search = (array)$search;
- $cnt = count($search);
-
- for ($i = 0; $i < $cnt; ++ $i) {
- // Credits for this to Monte Ohrt who made smarty's regex_replace modifier
- if (($pos = strpos($search[$i], "\0")) !== false) {
- $search[$i] = substr($search[$i], 0, $pos);
- }
-
- if (preg_match('#[a-z\s]+$#is', $search[$i], $m) && (strpos($m[0], 'e') !== false)) {
- $search[$i] = substr($search[$i], 0, - strlen($m[0])) . str_replace(array(
- 'e',
- ' '
- ),
- '',
- $m[0]);
- }
- }
-
- return preg_replace($search, $replace, $value);
- }
-}
\ No newline at end of file
diff --git a/core/l/Dwoo/Plugins/Functions/PluginReplace.php b/core/l/Dwoo/Plugins/Functions/PluginReplace.php
deleted file mode 100644
index b78138e..0000000
--- a/core/l/Dwoo/Plugins/Functions/PluginReplace.php
+++ /dev/null
@@ -1,52 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2017 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.2
- * @date 2017-01-06
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Functions;
-
-use Dwoo\Compiler;
-use Dwoo\ICompilable;
-use Dwoo\Plugin;
-
-/**
- * Replaces the search string by the replace string
- *
- * * value : the string to search into
- * * search : the string to search for
- * * replace : the string to use as a replacement
- *
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginReplace extends Plugin implements ICompilable
-{
- /**
- * @param Compiler $compiler
- * @param string $value
- * @param string $search
- * @param string $replace
- * @param bool $case_sensitive
- *
- * @return string
- */
- public static function compile(Compiler $compiler, $value, $search, $replace, $case_sensitive = true)
- {
- if ($case_sensitive == 'false' || (bool)$case_sensitive === false) {
- return 'str_ireplace(' . $search . ', ' . $replace . ', ' . $value . ')';
- } else {
- return 'str_replace(' . $search . ', ' . $replace . ', ' . $value . ')';
- }
- }
-}
\ No newline at end of file
diff --git a/core/l/Dwoo/Plugins/Functions/PluginReturn.php b/core/l/Dwoo/Plugins/Functions/PluginReturn.php
deleted file mode 100644
index 5026f18..0000000
--- a/core/l/Dwoo/Plugins/Functions/PluginReturn.php
+++ /dev/null
@@ -1,54 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2017 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.2
- * @date 2017-01-06
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Functions;
-
-use Dwoo\Compiler;
-use Dwoo\ICompilable;
-use Dwoo\Plugin;
-
-/**
- * Inserts another template into the current one
- *
- * * file : the resource name of the template
- * * cache_time : cache length in seconds
- * * cache_id : cache identifier for the included template
- * * compile_id : compilation identifier for the included template
- * * data : data to feed into the included template, it can be any array and will default to $_root (the current data)
- * * assign : if set, the output of the included template will be saved in this variable instead of being output
- * * rest : any additional parameter/value provided will be added to the data array
- *
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginReturn extends Plugin implements ICompilable
-{
- /**
- * @param Compiler $compiler
- * @param array $rest
- *
- * @return string
- */
- public static function compile(Compiler $compiler, array $rest = array())
- {
- $out = array();
- foreach ($rest as $var => $val) {
- $out[] = '$this->setReturnValue(' . var_export($var, true) . ', ' . $val . ')';
- }
-
- return '(' . implode('.', $out) . ')';
- }
-}
\ No newline at end of file
diff --git a/core/l/Dwoo/Plugins/Functions/PluginReverse.php b/core/l/Dwoo/Plugins/Functions/PluginReverse.php
deleted file mode 100644
index fc15d69..0000000
--- a/core/l/Dwoo/Plugins/Functions/PluginReverse.php
+++ /dev/null
@@ -1,54 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2017 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.2
- * @date 2017-01-06
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Functions;
-
-use Dwoo\Plugin;
-
-/**
- * Reverses a string or an array
- *
- * * value : the string or array to reverse
- * * preserve_keys : if value is an array and this is true, then the array keys are left intact
- *
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginReverse extends Plugin
-{
- /**
- * @param string $value
- * @param bool $preserve_keys
- *
- * @return array|string
- */
- public function process($value, $preserve_keys = false)
- {
- if (is_array($value)) {
- return array_reverse($value, $preserve_keys);
- } elseif (($charset = $this->core->getCharset()) === 'iso-8859-1') {
- return strrev((string)$value);
- }
-
- $strlen = mb_strlen($value);
- $out = '';
- while ($strlen --) {
- $out .= mb_substr($value, $strlen, 1, $charset);
- }
-
- return $out;
- }
-}
\ No newline at end of file
diff --git a/core/l/Dwoo/Plugins/Functions/PluginSafe.php b/core/l/Dwoo/Plugins/Functions/PluginSafe.php
deleted file mode 100644
index bb4118e..0000000
--- a/core/l/Dwoo/Plugins/Functions/PluginSafe.php
+++ /dev/null
@@ -1,46 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2017 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.2
- * @date 2017-01-06
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Functions;
-
-use Dwoo\Compiler;
-use Dwoo\ICompilable;
-use Dwoo\Plugin;
-
-/**
- * Marks the variable as safe and removes the auto-escape function, only useful if you turned auto-escaping on
- *
- * * var : the variable to pass through untouched
- *
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginSafe extends Plugin implements ICompilable
-{
-
- /**
- * @param Compiler $compiler
- * @param mixed $var
- *
- * @return mixed
- */
- public static function compile(Compiler $compiler, $var)
- {
- return preg_replace('#\(is_string\(\$tmp=(.+)\) \? htmlspecialchars\(\$tmp, ENT_QUOTES, \$this->charset\) : \$tmp\)#',
- '$1',
- $var);
- }
-}
\ No newline at end of file
diff --git a/core/l/Dwoo/Plugins/Functions/PluginSpacify.php b/core/l/Dwoo/Plugins/Functions/PluginSpacify.php
deleted file mode 100644
index 68f069e..0000000
--- a/core/l/Dwoo/Plugins/Functions/PluginSpacify.php
+++ /dev/null
@@ -1,45 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2017 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.2
- * @date 2017-01-06
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Functions;
-
-use Dwoo\Compiler;
-use Dwoo\ICompilable;
-use Dwoo\Plugin;
-
-/**
- * Adds spaces (or the given character(s)) between every character of a string
- *
- * * value : the string to process
- * * space_char : the character(s) to insert between each character
- *
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginSpacify extends Plugin implements ICompilable
-{
- /**
- * @param Compiler $compiler
- * @param string $value
- * @param string $space_char
- *
- * @return string
- */
- public static function compile(Compiler $compiler, $value, $space_char = ' ')
- {
- return 'implode(' . $space_char . ', str_split(' . $value . ', 1))';
- }
-}
\ No newline at end of file
diff --git a/core/l/Dwoo/Plugins/Functions/PluginStringFormat.php b/core/l/Dwoo/Plugins/Functions/PluginStringFormat.php
deleted file mode 100644
index b1e2394..0000000
--- a/core/l/Dwoo/Plugins/Functions/PluginStringFormat.php
+++ /dev/null
@@ -1,45 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2017 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.2
- * @date 2017-01-06
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Functions;
-
-use Dwoo\Compiler;
-use Dwoo\ICompilable;
-use Dwoo\Plugin;
-
-/**
- * Formats a string using the sprintf function
- *
- * * value : the string to format
- * * format : the format to use, see {@link http://php.net/sprintf} for details
- *
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginStringFormat extends Plugin implements ICompilable
-{
- /**
- * @param Compiler $compiler
- * @param string $value
- * @param string $format
- *
- * @return string
- */
- public static function compile(Compiler $compiler, $value, $format)
- {
- return 'sprintf(' . $format . ',' . $value . ')';
- }
-}
\ No newline at end of file
diff --git a/core/l/Dwoo/Plugins/Functions/PluginStripTags.php b/core/l/Dwoo/Plugins/Functions/PluginStripTags.php
deleted file mode 100644
index 37e7e89..0000000
--- a/core/l/Dwoo/Plugins/Functions/PluginStripTags.php
+++ /dev/null
@@ -1,55 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2017 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.3
- * @date 2017-01-07
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Functions;
-
-use Dwoo\Compiler;
-use Dwoo\ICompilable;
-use Dwoo\Plugin;
-
-/**
- * Removes all html tags
- *
- * * value: the string to process
- * * addspace: if true, a space is added in place of every removed tag
- * * allowable_tags: specify tags which should not be stripped
- *
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginStripTags extends Plugin implements ICompilable
-{
- /**
- * @param Compiler $compiler
- * @param string $value
- * @param bool $addspace
- * @param null|string $allowable_tags
- *
- * @return string
- */
- public static function compile(Compiler $compiler, $value, $addspace = true, $allowable_tags = null)
- {
- if ($addspace === 'true') {
- if ("null" == $allowable_tags) {
- return "preg_replace('#<[^>]*>#', ' ', $value)";
- }
-
- return "preg_replace('#<\\s*\\/?(" . $allowable_tags . ")\\s*[^>]*?>#im', ' ', $value)";
- }
-
- return "strip_tags($value, $allowable_tags)";
- }
-}
\ No newline at end of file
diff --git a/core/l/Dwoo/Plugins/Functions/PluginTif.php b/core/l/Dwoo/Plugins/Functions/PluginTif.php
deleted file mode 100644
index 9a876e0..0000000
--- a/core/l/Dwoo/Plugins/Functions/PluginTif.php
+++ /dev/null
@@ -1,105 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2017 David Sanchez
- * @license http://dwoo.org/LICENSE LGPLv3
- * @version 1.3.6
- * @date 2017-03-21
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Functions;
-
-use Dwoo\Compiler;
-use Dwoo\Core;
-use Dwoo\Exception;
-use Dwoo\Compilation\Exception as CompilationException;
-use Dwoo\ICompilable;
-use Dwoo\Plugin;
-use Dwoo\Plugins\Blocks\PluginIf;
-
-/**
- * Ternary if operation.
- * It evaluates the first argument and returns the second if it's true, or the third if it's false
- *
- * * rest : you can not use named parameters to call this, use it either with three arguments in the correct order
- * (expression, true result, false result) or write it as in php (expression ? true result : false result)
- *
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginTif extends Plugin implements ICompilable
-{
- /**
- * @param Compiler $compiler
- * @param array $rest
- * @param array $tokens
- *
- * @return mixed|string
- * @throws CompilationException
- */
- public static function compile(Compiler $compiler, array $rest, array $tokens)
- {
- // load if plugin
- if (!class_exists(Core::NAMESPACE_PLUGINS_BLOCKS . 'PluginIf')) {
- try {
- $compiler->getCore()->getLoader()->loadPlugin('if');
- }
- catch (Exception $e) {
- throw new CompilationException($compiler, 'Tif: the if plugin is required to use Tif');
- }
- }
-
- if (count($rest) == 1) {
- return $rest[0];
- }
-
- // fetch false result and remove the ":" if it was present
- $falseResult = array_pop($rest);
-
- if (trim(end($rest), '"\'') === ':') {
- // remove the ':' if present
- array_pop($rest);
- } elseif (trim(end($rest), '"\'') === '?' || count($rest) === 1) {
- if ($falseResult === '?' || $falseResult === ':') {
- throw new CompilationException($compiler,
- 'Tif: incomplete tif statement, value missing after ' . $falseResult);
- }
- // there was in fact no false result provided, so we move it to be the true result instead
- $trueResult = $falseResult;
- $falseResult = "''";
- }
-
- // fetch true result if needed
- if (!isset($trueResult)) {
- $trueResult = array_pop($rest);
- // no true result provided so we use the expression arg
- if ($trueResult === '?') {
- $trueResult = true;
- }
- }
-
- // remove the '?' if present
- if (trim(end($rest), '"\'') === '?') {
- array_pop($rest);
- }
-
- // check params were correctly provided
- if (empty($rest) || $trueResult === null || $falseResult === null) {
- throw new CompilationException($compiler,
- 'Tif: you must provide three parameters serving as ? : ');
- }
-
- // parse condition
- $condition = PluginIf::replaceKeywords($rest, $tokens, $compiler);
-
- return '((' . implode(' ', $condition) . ') ? ' . ($trueResult === true ? implode(' ',
- $condition) : $trueResult) . ' : ' . $falseResult . ')';
- }
-}
\ No newline at end of file
diff --git a/core/l/Dwoo/Plugins/Functions/PluginTruncate.php b/core/l/Dwoo/Plugins/Functions/PluginTruncate.php
deleted file mode 100644
index c998ea8..0000000
--- a/core/l/Dwoo/Plugins/Functions/PluginTruncate.php
+++ /dev/null
@@ -1,69 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2017 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.2
- * @date 2017-01-06
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Functions;
-
-use Dwoo\Plugin;
-
-/**
- * Truncates a string at the given length
- *
- * * value : text to truncate
- * * length : the maximum length for the string
- * * etc : the characters that are added to show that the string was cut off
- * * break : if true, the string will be cut off at the exact length, instead of cutting at the nearest space
- * * middle : if true, the string will contain the beginning and the end, and the extra characters will be removed
- * from the middle
- *
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginTruncate extends Plugin
-{
- /**
- * @param string $value
- * @param int $length
- * @param string $etc
- * @param bool $break
- * @param bool $middle
- *
- * @return mixed|string
- */
- public function process($value, $length = 80, $etc = '...', $break = false, $middle = false)
- {
- if ($length == 0) {
- return '';
- }
-
- $value = (string)$value;
- $etc = (string)$etc;
- $length = (int)$length;
-
- if (strlen($value) < $length) {
- return $value;
- }
-
- $length = max($length - strlen($etc), 0);
- if ($break === false && $middle === false) {
- $value = preg_replace('#\s+(\S*)?$#', '', substr($value, 0, $length + 1));
- }
- if ($middle === false) {
- return substr($value, 0, $length) . $etc;
- }
-
- return substr($value, 0, ceil($length / 2)) . $etc . substr($value, - floor($length / 2));
- }
-}
\ No newline at end of file
diff --git a/core/l/Dwoo/Plugins/Functions/PluginUpper.php b/core/l/Dwoo/Plugins/Functions/PluginUpper.php
deleted file mode 100644
index c85f0b1..0000000
--- a/core/l/Dwoo/Plugins/Functions/PluginUpper.php
+++ /dev/null
@@ -1,43 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2017 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.2
- * @date 2017-01-06
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Functions;
-
-use Dwoo\Compiler;
-use Dwoo\ICompilable;
-use Dwoo\Plugin;
-
-/**
- * Makes a string uppercased
- *
- * * value : the text to uppercase
- *
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginUpper extends Plugin implements ICompilable
-{
- /**
- * @param Compiler $compiler
- * @param string $value
- *
- * @return string
- */
- public static function compile(Compiler $compiler, $value)
- {
- return 'mb_strtoupper((string) ' . $value . ', $this->charset)';
- }
-}
\ No newline at end of file
diff --git a/core/l/Dwoo/Plugins/Functions/PluginWhitespace.php b/core/l/Dwoo/Plugins/Functions/PluginWhitespace.php
deleted file mode 100644
index c30fd33..0000000
--- a/core/l/Dwoo/Plugins/Functions/PluginWhitespace.php
+++ /dev/null
@@ -1,53 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2017 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.2
- * @date 2017-01-06
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Functions;
-
-use Dwoo\Block\Plugin;
-use Dwoo\Compiler;
-use Dwoo\ICompilable;
-
-/**
- * Replaces all white-space characters with the given string
- *
- * * value : the text to process
- * * with : the replacement string, note that any number of consecutive white-space characters will be replaced by a
- * single replacement string
- *
- * Example :.
- *
- * {"a b c d
- *
- * e"|whitespace}
- * results in : a b c d e
- *
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginWhitespace extends Plugin implements ICompilable
-{
- /**
- * @param Compiler $compiler
- * @param string $value
- * @param string $with
- *
- * @return string
- */
- public static function compile(Compiler $compiler, $value, $with = ' ')
- {
- return "preg_replace('#\s+#'.(strcasecmp(\$this->charset, 'utf-8')===0?'u':''), $with, $value)";
- }
-}
\ No newline at end of file
diff --git a/core/l/Dwoo/Plugins/Functions/PluginWordwrap.php b/core/l/Dwoo/Plugins/Functions/PluginWordwrap.php
deleted file mode 100644
index 83d884d..0000000
--- a/core/l/Dwoo/Plugins/Functions/PluginWordwrap.php
+++ /dev/null
@@ -1,49 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2017 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.2
- * @date 2017-01-06
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Functions;
-
-use Dwoo\Compiler;
-use Dwoo\ICompilable;
-use Dwoo\Plugin;
-
-/**
- * Wraps a text at the given line length
- *
- * * value : the text to wrap
- * * length : maximum line length
- * * break : the character(s) to use to break the line
- * * cut : if true, the line is cut at the exact length instead of breaking at the nearest space
- *
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginWordwrap extends Plugin implements ICompilable
-{
- /**
- * @param Compiler $compiler
- * @param string $value
- * @param int $length
- * @param string $break
- * @param bool $cut
- *
- * @return string
- */
- public static function compile(Compiler $compiler, $value, $length = 80, $break = "\n", $cut = false)
- {
- return 'wordwrap(' . $value . ',' . $length . ',' . $break . ',' . $cut . ')';
- }
-}
\ No newline at end of file
diff --git a/core/l/Dwoo/Plugins/Helpers/PluginArray.php b/core/l/Dwoo/Plugins/Helpers/PluginArray.php
deleted file mode 100644
index 838e65f..0000000
--- a/core/l/Dwoo/Plugins/Helpers/PluginArray.php
+++ /dev/null
@@ -1,56 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2017 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.2
- * @date 2017-01-06
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Helpers;
-
-use Dwoo\Compiler;
-use Dwoo\ICompilable;
-use Dwoo\Plugin;
-
-/**
- * Builds an array with all the provided variables, use named parameters to make an associative array
- *
- * * rest : any number of variables, strings or anything that you want to store in the array
- *
- * Example :
- *
- * {array(a, b, c)} results in array(0=>'a', 1=>'b', 2=>'c')
- * {array(a=foo, b=5, c=array(4,5))} results in array('a'=>'foo', 'b'=>5, 'c'=>array(0=>4, 1=>5))
- *
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginArray extends Plugin implements ICompilable
-{
- /**
- * @param Compiler $compiler
- * @param array $rest
- *
- * @return string
- */
- public static function compile(Compiler $compiler, array $rest = array())
- {
- $out = array();
- foreach ($rest as $key => $value) {
- if (!is_numeric($key) && !strstr($key, '$this->scope')) {
- $key = "'" . $key . "'";
- }
- $out[] = $key . '=>' . $value;
- }
-
- return 'array(' . implode(', ', $out) . ')';
- }
-}
\ No newline at end of file
diff --git a/core/l/Dwoo/Plugins/Processors/PluginSmartyCompatible.php b/core/l/Dwoo/Plugins/Processors/PluginSmartyCompatible.php
deleted file mode 100644
index 5b82219..0000000
--- a/core/l/Dwoo/Plugins/Processors/PluginSmartyCompatible.php
+++ /dev/null
@@ -1,94 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2016 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.0
- * @date 2016-09-18
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Plugins\Processors;
-
-use Dwoo\Processor;
-
-/**
- * Performs some template conversions to allow smarty templates to be used by
- * the Dwoo compiler.
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class PluginSmartyCompatible extends Processor
-{
- /**
- * @param string $input
- *
- * @return mixed
- */
- public function process($input)
- {
- list($l, $r) = $this->compiler->getDelimiters();
-
- $rl = preg_quote($l, '/');
- $rr = preg_quote($r, '/');
- $sectionParam = '(?:(name|loop|start|step|max|show)\s*=\s*(\S+))?\s*';
- $input = preg_replace_callback('/' . $rl . '\s*section ' . str_repeat($sectionParam, 6) . '\s*' . $rr . '(.+?)(?:' . $rl . '\s*sectionelse\s*' . $rr . '(.+?))?' . $rl . '\s*\/section\s*' . $rr . '/is', array(
- $this,
- 'convertSection'
- ), $input);
- $input = str_replace('$smarty.section.', '$smarty.for.', $input);
-
- $smarty = array(
- '/' . $rl . '\s*ldelim\s*' . $rr . '/',
- '/' . $rl . '\s*rdelim\s*' . $rr . '/',
- '/' . $rl . '\s*\$smarty\.ldelim\s*' . $rr . '/',
- '/' . $rl . '\s*\$smarty\.rdelim\s*' . $rr . '/',
- '/\$smarty\./',
- '/' . $rl . '\s*php\s*' . $rr . '/',
- '/' . $rl . '\s*\/php\s*' . $rr . '/',
- '/\|(@?)strip(\||' . $rr . ')/',
- '/' . $rl . '\s*sectionelse\s*' . $rr . '/',
- );
-
- $dwoo = array(
- '\\' . $l,
- $r,
- '\\' . $l,
- $r,
- '$dwoo.',
- '',
- '|$1whitespace$2',
- $l . 'else' . $r,
- );
-
- if (preg_match('{\|@([a-z][a-z0-9_]*)}i', $input, $matches)) {
- trigger_error('The Smarty Compatibility Module has detected that you use |@' . $matches[1] . ' in your template, this might lead to problems as Dwoo interprets the @ operator differently than Smarty, see http://wiki.dwoo.org/index.php/Syntax#The_.40_Operator', E_USER_NOTICE);
- }
-
- return preg_replace($smarty, $dwoo, $input);
- }
-
- /**
- * @param array $matches
- *
- * @return mixed
- */
- protected function convertSection(array $matches)
- {
- $params = array();
- $index = 1;
- while (!empty($matches[$index]) && $index < 13) {
- $params[$matches[$index]] = $matches[$index + 1];
- $index += 2;
- }
-
- return str_replace('[' . trim($params['name'], '"\'') . ']', '[$' . trim($params['name'], '"\'') . ']', $matches[0]);
- }
-}
diff --git a/core/l/Dwoo/Processor.php b/core/l/Dwoo/Processor.php
deleted file mode 100644
index f1941bf..0000000
--- a/core/l/Dwoo/Processor.php
+++ /dev/null
@@ -1,52 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2016 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.0
- * @date 2016-09-23
- * @link http://dwoo.org/
- */
-
-namespace Dwoo;
-
-/**
- * Base class for processors.
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-abstract class Processor
-{
- /**
- * The compiler instance that runs this processor.
- *
- * @var Core
- */
- protected $compiler;
-
- /**
- * Constructor, if you override it, call parent::__construct($compiler); or assign
- * the dwoo instance yourself if you need it.
- *
- * @param Compiler $compiler the compiler class
- */
- public function __construct(Compiler $compiler)
- {
- $this->compiler = $compiler;
- }
-
- /**
- * Processes the input and returns it filtered.
- *
- * @param string $input the template to process
- *
- * @return string
- */
- abstract public function process($input);
-}
diff --git a/core/l/Dwoo/Security/Exception.php b/core/l/Dwoo/Security/Exception.php
deleted file mode 100644
index 075f6a6..0000000
--- a/core/l/Dwoo/Security/Exception.php
+++ /dev/null
@@ -1,28 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2016 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.0
- * @date 2016-09-19
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Security;
-
-use Dwoo\Exception as DwooException;
-
-/**
- * Dwoo security exception class.
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class Exception extends DwooException
-{
-}
diff --git a/core/l/Dwoo/Security/Policy.php b/core/l/Dwoo/Security/Policy.php
deleted file mode 100644
index 3752537..0000000
--- a/core/l/Dwoo/Security/Policy.php
+++ /dev/null
@@ -1,322 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2016 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.0
- * @date 2016-09-23
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Security;
-
-use Dwoo\Core;
-
-/**
- * Represents the security settings of a dwoo instance, it can be passed around to different dwoo instances.
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class Policy
-{
- /**
- * Php handling constants, defaults to PHP_REMOVE
- * PHP_ENCODE : run htmlentities over them
- * PHP_REMOVE : remove all (+ short tags if your short tags option is on) from the input template
- * PHP_ALLOW : leave them as they are
- *
- * @var int
- */
- const PHP_ENCODE = 1;
- const PHP_REMOVE = 2;
- const PHP_ALLOW = 3;
-
- /**
- * Constant handling constants, defaults to CONST_DISALLOW
- * CONST_DISALLOW : throw an error if {$dwoo.const.*} is used in the template
- * CONST_ALLOW : allow {$dwoo.const.*} calls
- */
- const CONST_DISALLOW = false;
- const CONST_ALLOW = true;
-
- /**
- * Php functions that are allowed to be used within the template.
- *
- * @var array
- */
- protected $allowedPhpFunctions = array(
- 'str_repeat' => true,
- 'number_format' => true,
- 'htmlentities' => true,
- 'htmlspecialchars' => true,
- 'long2ip' => true,
- 'strlen' => true,
- 'list' => true,
- 'empty' => true,
- 'count' => true,
- 'sizeof' => true,
- 'in_array' => true,
- 'is_array' => true,
- );
-
- /**
- * Methods that are allowed to be used within the template.
- *
- * @var array
- */
- protected $allowedMethods = array();
-
- /**
- * Paths that are safe to use with include or other file-access plugins.
- *
- * @var array
- */
- protected $allowedDirectories = array();
-
- /**
- * Stores the php handling level.
- * defaults to self::PHP_REMOVE
- *
- * @var int
- */
- protected $phpHandling = self::PHP_REMOVE;
-
- /**
- * Stores the constant handling level.
- * defaults to self::CONST_DISALLOW
- *
- * @var bool
- */
- protected $constHandling = self::CONST_DISALLOW;
-
- /**
- * Adds a php function to the allowed list.
- *
- * @param mixed $func function name or array of function names
- */
- public function allowPhpFunction($func)
- {
- if (is_array($func)) {
- foreach ($func as $fname) {
- $this->allowedPhpFunctions[strtolower($fname)] = true;
- }
- } else {
- $this->allowedPhpFunctions[strtolower($func)] = true;
- }
- }
-
- /**
- * Removes a php function from the allowed list.
- *
- * @param mixed $func function name or array of function names
- */
- public function disallowPhpFunction($func)
- {
- if (is_array($func)) {
- foreach ($func as $fname) {
- unset($this->allowedPhpFunctions[strtolower($fname)]);
- }
- } else {
- unset($this->allowedPhpFunctions[strtolower($func)]);
- }
- }
-
- /**
- * Returns the list of php functions allowed to run, note that the function names
- * are stored in the array keys and not values.
- *
- * @return array
- */
- public function getAllowedPhpFunctions()
- {
- return $this->allowedPhpFunctions;
- }
-
- /**
- * Adds a class method to the allowed list, this must be used for
- * both static and non static method by providing the class name
- * and method name to use.
- *
- * @param mixed $class class name or array of array('class', 'method') couples
- * @param string $method method name
- */
- public function allowMethod($class, $method = null)
- {
- if (is_array($class)) {
- foreach ($class as $elem) {
- $this->allowedMethods[strtolower($elem[0])][strtolower($elem[1])] = true;
- }
- } else {
- $this->allowedMethods[strtolower($class)][strtolower($method)] = true;
- }
- }
-
- /**
- * Removes a class method from the allowed list.
- *
- * @param mixed $class class name or array of array('class', 'method') couples
- * @param string $method method name
- */
- public function disallowMethod($class, $method = null)
- {
- if (is_array($class)) {
- foreach ($class as $elem) {
- unset($this->allowedMethods[strtolower($elem[0])][strtolower($elem[1])]);
- }
- } else {
- unset($this->allowedMethods[strtolower($class)][strtolower($method)]);
- }
- }
-
- /**
- * Returns the list of class methods allowed to run, note that the class names
- * and method names are stored in the array keys and not values.
- *
- * @return array
- */
- public function getAllowedMethods()
- {
- return $this->allowedMethods;
- }
-
- /**
- * Adds a directory to the safelist for includes and other file-access plugins.
- * note that all the includePath directories you provide to the Dwoo_Template_File class
- * are automatically marked as safe
- *
- * @param mixed $path a path name or an array of paths
- */
- public function allowDirectory($path)
- {
- if (is_array($path)) {
- foreach ($path as $dir) {
- $this->allowedDirectories[realpath($dir)] = true;
- }
- } else {
- $this->allowedDirectories[realpath($path)] = true;
- }
- }
-
- /**
- * Removes a directory from the safe list.
- *
- * @param mixed $path a path name or an array of paths
- */
- public function disallowDirectory($path)
- {
- if (is_array($path)) {
- foreach ($path as $dir) {
- unset($this->allowedDirectories[realpath($dir)]);
- }
- } else {
- unset($this->allowedDirectories[realpath($path)]);
- }
- }
-
- /**
- * Returns the list of safe paths, note that the paths are stored in the array
- * keys and not values.
- *
- * @return array
- */
- public function getAllowedDirectories()
- {
- return $this->allowedDirectories;
- }
-
- /**
- * Sets the php handling level, defaults to REMOVE.
- *
- * @param int $level one of the Dwoo_Security_Policy::PHP_* constants
- */
- public function setPhpHandling($level = self::PHP_REMOVE)
- {
- $this->phpHandling = $level;
- }
-
- /**
- * Returns the php handling level.
- *
- * @return int the current level, one of the Dwoo_Security_Policy::PHP_* constants
- */
- public function getPhpHandling()
- {
- return $this->phpHandling;
- }
-
- /**
- * Sets the constant handling level, defaults to CONST_DISALLOW.
- *
- * @param bool $level one of the Dwoo_Security_Policy::CONST_* constants
- */
- public function setConstantHandling($level = self::CONST_DISALLOW)
- {
- $this->constHandling = $level;
- }
-
- /**
- * Returns the constant handling level.
- *
- * @return bool the current level, one of the Dwoo_Security_Policy::CONST_* constants
- */
- public function getConstantHandling()
- {
- return $this->constHandling;
- }
-
- /**
- * This is used at run time to check whether method calls are allowed or not.
- *
- * @param Core $dwoo dwoo instance that calls this
- * @param object $obj any object on which the method must be called
- * @param string $method lowercased method name
- * @param array $args arguments array
- *
- * @return mixed result of method call or unll + E_USER_NOTICE if not allowed
- */
- public function callMethod(Core $dwoo, $obj, $method, $args)
- {
- foreach ($this->allowedMethods as $class => $methods) {
- if (!isset($methods[$method])) {
- continue;
- }
- if ($obj instanceof $class) {
- return call_user_func_array(array($obj, $method), $args);
- }
- }
- $dwoo->triggerError('The current security policy prevents you from calling ' . get_class($obj) . '::' . $method . '()');
-
- return null;
- }
-
- /**
- * This is used at compile time to check whether static method calls are allowed or not.
- *
- * @param mixed $class lowercased class name or array('class', 'method') couple
- * @param string $method lowercased method name
- *
- * @return bool
- */
- public function isMethodAllowed($class, $method = null)
- {
- if (is_array($class)) {
- list($class, $method) = $class;
- }
- foreach ($this->allowedMethods as $allowedClass => $methods) {
- if (!isset($methods[$method])) {
- continue;
- }
- if ($class === $allowedClass || is_subclass_of($class, $allowedClass)) {
- return true;
- }
- }
-
- return false;
- }
-}
diff --git a/core/l/Dwoo/Smarty/Adapter.php b/core/l/Dwoo/Smarty/Adapter.php
deleted file mode 100644
index ff85160..0000000
--- a/core/l/Dwoo/Smarty/Adapter.php
+++ /dev/null
@@ -1,698 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2016 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.0
- * @date 2016-09-23
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Smarty;
-
-use Dwoo\Core;
-use Dwoo\Compiler;
-use Dwoo\Data;
-use Dwoo\Security\Policy as SecurityPolicy;
-use Dwoo\Exception as Exception;
-use Dwoo\Template\File as TemplateFile;
-use Dwoo\Smarty\Filter\Adapter as FilterAdapter;
-use Dwoo\Smarty\Processor\Adapter as ProcessorAdapter;
-
-if (!defined('DIR_SEP')) {
- define('DIR_SEP', DIRECTORY_SEPARATOR);
-}
-
-if (!defined('SMARTY_PHP_PASSTHRU')) {
- define('SMARTY_PHP_PASSTHRU', 0);
- define('SMARTY_PHP_QUOTE', 1);
- define('SMARTY_PHP_REMOVE', 2);
- define('SMARTY_PHP_ALLOW', 3);
-}
-
-/**
- * A Smarty compatibility layer for Dwoo.
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class Adapter extends Core
-{
- /**
- * Magic get/set/call functions that handle unsupported features
- *
- * @param string $p
- * @param string $v
- */
- public function __set($p, $v)
- {
- if ($p === 'scope') {
- $this->scope = $v;
-
- return;
- }
- if ($p === 'data') {
- $this->data = $v;
-
- return;
- }
- if (array_key_exists($p, $this->compat['properties']) !== false) {
- if ($this->show_compat_errors) {
- $this->triggerError('Property ' . $p . ' is not available in the Dwoo\Smarty\Adapter, however it might be implemented in the future, check out http://wiki.dwoo.org/index.php/SmartySupport for more details.', E_USER_NOTICE);
- }
- $this->compat['properties'][$p] = $v;
- } else {
- if ($this->show_compat_errors) {
- $this->triggerError('Property ' . $p . ' is not available in the Dwoo\Smarty\Adapter, but it is not listed as such, so you might want to tell me about it at j.boggiano@seld.be', E_USER_NOTICE);
- }
- }
- }
-
- /**
- * @param $p
- *
- * @return mixed
- */
- public function __get($p)
- {
- if (array_key_exists($p, $this->compat['properties']) !== false) {
- if ($this->show_compat_errors) {
- $this->triggerError('Property ' . $p . ' is not available in the Dwoo\Smarty\Adapter, however it might be implemented in the future, check out http://wiki.dwoo.org/index.php/SmartySupport for more details.', E_USER_NOTICE);
- }
-
- return $this->compat['properties'][$p];
- } else {
- if ($this->show_compat_errors) {
- $this->triggerError('Property ' . $p . ' is not available in the Dwoo\Smarty\Adapter, but it is not listed as such, so you might want to tell me about it at j.boggiano@seld.be', E_USER_NOTICE);
- }
- }
- }
-
- /**
- * @param string $m
- * @param array $a
- *
- * @return mixed|void
- */
- public function __call($m, $a)
- {
- if (method_exists($this->dataProvider, $m)) {
- call_user_func_array(
- array(
- $this->dataProvider,
- $m
- ), $a
- );
- } elseif ($this->show_compat_errors) {
- if (array_search($m, $this->compat['methods']) !== false) {
- $this->triggerError('Method ' . $m . ' is not available in the Dwoo\Smarty\Adapter, however it might be implemented in the future, check out http://wiki.dwoo.org/index.php/SmartySupport for more details.', E_USER_NOTICE);
- } else {
- $this->triggerError('Method ' . $m . ' is not available in the Dwoo\Smarty\Adapter, but it is not listed as such, so you might want to tell me about it at j.boggiano@seld.be', E_USER_NOTICE);
- }
- }
- }
-
- /**
- * List of unsupported properties and methods
- */
- protected $compat = array(
- 'methods' => array(
- 'register_resource',
- 'unregister_resource',
- 'load_filter',
- 'clear_compiled_tpl',
- 'clear_config',
- 'get_config_vars',
- 'config_load',
- ),
- 'properties' => array(
- 'cache_handler_func' => null,
- 'debugging' => false,
- 'error_reporting' => null,
- 'debugging_ctrl' => 'NONE',
- 'request_vars_order' => 'EGPCS',
- 'request_use_auto_globals' => true,
- 'use_sub_dirs' => false,
- 'autoload_filters' => array(),
- 'default_template_handler_func' => '',
- 'debug_tpl' => '',
- 'cache_modified_check' => false,
- 'default_modifiers' => array(),
- 'default_resource_type' => 'file',
- 'config_overwrite' => true,
- 'config_booleanize' => true,
- 'config_read_hidden' => false,
- 'config_fix_newlines' => true,
- 'config_class' => 'Config_File',
- ),
- );
-
- /**
- * Security vars
- */
- public $security = false;
- public $trusted_dir = array();
- public $secure_dir = array();
- public $php_handling = SMARTY_PHP_PASSTHRU;
- public $security_settings = array(
- 'PHP_HANDLING' => false,
- 'IF_FUNCS' => array(
- 'list',
- 'empty',
- 'count',
- 'sizeof',
- 'in_array',
- 'is_array',
- ),
- 'INCLUDE_ANY' => false,
- 'PHP_TAGS' => false,
- 'MODIFIER_FUNCS' => array(),
- 'ALLOW_CONSTANTS' => false,
- );
-
- /**
- * Paths
- */
- public $template_dir = 'templates';
- public $compile_dir = 'templates_c';
- public $config_dir = 'configs';
- public $cache_dir = 'cache';
- public $plugins_dir = array();
-
- /**
- * Misc options
- */
- public $left_delimiter = '{';
- public $right_delimiter = '}';
- public $compile_check = true;
- public $force_compile = false;
- public $caching = 0;
- public $cache_lifetime = 3600;
- public $compile_id = null;
- public $compiler_file = null;
- public $compiler_class = null;
-
- /**
- * Dwoo/Smarty compat layer
- */
- public $show_compat_errors = false;
- protected $dataProvider;
- protected $_filters = array(
- 'pre' => array(),
- 'post' => array(),
- 'output' => array()
- );
- protected static $tplCache = array();
- protected $compiler = null;
-
- /**
- * Adapter constructor.
- */
- public function __construct()
- {
- parent::__construct();
- $this->charset = 'iso-8859-1';
- $this->dataProvider = new Data();
- $this->compiler = new Compiler();
- }
-
- /**
- * @param $filename
- * @param null $cacheId
- * @param null $compileId
- */
- public function display($filename, $cacheId = null, $compileId = null)
- {
- $this->fetch($filename, $cacheId, $compileId, true);
- }
-
- /**
- * @param $filename
- * @param null $cacheId
- * @param null $compileId
- * @param bool $display
- *
- * @return string|void
- */
- public function fetch($filename, $cacheId = null, $compileId = null, $display = false)
- {
- $this->setCacheDir($this->cache_dir);
- $this->setCompileDir($this->compile_dir);
-
- if ($this->security) {
- $policy = new SecurityPolicy();
- $policy->addPhpFunction(array_merge($this->security_settings['IF_FUNCS'], $this->security_settings['MODIFIER_FUNCS']));
-
- $phpTags = $this->security_settings['PHP_HANDLING'] ? SMARTY_PHP_ALLOW : $this->php_handling;
- if ($this->security_settings['PHP_TAGS']) {
- $phpTags = SMARTY_PHP_ALLOW;
- }
- switch ($phpTags) {
- case SMARTY_PHP_ALLOW:
- case SMARTY_PHP_PASSTHRU:
- $phpTags = SecurityPolicy::PHP_ALLOW;
- break;
- case SMARTY_PHP_QUOTE:
- $phpTags = SecurityPolicy::PHP_ENCODE;
- break;
- case SMARTY_PHP_REMOVE:
- default:
- $phpTags = SecurityPolicy::PHP_REMOVE;
- break;
- }
- $policy->setPhpHandling($phpTags);
-
- $policy->setConstantHandling($this->security_settings['ALLOW_CONSTANTS']);
-
- if ($this->security_settings['INCLUDE_ANY']) {
- $policy->allowDirectory(preg_replace('{^((?:[a-z]:)?[\\\\/]).*}i', '$1', __FILE__));
- } else {
- $policy->allowDirectory($this->secure_dir);
- }
-
- $this->setSecurityPolicy($policy);
- }
-
- if (!empty($this->plugins_dir)) {
- foreach ($this->plugins_dir as $dir) {
- $this->getLoader()->addDirectory(rtrim($dir, '\\/'));
- }
- }
-
- $tpl = $this->makeTemplate($filename, $cacheId, $compileId);
- if ($this->force_compile) {
- $tpl->forceCompilation();
- }
-
- if ($this->caching > 0) {
- $this->cacheTime = $this->cache_lifetime;
- } else {
- $this->cacheTime = 0;
- }
-
- if ($this->compiler_class !== null) {
- if ($this->compiler_file !== null && !class_exists($this->compiler_class)) {
- include $this->compiler_file;
- }
- $this->compiler = new $this->compiler_class();
- } else {
- $this->compiler->addPreProcessor('PluginSmartyCompatible', true);
- $this->compiler->setLooseOpeningHandling(true);
- }
-
- $this->compiler->setDelimiters($this->left_delimiter, $this->right_delimiter);
-
- return $this->get($tpl, $this->dataProvider, $this->compiler, $display === true);
- }
-
- /**
- * @param mixed $_tpl
- * @param array $data
- * @param null $_compiler
- * @param bool $_output
- *
- * @return string|void
- */
- public function get($_tpl, $data = array(), $_compiler = null, $_output = false)
- {
- if ($_compiler === null) {
- $_compiler = $this->compiler;
- }
-
- return parent::get($_tpl, $data, $_compiler, $_output);
- }
-
- /**
- * @param $name
- * @param $callback
- * @param bool $cacheable
- * @param null $cache_attrs
- *
- * @throws Exception
- */
- public function register_function($name, $callback, $cacheable = true, $cache_attrs = null)
- {
- if (isset($this->plugins[$name]) && $this->plugins[$name][0] !== self::SMARTY_FUNCTION) {
- throw new Exception('Multiple plugins of different types can not share the same name');
- }
- $this->plugins[$name] = array(
- 'type' => self::SMARTY_FUNCTION,
- 'callback' => $callback
- );
- }
-
- /**
- * @param $name
- */
- public function unregister_function($name)
- {
- unset($this->plugins[$name]);
- }
-
- /**
- * @param $name
- * @param $callback
- * @param bool $cacheable
- * @param null $cache_attrs
- *
- * @throws Exception
- */
- public function register_block($name, $callback, $cacheable = true, $cache_attrs = null)
- {
- if (isset($this->plugins[$name]) && $this->plugins[$name][0] !== self::SMARTY_BLOCK) {
- throw new Exception('Multiple plugins of different types can not share the same name');
- }
- $this->plugins[$name] = array(
- 'type' => self::SMARTY_BLOCK,
- 'callback' => $callback
- );
- }
-
- /**
- * @param $name
- */
- public function unregister_block($name)
- {
- unset($this->plugins[$name]);
- }
-
- /**
- * @param $name
- * @param $callback
- *
- * @throws Exception
- */
- public function register_modifier($name, $callback)
- {
- if (isset($this->plugins[$name]) && $this->plugins[$name][0] !== self::SMARTY_MODIFIER) {
- throw new Exception('Multiple plugins of different types can not share the same name');
- }
- $this->plugins[$name] = array(
- 'type' => self::SMARTY_MODIFIER,
- 'callback' => $callback
- );
- }
-
- /**
- * @param $name
- */
- public function unregister_modifier($name)
- {
- unset($this->plugins[$name]);
- }
-
- /**
- * @param $callback
- */
- public function register_prefilter($callback)
- {
- $processor = new ProcessorAdapter($this->compiler);
- $processor->registerCallback($callback);
- $this->_filters['pre'][] = $processor;
- $this->compiler->addPreProcessor($processor);
- }
-
- /**
- * @param $callback
- */
- public function unregister_prefilter($callback)
- {
- foreach ($this->_filters['pre'] as $index => $processor) {
- if ($processor->callback === $callback) {
- $this->compiler->removePostProcessor($processor);
- unset($this->_filters['pre'][$index]);
- }
- }
- }
-
- /**
- * @param $callback
- */
- public function register_postfilter($callback)
- {
- $processor = new ProcessorAdapter($this->compiler);
- $processor->registerCallback($callback);
- $this->_filters['post'][] = $processor;
- $this->compiler->addPostProcessor($processor);
- }
-
- /**
- * @param $callback
- */
- public function unregister_postfilter($callback)
- {
- foreach ($this->_filters['post'] as $index => $processor) {
- if ($processor->callback === $callback) {
- $this->compiler->removePostProcessor($processor);
- unset($this->_filters['post'][$index]);
- }
- }
- }
-
- /**
- * @param $callback
- */
- public function register_outputfilter($callback)
- {
- $filter = new FilterAdapter($this);
- $filter->registerCallback($callback);
- $this->_filters['output'][] = $filter;
- $this->addFilter($filter);
- }
-
- /**
- * @param $callback
- */
- public function unregister_outputfilter($callback)
- {
- foreach ($this->_filters['output'] as $index => $filter) {
- if ($filter->callback === $callback) {
- $this->removeOutputFilter($filter);
- unset($this->_filters['output'][$index]);
- }
- }
- }
-
- /**
- * @param $object
- * @param $object_impl
- * @param array $allowed
- * @param bool $smarty_args
- * @param array $block_methods
- */
- public function register_object($object, $object_impl, $allowed = array(), $smarty_args = false, $block_methods = array())
- {
- settype($allowed, 'array');
- settype($block_methods, 'array');
- settype($smarty_args, 'boolean');
-
- if (!empty($allowed) && $this->show_compat_errors) {
- $this->triggerError('You can register objects but can not restrict the method/properties used, this is PHP5, you have proper OOP access restrictions so use them.', E_USER_NOTICE);
- }
-
- if ($smarty_args) {
- $this->triggerError('You can register objects but methods will be called using method($arg1, $arg2, $arg3), not as an argument array like smarty did.', E_USER_NOTICE);
- }
-
- if (!empty($block_methods)) {
- $this->triggerError('You can register objects but can not use methods as being block methods, you have to build a plugin for that.', E_USER_NOTICE);
- }
-
- $this->dataProvider->assign($object, $object_impl);
- }
-
- /**
- * @param $object
- */
- public function unregister_object($object)
- {
- $this->dataProvider->clear($object);
- }
-
- /**
- * @param $name
- *
- * @return mixed
- */
- public function get_registered_object($name)
- {
- $data = $this->dataProvider->getData();
- if (isset($data[$name]) && is_object($data[$name])) {
- return $data[$name];
- } else {
- trigger_error('Dwoo_Compiler: object "' . $name . '" was not registered or is not an object', E_USER_ERROR);
- }
- }
-
- /**
- * @param $filename
- *
- * @return bool
- */
- public function template_exists($filename)
- {
- if (!is_array($this->template_dir)) {
- return file_exists($this->template_dir . DIRECTORY_SEPARATOR . $filename);
- } else {
- foreach ($this->template_dir as $tpl_dir) {
- if (file_exists($tpl_dir . DIRECTORY_SEPARATOR . $filename)) {
- return true;
- }
- }
-
- return false;
- }
- }
-
- /**
- * @param $tpl
- * @param null $cacheId
- * @param null $compileId
- *
- * @return bool
- */
- public function is_cached($tpl, $cacheId = null, $compileId = null)
- {
- return $this->isCached($this->makeTemplate($tpl, $cacheId, $compileId));
- }
-
- /**
- * @param $var
- * @param $value
- * @param bool $merge
- */
- public function append_by_ref($var, &$value, $merge = false)
- {
- $this->dataProvider->appendByRef($var, $value, $merge);
- }
-
- /**
- * @param $name
- * @param $val
- */
- public function assign_by_ref($name, &$val)
- {
- $this->dataProvider->assignByRef($name, $val);
- }
-
- /**
- * @param $var
- */
- public function clear_assign($var)
- {
- $this->dataProvider->clear($var);
- }
-
- /**
- *
- */
- public function clear_all_assign()
- {
- $this->dataProvider->clear();
- }
-
- /**
- * @param null $name
- *
- * @return array|null
- */
- public function get_template_vars($name = null)
- {
- if ($this->show_compat_errors) {
- trigger_error('get_template_vars does not return values by reference, if you try to modify the data that way you should modify your code.', E_USER_NOTICE);
- }
-
- $data = $this->dataProvider->getData();
- if ($name === null) {
- return $data;
- } elseif (isset($data[$name])) {
- return $data[$name];
- }
-
- return null;
- }
-
- /**
- * @param int $olderThan
- */
- public function clear_all_cache($olderThan = 0)
- {
- $this->clearCache($olderThan);
- }
-
- /**
- * @param $template
- * @param null $cacheId
- * @param null $compileId
- * @param int $olderThan
- */
- public function clear_cache($template, $cacheId = null, $compileId = null, $olderThan = 0)
- {
- $this->makeTemplate($template, $cacheId, $compileId)->clearCache($olderThan);
- }
-
- /**
- * @param $error_msg
- * @param int $error_type
- */
- public function trigger_error($error_msg, $error_type = E_USER_WARNING)
- {
- $this->triggerError($error_msg, $error_type);
- }
-
- /**
- *
- */
- protected function initGlobals()
- {
- parent::initGlobals();
- $this->globals['ldelim'] = '{';
- $this->globals['rdelim'] = '}';
- }
-
- /**
- * @param $file
- * @param $cacheId
- * @param $compileId
- *
- * @return mixed
- * @throws Exception
- */
- protected function makeTemplate($file, $cacheId, $compileId)
- {
- if ($compileId === null) {
- $compileId = $this->compile_id;
- }
-
- $hash = bin2hex(md5($file . $cacheId . $compileId, true));
- if (!isset(self::$tplCache[$hash])) {
- // abs path
- if (substr($file, 0, 1) === '/' || substr($file, 1, 1) === ':') {
- self::$tplCache[$hash] = new TemplateFile($file, null, $cacheId, $compileId);
- } elseif (is_string($this->template_dir) || is_array($this->template_dir)) {
- self::$tplCache[$hash] = new TemplateFile($file, null, $cacheId, $compileId, $this->template_dir);
- } else {
- throw new Exception('Unable to load "' . $file . '", check the template_dir');
- }
- }
-
- return self::$tplCache[$hash];
- }
-
- /**
- * @param string $message
- * @param int $level
- */
- public function triggerError($message, $level = E_USER_NOTICE)
- {
- if (is_object($this->template)) {
- parent::triggerError($message, $level);
- }
- trigger_error('Dwoo error : ' . $message, $level);
- }
-}
diff --git a/core/l/Dwoo/Smarty/Filter/Adapter.php b/core/l/Dwoo/Smarty/Filter/Adapter.php
deleted file mode 100644
index 9fa52fd..0000000
--- a/core/l/Dwoo/Smarty/Filter/Adapter.php
+++ /dev/null
@@ -1,45 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2016 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.0
- * @date 2016-09-23
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Smarty\Filter;
-
-use Dwoo\Filter;
-
-/**
- * Class Adapter
- */
-class Adapter extends Filter
-{
- public $callback;
-
- /**
- * @param string $input
- *
- * @return mixed
- */
- public function process($input)
- {
- return call_user_func($this->callback, $input);
- }
-
- /**
- * @param $callback
- */
- public function registerCallback($callback)
- {
- $this->callback = $callback;
- }
-}
\ No newline at end of file
diff --git a/core/l/Dwoo/Smarty/Processor/Adapter.php b/core/l/Dwoo/Smarty/Processor/Adapter.php
deleted file mode 100644
index 2510091..0000000
--- a/core/l/Dwoo/Smarty/Processor/Adapter.php
+++ /dev/null
@@ -1,45 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2016 David Sanchez
- * @license http://dwoo.org/LICENSE Modified BSD License
- * @version 1.3.0
- * @date 2016-09-23
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Smarty\Processor;
-
-use Dwoo\Processor;
-
-/**
- * Class Adapter
- */
-class Adapter extends Processor
-{
- public $callback;
-
- /**
- * @param string $input
- *
- * @return mixed
- */
- public function process($input)
- {
- return call_user_func($this->callback, $input);
- }
-
- /**
- * @param $callback
- */
- public function registerCallback($callback)
- {
- $this->callback = $callback;
- }
-}
\ No newline at end of file
diff --git a/core/l/Dwoo/Template/File.php b/core/l/Dwoo/Template/File.php
deleted file mode 100644
index 186466d..0000000
--- a/core/l/Dwoo/Template/File.php
+++ /dev/null
@@ -1,276 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2017 David Sanchez
- * @license http://dwoo.org/LICENSE LGPLv3
- * @version 1.4.0
- * @date 2017-03-16
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Template;
-
-use Dwoo\Exception as DwooException;
-use Dwoo\Core as Core;
-use Dwoo\ICompiler;
-use Dwoo\ITemplate as ITemplate;
-use Dwoo\Security\Exception as SecurityException;
-use Dwoo\Template\File as TemplateFile;
-
-/**
- * Represents a Dwoo template contained in a file.
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class File extends Str
-{
- /**
- * Template filename.
- *
- * @var string
- */
- protected $file;
-
- /**
- * Include path(s) to look into to find this template.
- *
- * @var array
- */
- protected $includePath = array();
-
- /**
- * Resolved path cache when looking for a file in multiple include paths.
- * this is reset when the include path is changed
- *
- * @var string
- */
- protected $resolvedPath = null;
-
- /**
- * Creates a template from a file.
- *
- * @param string $file the path to the template file, make sure it exists
- * @param int $cacheTime duration of the cache validity for this template,
- * if null it defaults to the Dwoo instance that will
- * render this template
- * @param string $cacheId the unique cache identifier of this page or anything else that
- * makes this template's content unique, if null it defaults
- * to the current url
- * @param string $compileId the unique compiled identifier, which is used to distinguish this
- * template from others, if null it defaults to the filename+bits of the path
- * @param mixed $includePath a string for a single path to look into for the given file, or an array of paths
- */
- public function __construct($file, $cacheTime = null, $cacheId = null, $compileId = null, $includePath = array())
- {
- parent::__construct($file, $cacheTime, $cacheId, $compileId);
- $this->template = null;
- $this->file = $file;
- $this->name = basename($file);
- $this->setIncludePath($includePath);
- $this->compileId = $this->getResourceIdentifier();
- }
-
- /**
- * Sets the include path(s) to where the given template filename must be looked up.
- *
- * @param mixed $paths the path to look into, can be string for a single path or an array of paths
- */
- public function setIncludePath($paths)
- {
- if (is_array($paths) === false) {
- $paths = array($paths);
- }
-
- $this->includePath = $paths;
- $this->resolvedPath = null;
- }
-
- /**
- * Return the current include path(s).
- *
- * @return array
- */
- public function getIncludePath()
- {
- return $this->includePath;
- }
-
- /**
- * Checks if compiled file is valid (exists and it's the modification is greater or
- * equal to the modification time of the template file).
- *
- * @param string file
- *
- * @return bool True cache file existance and it's modification time
- */
- protected function isValidCompiledFile($file)
- {
- return parent::isValidCompiledFile($file) && (int)$this->getUid() <= filemtime($file);
- }
-
- /**
- * Returns the template source of this template.
- *
- * @return string
- */
- public function getSource()
- {
- return file_get_contents($this->getResourceIdentifier());
- }
-
- /**
- * Returns the resource name for this template class.
- *
- * @return string
- */
- public function getResourceName()
- {
- return 'file';
- }
-
- /**
- * Returns this template's source filename.
- *
- * @return string
- * @throws DwooException
- */
- public function getResourceIdentifier()
- {
- if ($this->resolvedPath !== null) {
- return $this->resolvedPath;
- } elseif (array_filter($this->getIncludePath()) == array()) {
- return $this->file;
- } else {
- foreach ($this->getIncludePath() as $path) {
- $path = rtrim($path, DIRECTORY_SEPARATOR);
- if (file_exists($path . DIRECTORY_SEPARATOR . $this->file) === true) {
- return $this->resolvedPath = $path . DIRECTORY_SEPARATOR . $this->file;
- }
- }
-
- throw new DwooException('Template "' . $this->file . '" could not be found in any of your include path(s)');
- }
- }
-
- /**
- * Returns an unique value identifying the current version of this template,
- * in this case it's the unix timestamp of the last modification.
- *
- * @return string
- */
- public function getUid()
- {
- return (string)filemtime($this->getResourceIdentifier());
- }
-
- /**
- * Returns a new template object from the given include name, null if no include is
- * possible (resource not found), or false if include is not permitted by this resource type.
- *
- * @param Core $core the dwoo instance requiring it
- * @param mixed $resourceId the filename (relative to this template's dir) of the template to
- * include
- * @param int $cacheTime duration of the cache validity for this template, if null it defaults
- * to the Dwoo instance that will render this template if null it
- * defaults to the Dwoo instance that will render this template if null
- * it defaults to the Dwoo instance that will render this template
- * @param string $cacheId the unique cache identifier of this page or anything else that makes
- * this template's content unique, if null it defaults to the current
- * url makes this template's content unique, if null it defaults to the
- * current url makes this template's content unique, if null it defaults
- * to the current url
- * @param string $compileId the unique compiled identifier, which is used to distinguish this
- * template from others, if null it defaults to the filename+bits of the
- * path template from others, if null it defaults to the filename+bits
- * of the path template from others, if null it defaults to the
- * filename+bits of the path
- * @param ITemplate $parentTemplate the template that is requesting a new template object (through an
- * include, extends or any other plugin) an include, extends or any
- * other plugin) an include, extends or any other plugin)
- *
- * @return TemplateFile|null
- * @throws DwooException
- * @throws SecurityException
- */
- public static function templateFactory(Core $core, $resourceId, $cacheTime = null, $cacheId = null,
- $compileId = null, ITemplate $parentTemplate = null)
- {
- if (DIRECTORY_SEPARATOR === '\\') {
- $resourceId = str_replace(array("\t", "\n", "\r", "\f", "\v"), array(
- '\\t',
- '\\n',
- '\\r',
- '\\f',
- '\\v'
- ), $resourceId);
- }
- $resourceId = strtr($resourceId, '\\', '/');
-
- $includePath = null;
-
- if (file_exists($resourceId) === false) {
- if ($parentTemplate === null) {
- $parentTemplate = $core->getTemplate();
- }
- if ($parentTemplate instanceof self) {
- if ($includePath = $parentTemplate->getIncludePath()) {
- if (strstr($resourceId, '../')) {
- throw new DwooException('When using an include path you can not reference a template into a parent directory (using ../)');
- }
- } else {
- $resourceId = dirname($parentTemplate->getResourceIdentifier()) . DIRECTORY_SEPARATOR . $resourceId;
- if (file_exists($resourceId) === false) {
- return null;
- }
- }
- } else {
- return null;
- }
- }
-
- if ($policy = $core->getSecurityPolicy()) {
- while (true) {
- if (preg_match('{^([a-z]+?)://}i', $resourceId)) {
- throw new SecurityException('The security policy prevents you to read files from external sources : ' . $resourceId . '.');
- }
-
- if ($includePath) {
- break;
- }
-
- $resourceId = realpath($resourceId);
- $dirs = $policy->getAllowedDirectories();
- foreach ($dirs as $dir => $dummy) {
- if (strpos($resourceId, $dir) === 0) {
- break 2;
- }
- }
- throw new SecurityException('The security policy prevents you to read ' . $resourceId . '');
- }
- }
-
- $class = 'Dwoo\Template\File';
- if ($parentTemplate) {
- $class = get_class($parentTemplate);
- }
-
- return new $class($resourceId, $cacheTime, $cacheId, $compileId, $includePath);
- }
-
- /**
- * Returns some php code that will check if this template has been modified or not.
- * if the function returns null, the template will be instanciated and then the Uid checked
- *
- * @return string
- */
- public function getIsModifiedCode()
- {
- return '"' . $this->getUid() . '" == filemtime(' . var_export($this->getResourceIdentifier(), true) . ')';
- }
-}
diff --git a/core/l/Dwoo/Template/Str.php b/core/l/Dwoo/Template/Str.php
deleted file mode 100644
index ab81e31..0000000
--- a/core/l/Dwoo/Template/Str.php
+++ /dev/null
@@ -1,535 +0,0 @@
-
- * @author David Sanchez
- * @copyright 2008-2013 Jordi Boggiano
- * @copyright 2013-2017 David Sanchez
- * @license http://dwoo.org/LICENSE LGPLv3
- * @version 1.4.0
- * @date 2017-03-16
- * @link http://dwoo.org/
- */
-
-namespace Dwoo\Template;
-
-use Dwoo\Core;
-use Dwoo\Compiler;
-use Dwoo\ITemplate;
-use Dwoo\ICompiler;
-use Dwoo\Exception;
-
-/**
- * Represents a Dwoo template contained in a string.
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising from the use of this software.
- */
-class Str implements ITemplate
-{
- /**
- * Template name.
- *
- * @var string
- */
- protected $name;
-
- /**
- * Template compilation id.
- *
- * @var string
- */
- protected $compileId;
-
- /**
- * Template cache id, if not provided in the constructor, it is set to
- * the md4 hash of the request_uri. it is however highly recommended to
- * provide one that will fit your needs.
- * in all cases, the compilation id is prepended to the cache id to separate
- * templates with similar cache ids from one another
- *
- * @var string
- */
- protected $cacheId;
-
- /**
- * Validity duration of the generated cache file (in seconds).
- * set to -1 for infinite cache, 0 to disable and null to inherit the Dwoo instance's cache time
- *
- * @var int
- */
- protected $cacheTime;
-
- /**
- * Boolean flag that defines whether the compilation should be enforced (once) or
- * not use this if you have issues with the compiled templates not being updated
- * but if you do need this it's most likely that you should file a bug report.
- *
- * @var bool
- */
- protected $compilationEnforced;
-
- /**
- * Caches the results of the file checks to save some time when the same
- * templates is rendered several times.
- *
- * @var array
- */
- protected static $cache = array(
- 'cached' => array(),
- 'compiled' => array()
- );
-
- /**
- * Holds the compiler that built this template.
- *
- * @var ICompiler
- */
- protected $compiler;
-
- /**
- * Chmod value for all files written (cached or compiled ones).
- * set to null if you don't want any chmod operation to happen
- *
- * @var int
- */
- protected $chmod = 0777;
-
- /**
- * Containing template string.
- *
- * @var string
- */
- protected $template;
-
- /**
- * Creates a template from a string.
- *
- * @param string $templateString the template to use
- * @param int $cacheTime duration of the cache validity for this template,
- * if null it defaults to the Dwoo instance that will
- * render this template, set to -1 for infinite cache or 0 to disable
- * @param string $cacheId the unique cache identifier of this page or anything else that
- * makes this template's content unique, if null it defaults
- * to the current url
- * @param string $compileId the unique compiled identifier, which is used to distinguish this
- * template from others, if null it defaults to the md4 hash of the template
- */
- public function __construct($templateString, $cacheTime = null, $cacheId = null, $compileId = null)
- {
- $this->template = $templateString;
- $this->name = hash('md4', $templateString);
- $this->cacheTime = $cacheTime;
-
- if ($compileId !== null) {
- $this->compileId = str_replace('../', '__', strtr($compileId, '\\%?=!:;' . PATH_SEPARATOR, '/-------'));
- } else {
- $this->compileId = $templateString;
- }
-
- if ($cacheId !== null) {
- $this->cacheId = str_replace('../', '__', strtr($cacheId, '\\%?=!:;' . PATH_SEPARATOR, '/-------'));
- }
- }
-
- /**
- * Returns the cache duration for this template.
- * defaults to null if it was not provided
- *
- * @return int|null
- */
- public function getCacheTime()
- {
- return $this->cacheTime;
- }
-
- /**
- * Sets the cache duration for this template.
- * can be used to set it after the object is created if you did not provide
- * it in the constructor
- *
- * @param int $seconds duration of the cache validity for this template, if
- * null it defaults to the Dwoo instance's cache time. 0 = disable and
- * -1 = infinite cache
- */
- public function setCacheTime($seconds = null)
- {
- $this->cacheTime = $seconds;
- }
-
- /**
- * Returns the chmod value for all files written (cached or compiled ones).
- * defaults to 0777
- *
- * @return int|null
- */
- public function getChmod()
- {
- return $this->chmod;
- }
-
- /**
- * Set the chmod value for all files written (cached or compiled ones).
- * set to null if you don't want to do any chmod() operation
- *
- * @param int $mask new bitmask to use for all files
- */
- public function setChmod($mask = null)
- {
- $this->chmod = $mask;
- }
-
- /**
- * Returns the template name.
- *
- * @return string
- */
- public function getName()
- {
- return $this->name;
- }
-
- /**
- * Returns the resource name for this template class.
- *
- * @return string
- */
- public function getResourceName()
- {
- return 'string';
- }
-
- /**
- * Returns the resource identifier for this template, false here as strings don't have identifiers.
- *
- * @return false
- */
- public function getResourceIdentifier()
- {
- return false;
- }
-
- /**
- * Returns the template source of this template.
- *
- * @return string
- */
- public function getSource()
- {
- return $this->template;
- }
-
- /**
- * Returns an unique value identifying the current version of this template,
- * in this case it's the md4 hash of the content.
- *
- * @return string
- */
- public function getUid()
- {
- return $this->name;
- }
-
- /**
- * Returns the compiler used by this template, if it was just compiled, or null.
- *
- * @return ICompiler
- */
- public function getCompiler()
- {
- return $this->compiler;
- }
-
- /**
- * Marks this template as compile-forced, which means it will be recompiled even if it
- * was already saved and wasn't modified since the last compilation. do not use this in production,
- * it's only meant to be used in development (and the development of dwoo particularly).
- */
- public function forceCompilation()
- {
- $this->compilationEnforced = true;
- }
-
- /**
- * Returns the cached template output file name, true if it's cache-able but not cached
- * or false if it's not cached.
- *
- * @param Core $core the dwoo instance that requests it
- *
- * @return string|bool
- */
- public function getCachedTemplate(Core $core)
- {
- $cacheLength = $core->getCacheTime();
- if ($this->cacheTime !== null) {
- $cacheLength = $this->cacheTime;
- }
-
- // file is not cacheable
- if ($cacheLength == 0) {
- return false;
- }
-
- $cachedFile = $this->getCacheFilename($core);
-
- if (isset(self::$cache['cached'][$this->cacheId]) === true && file_exists($cachedFile)) {
- // already checked, return cache file
- return $cachedFile;
- } elseif ($this->compilationEnforced !== true && file_exists($cachedFile) && ($cacheLength === - 1 || filemtime($cachedFile) > ($_SERVER['REQUEST_TIME'] - $cacheLength)) && $this->isValidCompiledFile($this->getCompiledFilename($core))) {
- // cache is still valid and can be loaded
- self::$cache['cached'][$this->cacheId] = true;
-
- return $cachedFile;
- }
-
- // file is cacheable
- return true;
- }
-
- /**
- * Caches the provided output into the cache file.
- *
- * @param Core $core the dwoo instance that requests it
- * @param string $output the template output
- *
- * @return mixed full path of the cached file or false upon failure
- */
- public function cache(Core $core, $output)
- {
- $cacheDir = $core->getCacheDir();
- $cachedFile = $this->getCacheFilename($core);
-
- // the code below is courtesy of Rasmus Schultz,
- // thanks for his help on avoiding concurency issues
- $temp = tempnam($cacheDir, 'temp');
- if (!($file = @fopen($temp, 'wb'))) {
- $temp = $cacheDir . uniqid('temp');
- if (!($file = @fopen($temp, 'wb'))) {
- trigger_error('Error writing temporary file \'' . $temp . '\'', E_USER_WARNING);
-
- return false;
- }
- }
-
- fwrite($file, $output);
- fclose($file);
-
- $this->makeDirectory(dirname($cachedFile), $cacheDir);
- if (!@rename($temp, $cachedFile)) {
- @unlink($cachedFile);
- @rename($temp, $cachedFile);
- }
-
- if ($this->chmod !== null) {
- chmod($cachedFile, $this->chmod);
- }
-
- self::$cache['cached'][$this->cacheId] = true;
-
- return $cachedFile;
- }
-
- /**
- * Clears the cached template if it's older than the given time.
- *
- * @param Core $core the dwoo instance that was used to cache that template
- * @param int $olderThan minimum time (in seconds) required for the cache to be cleared
- *
- * @return bool true if the cache was not present or if it was deleted, false if it remains there
- */
- public function clearCache(Core $core, $olderThan = - 1)
- {
- $cachedFile = $this->getCacheFilename($core);
-
- return !file_exists($cachedFile) || (filectime($cachedFile) < (time() - $olderThan) && unlink($cachedFile));
- }
-
- /**
- * Returns the compiled template file name.
- *
- * @param Core $core the dwoo instance that requests it
- * @param ICompiler $compiler the compiler that must be used
- *
- * @return string
- */
- public function getCompiledTemplate(Core $core, ICompiler $compiler = null)
- {
- $compiledFile = $this->getCompiledFilename($core);
-
- if ($this->compilationEnforced !== true && isset(self::$cache['compiled'][$this->compileId]) === true) {
- // already checked, return compiled file
- } elseif ($this->compilationEnforced !== true && $this->isValidCompiledFile($compiledFile)) {
- // template is compiled
- self::$cache['compiled'][$this->compileId] = true;
- } else {
- // compiles the template
- $this->compilationEnforced = false;
-
- if ($compiler === null) {
- $compiler = $core->getDefaultCompilerFactory($this->getResourceName());
-
- if ($compiler === null || $compiler === array('Dwoo\Compiler', 'compilerFactory')) {
- $compiler = Compiler::compilerFactory();
- } else {
- $compiler = call_user_func($compiler);
- }
- }
-
- $this->compiler = $compiler;
-
- $compiler->setCustomPlugins($core->getCustomPlugins());
- $compiler->setSecurityPolicy($core->getSecurityPolicy());
- $this->makeDirectory(dirname($compiledFile), $core->getCompileDir());
- file_put_contents($compiledFile, $compiler->compile($core, $this));
- if ($this->chmod !== null) {
- chmod($compiledFile, $this->chmod);
- }
-
- if (extension_loaded('Zend OPcache')) {
- opcache_invalidate($compiledFile);
- } elseif (extension_loaded('apc') && ini_get('apc.enabled')) {
- apc_delete_file($compiledFile);
- }
-
- self::$cache['compiled'][$this->compileId] = true;
- }
-
- return $compiledFile;
- }
-
- /**
- * Checks if compiled file is valid (it exists).
- *
- * @param string $file
- *
- * @return bool True cache file existence
- */
- protected function isValidCompiledFile($file)
- {
- return file_exists($file);
- }
-
- /**
- * Returns a new template string object with the resource id being the template source code.
- *
- * @param Core $core the dwoo instance requiring it
- * @param mixed $resourceId the filename (relative to this template's dir) of the template to include
- * @param int $cacheTime duration of the cache validity for this template, if null it defaults to the
- * Dwoo instance that will render this template if null it defaults to the Dwoo
- * instance that will render this template
- * @param string $cacheId the unique cache identifier of this page or anything else that makes this
- * template's content unique, if null it defaults to the current url makes this
- * template's content unique, if null it defaults to the current url
- * @param string $compileId the unique compiled identifier, which is used to distinguish this template from
- * others, if null it defaults to the filename+bits of the path template from
- * others, if null it defaults to the filename+bits of the path
- * @param ITemplate $parentTemplate the template that is requesting a new template object (through an include,
- * extends or any other plugin) an include, extends or any other plugin)
- *
- * @return $this
- */
- public static function templateFactory(Core $core, $resourceId, $cacheTime = null, $cacheId = null,
- $compileId = null, ITemplate $parentTemplate = null)
- {
- return new self($resourceId, $cacheTime, $cacheId, $compileId);
- }
-
- /**
- * Returns the full compiled file name and assigns a default value to it if
- * required.
- *
- * @param Core $core the Core instance that requests the file name
- *
- * @return string the full path to the compiled file
- */
- protected function getCompiledFilename(Core $core)
- {
- return $core->getCompileDir() . hash('md4', $this->compileId) . '.d' . Core::RELEASE_TAG . '.php';
- }
-
- /**
- * Returns the full cached file name and assigns a default value to it if
- * required.
- *
- * @param Core $core the dwoo instance that requests the file name
- *
- * @return string the full path to the cached file
- */
- protected function getCacheFilename(Core $core)
- {
- // no cache id provided, use request_uri as default
- if ($this->cacheId === null) {
- if (isset($_SERVER['REQUEST_URI']) === true) {
- $cacheId = $_SERVER['REQUEST_URI'];
- } elseif (isset($_SERVER['SCRIPT_FILENAME']) && isset($_SERVER['argv'])) {
- $cacheId = $_SERVER['SCRIPT_FILENAME'] . '-' . implode('-', $_SERVER['argv']);
- } else {
- $cacheId = '';
- }
- // force compiled id generation
- $this->getCompiledFilename($core);
-
- $this->cacheId = str_replace('../', '__',
- $this->compileId . strtr($cacheId, '\\%?=!:;' . PATH_SEPARATOR, '/-------'));
- }
-
- return $core->getCacheDir() . $this->cacheId . '.html';
- }
-
- /**
- * Returns some php code that will check if this template has been modified or not.
- * if the function returns null, the template will be instanciated and then the Uid checked
- *
- * @return string
- */
- public function getIsModifiedCode()
- {
- return null;
- }
-
- /**
- * Ensures the given path exists.
- *
- * @param string $path any path
- * @param string $baseDir the base directory where the directory is created
- * ($path must still contain the full path, $baseDir
- * is only used for unix permissions)
- *
- * @throws Exception
- */
- protected function makeDirectory($path, $baseDir = null)
- {
- if (is_dir($path) === true) {
- return;
- }
-
- if ($this->chmod === null) {
- $chmod = 0777;
- } else {
- $chmod = $this->chmod;
- }
-
- $retries = 3;
- while ($retries --) {
- @mkdir($path, $chmod, true);
- if (is_dir($path)) {
- break;
- }
- usleep(20);
- }
-
- // enforce the correct mode for all directories created
- if (strpos(PHP_OS, 'WIN') !== 0 && $baseDir !== null) {
- $path = strtr(str_replace($baseDir, '', $path), '\\', '/');
- $folders = explode('/', trim($path, '/'));
- foreach ($folders as $folder) {
- $baseDir .= $folder . DIRECTORY_SEPARATOR;
- if (!chmod($baseDir, $chmod)) {
- throw new Exception('Unable to chmod ' . "$baseDir to $chmod: " . print_r(error_get_last(), true));
- }
- }
- }
- }
-}
diff --git a/core/l/PHPMailer/.gitattributes b/core/l/PHPMailer/.gitattributes
deleted file mode 100755
index afb556f..0000000
--- a/core/l/PHPMailer/.gitattributes
+++ /dev/null
@@ -1,17 +0,0 @@
-* text=auto
-
-/.gitattributes export-ignore
-/.github export-ignore
-/.gitignore export-ignore
-/.phan export-ignore
-/.php_cs export-ignore
-/.scrutinizer.yml export-ignore
-/.travis.yml export-ignore
-/changelog.md export-ignore
-/composer.json export-ignore
-/docs export-ignore
-/examples export-ignore
-/phpdoc.dist.xml export-ignore
-/test export-ignore
-/travis.phpunit.xml.dist export-ignore
-/UPGRADING.md export-ignore
diff --git a/core/l/PHPMailer/.github/ISSUE_TEMPLATE.md b/core/l/PHPMailer/.github/ISSUE_TEMPLATE.md
deleted file mode 100755
index f970c10..0000000
--- a/core/l/PHPMailer/.github/ISSUE_TEMPLATE.md
+++ /dev/null
@@ -1,13 +0,0 @@
-Please check these things before submitting your issue:
-
-- [ ] Make sure you're using the latest version of PHPMailer
-- [ ] Check that your problem is not dealt with in [the troubleshooting guide](https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting), especially if you're having problems connecting to Gmail or GoDaddy
-- [ ] Include sufficient code to reproduce your problem
-- [ ] If you're having an SMTP issue, include the debug output generated with `SMTPDebug = 2` set
-- [ ] If you have a question about how to use PHPMailer (rather than reporting a bug in it), tag a question on Stack Overflow with `phpmailer`, but [**search first**](http://stackoverflow.com/questions/tagged/phpmailer)!
-
-# Problem description
-
-# Code to reproduce
-
-# Debug output
diff --git a/core/l/PHPMailer/.github/PULL_REQUEST_TEMPLATE.md b/core/l/PHPMailer/.github/PULL_REQUEST_TEMPLATE.md
deleted file mode 100755
index e0bbfd5..0000000
--- a/core/l/PHPMailer/.github/PULL_REQUEST_TEMPLATE.md
+++ /dev/null
@@ -1,6 +0,0 @@
-Before submitting your pull request, check whether your code adheres to PHPMailer
-coding standards by running the following command:
-
-`./vendor/bin/php-cs-fixer --diff --dry-run --verbose fix `
-
-And committing eventual changes. It's important that this command uses the specific version of php-cs-fixer configured for PHPMailer, so run `composer install` within the PHPMailer folder to use the exact version it needs.
diff --git a/core/l/PHPMailer/.gitignore b/core/l/PHPMailer/.gitignore
deleted file mode 100755
index 33110b4..0000000
--- a/core/l/PHPMailer/.gitignore
+++ /dev/null
@@ -1,9 +0,0 @@
-docs/*
-!docs/README.md
-test/message.txt
-test/testbootstrap.php
-build/
-vendor/
-*.pem
-composer.lock
-.php_cs.cache
diff --git a/core/l/PHPMailer/.phan/config.php b/core/l/PHPMailer/.phan/config.php
deleted file mode 100755
index 785e9df..0000000
--- a/core/l/PHPMailer/.phan/config.php
+++ /dev/null
@@ -1,41 +0,0 @@
- [
- 'src',
- 'vendor',
- 'examples'
- ],
-
- // A directory list that defines files that will be excluded
- // from static analysis, but whose class and method
- // information should be included.
- //
- // Generally, you'll want to include the directories for
- // third-party code (such as "vendor/") in this list.
- //
- // n.b.: If you'd like to parse but not analyze 3rd
- // party code, directories containing that code
- // should be added to the `directory_list` as
- // to `exclude_analysis_directory_list`.
- "exclude_analysis_directory_list" => [
- 'vendor/'
- ],
-
- 'skip_slow_php_options_warning' => true,
-
- 'exclude_file_regex' => '@^vendor/.*/(tests|Tests)/@',
-];
diff --git a/core/l/PHPMailer/.php_cs b/core/l/PHPMailer/.php_cs
deleted file mode 100755
index 446014f..0000000
--- a/core/l/PHPMailer/.php_cs
+++ /dev/null
@@ -1,31 +0,0 @@
-setRiskyAllowed(true)
- ->setRules([
- '@Symfony' => true,
- '@Symfony:risky' => true,
- 'array_syntax' => ['syntax' => 'short'],
- 'binary_operator_spaces' => false,
- 'concat_space' => ['spacing' => 'one'],
- 'heredoc_to_nowdoc' => true,
- 'method_argument_space' => true,
- 'no_extra_consecutive_blank_lines' => ['break', 'continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block'],
- 'no_php4_constructor' => true,
- 'no_short_echo_tag' => true,
- 'no_unreachable_default_argument_value' => true,
- 'no_useless_else' => true,
- 'no_useless_return' => true,
- 'ordered_imports' => true,
- 'php_unit_fqcn_annotation' => false,
- 'phpdoc_add_missing_param_annotation' => true,
- 'phpdoc_order' => true,
- 'phpdoc_summary' => false,
- 'semicolon_after_instruction' => true,
- 'simplified_null_return' => true
- ])
- ->setFinder(
- PhpCsFixer\Finder::create()
- ->in(__DIR__ . '/src')
- ->in(__DIR__ . '/test')
- )
-;
diff --git a/core/l/PHPMailer/.scrutinizer.yml b/core/l/PHPMailer/.scrutinizer.yml
deleted file mode 100755
index 95162c3..0000000
--- a/core/l/PHPMailer/.scrutinizer.yml
+++ /dev/null
@@ -1,128 +0,0 @@
-build:
- environment:
- php: '5.6.0'
-
-before_commands:
- - "composer install --prefer-source"
-
-tools:
- external_code_coverage:
- enabled: true
- timeout: 300
- filter:
- excluded_paths:
- - 'docs/*'
- - 'examples/*'
- - 'extras/*'
- - 'test/*'
- - 'vendor/*'
-
- php_code_coverage:
- enabled: false
- filter:
- excluded_paths:
- - 'docs/*'
- - 'examples/*'
- - 'extras/*'
- - 'test/*'
- - 'vendor/*'
-
- php_code_sniffer:
- enabled: true
- config:
- standard: PSR2
- filter:
- excluded_paths:
- - 'docs/*'
- - 'examples/*'
- - 'extras/*'
- - 'test/*'
- - 'vendor/*'
-
- # Copy/Paste Detector
- php_cpd:
- enabled: true
- excluded_dirs:
- - docs
- - examples
- - extras
- - test
- - vendor
-
- # PHP CS Fixer (http://http://cs.sensiolabs.org/).
- php_cs_fixer:
- enabled: true
- config:
- level: psr2
- filter:
- excluded_paths:
- - 'docs/*'
- - 'examples/*'
- - 'extras/*'
- - 'test/*'
- - 'vendor/*'
-
- # Analyzes the size and structure of a PHP project.
- php_loc:
- enabled: true
- excluded_dirs:
- - docs
- - examples
- - extras
- - test
- - vendor
-
- # PHP Mess Detector (http://phpmd.org).
- php_mess_detector:
- enabled: true
- config:
- rulesets:
- - codesize
- - unusedcode
- - naming
- - design
- naming_rules:
- short_variable: { minimum: 2 }
- filter:
- excluded_paths:
- - 'docs/*'
- - 'examples/*'
- - 'extras/*'
- - 'test/*'
- - 'vendor/*'
-
- # Analyzes the size and structure of a PHP project.
- php_pdepend:
- enabled: true
- excluded_dirs:
- - docs
- - examples
- - extras
- - test
- - vendor
-
- # Runs Scrutinizer's PHP Analyzer Tool
- # https://scrutinizer-ci.com/docs/tools/php/php-analyzer/config_reference
- php_analyzer:
- enabled: true
- config:
- checkstyle:
- enabled: true
- naming:
- enabled: true
- property_name: ^[_a-zA-Z][a-zA-Z0-9_]*$ #Allow underscores & caps
- method_name: ^(?:[_a-zA-Z]|__)[a-zA-Z0-9_]*$ #Allow underscores & caps
- parameter_name: ^[a-z][a-zA-Z0-9_]*$ # Allow underscores
- local_variable: ^[a-zA-Z][a-zA-Z0-9_]*$ #Allow underscores & caps
- exception_name: ^[a-zA-Z][a-zA-Z0-9]*Exception$
- isser_method_name: ^(?:[_a-zA-Z]|__)[a-zA-Z0-9]*$ #Allow underscores & caps
- filter:
- excluded_paths:
- - 'docs/*'
- - 'examples/*'
- - 'extras/*'
- - 'test/*'
- - 'vendor/*'
-
- # Security Advisory Checker
- sensiolabs_security_checker: true
diff --git a/core/l/PHPMailer/.travis.yml b/core/l/PHPMailer/.travis.yml
deleted file mode 100755
index f4c9225..0000000
--- a/core/l/PHPMailer/.travis.yml
+++ /dev/null
@@ -1,60 +0,0 @@
-language: php
-
-cache:
- directories:
- - $HOME/.composer/cache
-
-before_install:
- - sudo apt-get update -qq
- - sudo apt-get install -y -qq postfix
-
-install:
- - REMOVE_PACKAGE="friendsofphp/php-cs-fixer"; if [ "$CS_CHECK" = 1 ]; then REMOVE_PACKAGE="phpunit/phpunit"; fi; composer remove --no-update --no-scripts --dev $REMOVE_PACKAGE
- - composer remove --no-update --no-scripts --dev phpdocumentor/phpdocumentor
- - composer install
- - if [ "$CODE_COVERAGE" != 1 ]; then phpenv config-rm xdebug.ini || true; fi
-
-before_script:
- - sudo service postfix stop
- - smtp-sink -d "%d.%H.%M.%S" localhost:2500 1000 &
- - mkdir -p build/logs
- - cp test/testbootstrap-dist.php test/testbootstrap.php
- - chmod +x test/fakesendmail.sh
- - sudo mkdir -p /var/qmail/bin
- - sudo cp test/fakesendmail.sh /var/qmail/bin/sendmail
- - sudo cp test/fakesendmail.sh /usr/sbin/sendmail
- - |
- if [[ $TRAVIS_PHP_VERSION = "hhv"* ]]; then
- echo 'sendmail_path = "/usr/sbin/sendmail -t -i "' >> /etc/hhvm/php.ini
- else
- echo 'sendmail_path = "/usr/sbin/sendmail -t -i "' > $(php --ini|grep -m 1 "ini files in:"|cut -d ":" -f 2)/sendmail.ini
- fi
-
-script: ./vendor/bin/phpunit --configuration ./travis.phpunit.xml.dist
-
-after_script:
- - if [ "$CODE_COVERAGE" = 1 ]; then wget https://scrutinizer-ci.com/ocular.phar; fi
- - if [ "$CODE_COVERAGE" = 1 ]; then php ocular.phar code-coverage:upload --format=php-clover ../build/logs/clover.xml; fi
-
-stages:
- - coding-standard
- - test
-
-jobs:
- include:
- - stage: coding-standard
- before_install:
- before_script:
- script: ./vendor/bin/php-cs-fixer --diff --dry-run --verbose fix
- after_script:
- php: 5.5
- env: CS_CHECK=1
- - stage: test
- php: 5.5
- - php: 5.6
- - php: 7.0
- - php: 7.1
- env: CODE_COVERAGE=1
- - php: 7.2
- - php: hhvm
- dist: trusty
diff --git a/core/l/PHPMailer/LICENSE b/core/l/PHPMailer/LICENSE
deleted file mode 100755
index f166cc5..0000000
--- a/core/l/PHPMailer/LICENSE
+++ /dev/null
@@ -1,502 +0,0 @@
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 2.1, February 1999
-
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the Lesser GPL. It also counts
- as the successor of the GNU Library Public License, version 2, hence
- the version number 2.1.]
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
- This license, the Lesser General Public License, applies to some
-specially designated software packages--typically libraries--of the
-Free Software Foundation and other authors who decide to use it. You
-can use it too, but we suggest you first think carefully about whether
-this license or the ordinary General Public License is the better
-strategy to use in any particular case, based on the explanations below.
-
- When we speak of free software, we are referring to freedom of use,
-not price. Our General Public Licenses are designed to make sure that
-you have the freedom to distribute copies of free software (and charge
-for this service if you wish); that you receive source code or can get
-it if you want it; that you can change the software and use pieces of
-it in new free programs; and that you are informed that you can do
-these things.
-
- To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights. These restrictions translate to certain responsibilities for
-you if you distribute copies of the library or if you modify it.
-
- For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you. You must make sure that they, too, receive or can get the source
-code. If you link other code with the library, you must provide
-complete object files to the recipients, so that they can relink them
-with the library after making changes to the library and recompiling
-it. And you must show them these terms so they know their rights.
-
- We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
- To protect each distributor, we want to make it very clear that
-there is no warranty for the free library. Also, if the library is
-modified by someone else and passed on, the recipients should know
-that what they have is not the original version, so that the original
-author's reputation will not be affected by problems that might be
-introduced by others.
-
- Finally, software patents pose a constant threat to the existence of
-any free program. We wish to make sure that a company cannot
-effectively restrict the users of a free program by obtaining a
-restrictive license from a patent holder. Therefore, we insist that
-any patent license obtained for a version of the library must be
-consistent with the full freedom of use specified in this license.
-
- Most GNU software, including some libraries, is covered by the
-ordinary GNU General Public License. This license, the GNU Lesser
-General Public License, applies to certain designated libraries, and
-is quite different from the ordinary General Public License. We use
-this license for certain libraries in order to permit linking those
-libraries into non-free programs.
-
- When a program is linked with a library, whether statically or using
-a shared library, the combination of the two is legally speaking a
-combined work, a derivative of the original library. The ordinary
-General Public License therefore permits such linking only if the
-entire combination fits its criteria of freedom. The Lesser General
-Public License permits more lax criteria for linking other code with
-the library.
-
- We call this license the "Lesser" General Public License because it
-does Less to protect the user's freedom than the ordinary General
-Public License. It also provides other free software developers Less
-of an advantage over competing non-free programs. These disadvantages
-are the reason we use the ordinary General Public License for many
-libraries. However, the Lesser license provides advantages in certain
-special circumstances.
-
- For example, on rare occasions, there may be a special need to
-encourage the widest possible use of a certain library, so that it becomes
-a de-facto standard. To achieve this, non-free programs must be
-allowed to use the library. A more frequent case is that a free
-library does the same job as widely used non-free libraries. In this
-case, there is little to gain by limiting the free library to free
-software only, so we use the Lesser General Public License.
-
- In other cases, permission to use a particular library in non-free
-programs enables a greater number of people to use a large body of
-free software. For example, permission to use the GNU C Library in
-non-free programs enables many more people to use the whole GNU
-operating system, as well as its variant, the GNU/Linux operating
-system.
-
- Although the Lesser General Public License is Less protective of the
-users' freedom, it does ensure that the user of a program that is
-linked with the Library has the freedom and the wherewithal to run
-that program using a modified version of the Library.
-
- The precise terms and conditions for copying, distribution and
-modification follow. Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library". The
-former contains code derived from the library, whereas the latter must
-be combined with the library in order to run.
-
- GNU LESSER GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License Agreement applies to any software library or other
-program which contains a notice placed by the copyright holder or
-other authorized party saying it may be distributed under the terms of
-this Lesser General Public License (also called "this License").
-Each licensee is addressed as "you".
-
- A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
- The "Library", below, refers to any such software library or work
-which has been distributed under these terms. A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language. (Hereinafter, translation is
-included without limitation in the term "modification".)
-
- "Source code" for a work means the preferred form of the work for
-making modifications to it. For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control compilation
-and installation of the library.
-
- Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it). Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
- 1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
- You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-
- 2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) The modified work must itself be a software library.
-
- b) You must cause the files modified to carry prominent notices
- stating that you changed the files and the date of any change.
-
- c) You must cause the whole of the work to be licensed at no
- charge to all third parties under the terms of this License.
-
- d) If a facility in the modified Library refers to a function or a
- table of data to be supplied by an application program that uses
- the facility, other than as an argument passed when the facility
- is invoked, then you must make a good faith effort to ensure that,
- in the event an application does not supply such function or
- table, the facility still operates, and performs whatever part of
- its purpose remains meaningful.
-
- (For example, a function in a library to compute square roots has
- a purpose that is entirely well-defined independent of the
- application. Therefore, Subsection 2d requires that any
- application-supplied function or table used by this function must
- be optional: if the application does not supply it, the square
- root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library. To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License. (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.) Do not make any other change in
-these notices.
-
- Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
- This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
- 4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
- If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library". Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
- However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library". The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
- When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library. The
-threshold for this to be true is not precisely defined by law.
-
- If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work. (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
- Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-
- 6. As an exception to the Sections above, you may also combine or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
- You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License. You must supply a copy of this License. If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License. Also, you must do one
-of these things:
-
- a) Accompany the work with the complete corresponding
- machine-readable source code for the Library including whatever
- changes were used in the work (which must be distributed under
- Sections 1 and 2 above); and, if the work is an executable linked
- with the Library, with the complete machine-readable "work that
- uses the Library", as object code and/or source code, so that the
- user can modify the Library and then relink to produce a modified
- executable containing the modified Library. (It is understood
- that the user who changes the contents of definitions files in the
- Library will not necessarily be able to recompile the application
- to use the modified definitions.)
-
- b) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (1) uses at run time a
- copy of the library already present on the user's computer system,
- rather than copying library functions into the executable, and (2)
- will operate properly with a modified version of the library, if
- the user installs one, as long as the modified version is
- interface-compatible with the version that the work was made with.
-
- c) Accompany the work with a written offer, valid for at
- least three years, to give the same user the materials
- specified in Subsection 6a, above, for a charge no more
- than the cost of performing this distribution.
-
- d) If distribution of the work is made by offering access to copy
- from a designated place, offer equivalent access to copy the above
- specified materials from the same place.
-
- e) Verify that the user has already received a copy of these
- materials or that you have already sent this user a copy.
-
- For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it. However, as a special exception,
-the materials to be distributed need not include anything that is
-normally distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
- It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system. Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-
- 7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
- a) Accompany the combined library with a copy of the same work
- based on the Library, uncombined with any other library
- facilities. This must be distributed under the terms of the
- Sections above.
-
- b) Give prominent notice with the combined library of the fact
- that part of it is a work based on the Library, and explaining
- where to find the accompanying uncombined form of the same work.
-
- 8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License. Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License. However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
- 9. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Library or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
- 10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties with
-this License.
-
- 11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all. For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under any
-particular circumstance, the balance of the section is intended to apply,
-and the section as a whole is intended to apply in other circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License may add
-an explicit geographical distribution limitation excluding those countries,
-so that distribution is permitted only in or among countries not thus
-excluded. In such case, this License incorporates the limitation as if
-written in the body of this License.
-
- 13. The Free Software Foundation may publish revised and/or new
-versions of the Lesser General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation. If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-
- 14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission. For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this. Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
- NO WARRANTY
-
- 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Libraries
-
- If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change. You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms of the
-ordinary General Public License).
-
- To apply these terms, attach the following notices to the library. It is
-safest to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least the
-"copyright" line and a pointer to where the full notice is found.
-
-
- Copyright (C)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the library, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the
- library `Frob' (a library for tweaking knobs) written by James Random Hacker.
-
- , 1 April 1990
- Ty Coon, President of Vice
-
-That's all there is to it!
\ No newline at end of file
diff --git a/core/l/PHPMailer/README.md b/core/l/PHPMailer/README.md
deleted file mode 100755
index 5f4ad9d..0000000
--- a/core/l/PHPMailer/README.md
+++ /dev/null
@@ -1,217 +0,0 @@
-
-
-# PHPMailer - A full-featured email creation and transfer class for PHP
-
-Build status: [](https://travis-ci.org/PHPMailer/PHPMailer)
-[](https://scrutinizer-ci.com/g/PHPMailer/PHPMailer/)
-[](https://scrutinizer-ci.com/g/PHPMailer/PHPMailer/)
-
-[](https://packagist.org/packages/phpmailer/phpmailer) [](https://packagist.org/packages/phpmailer/phpmailer) [](https://packagist.org/packages/phpmailer/phpmailer) [](https://packagist.org/packages/phpmailer/phpmailer)
-
-## Class Features
-- Probably the world's most popular code for sending email from PHP!
-- Used by many open-source projects: WordPress, Drupal, 1CRM, SugarCRM, Yii, Joomla! and many more
-- Integrated SMTP support - send without a local mail server
-- Send emails with multiple To, CC, BCC and Reply-to addresses
-- Multipart/alternative emails for mail clients that do not read HTML email
-- Add attachments, including inline
-- Support for UTF-8 content and 8bit, base64, binary, and quoted-printable encodings
-- SMTP authentication with LOGIN, PLAIN, CRAM-MD5 and XOAUTH2 mechanisms over SSL and SMTP+STARTTLS transports
-- Validates email addresses automatically
-- Protect against header injection attacks
-- Error messages in 47 languages!
-- DKIM and S/MIME signing support
-- Compatible with PHP 5.5 and later
-- Namespaced to prevent name clashes
-- Much more!
-
-## Why you might need it
-Many PHP developers utilize email in their code. The only PHP function that supports this is the `mail()` function. However, it does not provide any assistance for making use of popular features such as HTML-based emails and attachments.
-
-Formatting email correctly is surprisingly difficult. There are myriad overlapping RFCs, requiring tight adherence to horribly complicated formatting and encoding rules - the vast majority of code that you'll find online that uses the `mail()` function directly is just plain wrong!
-*Please* don't be tempted to do it yourself - if you don't use PHPMailer, there are many other excellent libraries that you should look at before rolling your own - try [SwiftMailer](https://swiftmailer.symfony.com/), [Zend/Mail](https://zendframework.github.io/zend-mail/), [eZcomponents](https://github.com/zetacomponents/Mail) etc.
-
-The PHP `mail()` function usually sends via a local mail server, typically fronted by a `sendmail` binary on Linux, BSD and OS X platforms, however, Windows usually doesn't include a local mail server; PHPMailer's integrated SMTP implementation allows email sending on Windows platforms without a local mail server.
-
-## License
-This software is distributed under the [LGPL 2.1](http://www.gnu.org/licenses/lgpl-2.1.html) license. Please read LICENSE for information on the
-software availability and distribution.
-
-## Installation & loading
-PHPMailer is available on [Packagist](https://packagist.org/packages/phpmailer/phpmailer) (using semantic versioning), and installation via composer is the recommended way to install PHPMailer. Just add this line to your `composer.json` file:
-
-```json
-"phpmailer/phpmailer": "~6.0"
-```
-
-or run
-
-```sh
-composer require phpmailer/phpmailer
-```
-
-Note that the `vendor` folder and the `vendor/autoload.php` script are generated by composer; they are not part of PHPMailer.
-
-If you want to use the Gmail XOAUTH2 authentication class, you will also need to add a dependency on the `league/oauth2-client` package in your `composer.json`.
-
-Alternatively, if you're not using composer, copy the contents of the PHPMailer folder into one of the `include_path` directories specified in your PHP configuration and load each class file manually:
-
-```php
-SMTPDebug = 2; // Enable verbose debug output
- $mail->isSMTP(); // Set mailer to use SMTP
- $mail->Host = 'smtp1.example.com;smtp2.example.com'; // Specify main and backup SMTP servers
- $mail->SMTPAuth = true; // Enable SMTP authentication
- $mail->Username = 'user@example.com'; // SMTP username
- $mail->Password = 'secret'; // SMTP password
- $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
- $mail->Port = 587; // TCP port to connect to
-
- //Recipients
- $mail->setFrom('from@example.com', 'Mailer');
- $mail->addAddress('joe@example.net', 'Joe User'); // Add a recipient
- $mail->addAddress('ellen@example.com'); // Name is optional
- $mail->addReplyTo('info@example.com', 'Information');
- $mail->addCC('cc@example.com');
- $mail->addBCC('bcc@example.com');
-
- //Attachments
- $mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
- $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
-
- //Content
- $mail->isHTML(true); // Set email format to HTML
- $mail->Subject = 'Here is the subject';
- $mail->Body = 'This is the HTML message body in bold!';
- $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
-
- $mail->send();
- echo 'Message has been sent';
-} catch (Exception $e) {
- echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
-}
-```
-
-You'll find plenty more to play with in the [examples](https://github.com/PHPMailer/PHPMailer/tree/master/examples) folder.
-
-That's it. You should now be ready to use PHPMailer!
-
-## Localization
-PHPMailer defaults to English, but in the [language](https://github.com/PHPMailer/PHPMailer/tree/master/language/) folder you'll find numerous (47 at the time of writing!) translations for PHPMailer error messages that you may encounter. Their filenames contain [ISO 639-1](http://en.wikipedia.org/wiki/ISO_639-1) language code for the translations, for example `fr` for French. To specify a language, you need to tell PHPMailer which one to use, like this:
-
-```php
-// To load the French version
-$mail->setLanguage('fr', '/optional/path/to/language/directory/');
-```
-
-We welcome corrections and new languages - if you're looking for corrections to do, run the [PHPMailerLangTest.php](https://github.com/PHPMailer/PHPMailer/tree/master/test/PHPMailerLangTest.php) script in the tests folder and it will show any missing translations.
-
-## Documentation
-Start reading at the [GitHub wiki](https://github.com/PHPMailer/PHPMailer/wiki). If you're having trouble, this should be the first place you look as it's the most frequently updated.
-
-Examples of how to use PHPMailer for common scenarios can be found in the [examples](https://github.com/PHPMailer/PHPMailer/tree/master/examples) folder. If you're looking for a good starting point, we recommend you start with [the Gmail example](https://github.com/PHPMailer/PHPMailer/tree/master/examples/gmail.phps).
-
-Note that in order to reduce PHPMailer's deployed code footprint, the examples are no longer included if you load PHPMailer via composer or via [GitHub's zip file download](https://github.com/PHPMailer/PHPMailer/archive/master.zip), so you'll need to either clone the git repository or use the above links to get to the examples directly.
-
-Complete generated API documentation is [available online](http://phpmailer.github.io/PHPMailer/).
-
-You can generate complete API-level documentation by running `phpdoc` in the top-level folder, and documentation will appear in teh `docs` folder, though you'll need to have [PHPDocumentor](http://www.phpdoc.org) installed. You may find [the unit tests](https://github.com/PHPMailer/PHPMailer/tree/master/test/phpmailerTest.php) a good source of how to do various operations such as encryption.
-
-If the documentation doesn't cover what you need, search the [many questions on Stack Overflow](http://stackoverflow.com/questions/tagged/phpmailer), and before you ask a question about "SMTP Error: Could not connect to SMTP host.", [read the troubleshooting guide](https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting).
-
-## Tests
-There is a PHPUnit test script in the [test](https://github.com/PHPMailer/PHPMailer/tree/master/test/) folder. PHPMailer uses PHPUnit 4.8 - we would use 5.x but we need to run on PHP 5.5.
-
-Build status: [](https://travis-ci.org/PHPMailer/PHPMailer)
-
-If this isn't passing, is there something you can do to help?
-
-## Security
-Please disclose any vulnerabilities found responsibly - report any security problems found to the maintainers privately.
-
-PHPMailer versions prior to 5.2.22 (released January 9th 2017) have a local file disclosure vulnerability, [CVE-2017-5223](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2017-5223). If content passed into `msgHTML()` is sourced from unfiltered user input, relative paths can map to absolute local file paths and added as attachments. Also note that `addAttachment` (just like `file_get_contents`, `passthru`, `unlink`, etc) should not be passed user-sourced params either! Reported by Yongxiang Li of Asiasecurity.
-
-PHPMailer versions prior to 5.2.20 (released December 28th 2016) are vulnerable to [CVE-2016-10045](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2016-10045) a remote code execution vulnerability, responsibly reported by [Dawid Golunski](https://legalhackers.com/advisories/PHPMailer-Exploit-Remote-Code-Exec-CVE-2016-10045-Vuln-Patch-Bypass.html), and patched by Paul Buonopane (@Zenexer).
-
-PHPMailer versions prior to 5.2.18 (released December 2016) are vulnerable to [CVE-2016-10033](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2016-10033) a critical remote code execution vulnerability, responsibly reported by [Dawid Golunski](http://legalhackers.com/advisories/PHPMailer-Exploit-Remote-Code-Exec-CVE-2016-10033-Vuln.html).
-
-See [SECURITY](https://github.com/PHPMailer/PHPMailer/tree/master/SECURITY.md) for more detail on security issues.
-
-## Contributing
-Please submit bug reports, suggestions and pull requests to the [GitHub issue tracker](https://github.com/PHPMailer/PHPMailer/issues).
-
-We're particularly interested in fixing edge-cases, expanding test coverage and updating translations.
-
-If you found a mistake in the docs, or want to add something, go ahead and amend the wiki - anyone can edit it.
-
-If you have git clones from prior to the move to the PHPMailer GitHub organisation, you'll need to update any remote URLs referencing the old GitHub location with a command like this from within your clone:
-
-```sh
-git remote set-url upstream https://github.com/PHPMailer/PHPMailer.git
-```
-
-Please *don't* use the SourceForge or Google Code projects any more; they are obsolete and no longer maintained.
-
-## Sponsorship
-Development time and resources for PHPMailer are provided by [Smartmessages.net](https://info.smartmessages.net/), a powerful email marketing system.
-
-
-
-Other contributions are gladly received, whether in beer ðŸº, T-shirts 👕, Amazon wishlist raids, or cold, hard cash 💰. If you'd like to donate to say "thank you" to maintainers or contributors, please contact them through individual profile pages via [the contributors page](https://github.com/PHPMailer/PHPMailer/graphs/contributors).
-
-## Changelog
-See [changelog](changelog.md).
-
-## History
-- PHPMailer was originally written in 2001 by Brent R. Matzelle as a [SourceForge project](http://sourceforge.net/projects/phpmailer/).
-- Marcus Bointon (coolbru on SF) and Andy Prevost (codeworxtech) took over the project in 2004.
-- Became an Apache incubator project on Google Code in 2010, managed by Jim Jagielski.
-- Marcus created his fork on [GitHub](https://github.com/Synchro/PHPMailer) in 2008.
-- Jim and Marcus decide to join forces and use GitHub as the canonical and official repo for PHPMailer in 2013.
-- PHPMailer moves to the [PHPMailer organisation](https://github.com/PHPMailer) on GitHub in 2013.
-
-### What's changed since moving from SourceForge?
-- Official successor to the SourceForge and Google Code projects.
-- Test suite.
-- Continuous integration with Travis-CI.
-- Composer support.
-- Public development.
-- Additional languages and language strings.
-- CRAM-MD5 authentication support.
-- Preserves full repo history of authors, commits and branches from the original SourceForge project.
diff --git a/core/l/PHPMailer/SECURITY.md b/core/l/PHPMailer/SECURITY.md
deleted file mode 100755
index 57a1f13..0000000
--- a/core/l/PHPMailer/SECURITY.md
+++ /dev/null
@@ -1,26 +0,0 @@
-# Security notices relating to PHPMailer
-
-Please disclose any vulnerabilities found responsibly - report any security problems found to the maintainers privately.
-
-PHPMailer versions prior to 5.2.24 (released July 26th 2017) have an XSS vulnerability in one of the code examples, [CVE-2017-11503](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2017-11503). The `code_generator.phps` example did not filter user input prior to output. This file is distributed with a `.phps` extension, so it it not normally executable unless it is explicitly renamed, so it is safe by default. There was also an undisclosed potential XSS vulnerability in the default exception handler (unused by default). Patches for both issues kindly provided by Patrick Monnerat of the Fedora Project.
-
-PHPMailer versions prior to 5.2.22 (released January 9th 2017) have a local file disclosure vulnerability, [CVE-2017-5223](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2017-5223). If content passed into `msgHTML()` is sourced from unfiltered user input, relative paths can map to absolute local file paths and added as attachments. Also note that `addAttachment` (just like `file_get_contents`, `passthru`, `unlink`, etc) should not be passed user-sourced params either! Reported by Yongxiang Li of Asiasecurity.
-
-PHPMailer versions prior to 5.2.20 (released December 28th 2016) are vulnerable to [CVE-2016-10045](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2016-10045) a remote code execution vulnerability, responsibly reported by [Dawid Golunski](https://legalhackers.com/advisories/PHPMailer-Exploit-Remote-Code-Exec-CVE-2016-10045-Vuln-Patch-Bypass.html), and patched by Paul Buonopane (@Zenexer).
-
-PHPMailer versions prior to 5.2.18 (released December 2016) are vulnerable to [CVE-2016-10033](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2016-10033) a remote code execution vulnerability, responsibly reported by [Dawid Golunski](http://legalhackers.com/advisories/PHPMailer-Exploit-Remote-Code-Exec-CVE-2016-10033-Vuln.html).
-
-PHPMailer versions prior to 5.2.14 (released November 2015) are vulnerable to [CVE-2015-8476](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2015-8476) an SMTP CRLF injection bug permitting arbitrary message sending.
-
-PHPMailer versions prior to 5.2.10 (released May 2015) are vulnerable to [CVE-2008-5619](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2008-5619), a remote code execution vulnerability in the bundled html2text library. This file was removed in 5.2.10, so if you are using a version prior to that and make use of the html2text function, it's vitally important that you upgrade and remove this file.
-
-PHPMailer versions prior to 2.0.7 and 2.2.1 are vulnerable to [CVE-2012-0796](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2012-0796), an email header injection attack.
-
-Joomla 1.6.0 uses PHPMailer in an unsafe way, allowing it to reveal local file paths, reported in [CVE-2011-3747](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2011-3747).
-
-PHPMailer didn't sanitise the `$lang_path` parameter in `SetLanguage`. This wasn't a problem in itself, but some apps (PHPClassifieds, ATutor) also failed to sanitise user-provided parameters passed to it, permitting semi-arbitrary local file inclusion, reported in [CVE-2010-4914](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2010-4914), [CVE-2007-2021](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2007-2021) and [CVE-2006-5734](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2006-5734).
-
-PHPMailer 1.7.2 and earlier contained a possible DDoS vulnerability reported in [CVE-2005-1807](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2005-1807).
-
-PHPMailer 1.7 and earlier (June 2003) have a possible vulnerability in the `SendmailSend` method where shell commands may not be sanitised. Reported in [CVE-2007-3215](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2007-3215).
-
diff --git a/core/l/PHPMailer/UPGRADING.md b/core/l/PHPMailer/UPGRADING.md
deleted file mode 100755
index 3aae774..0000000
--- a/core/l/PHPMailer/UPGRADING.md
+++ /dev/null
@@ -1,125 +0,0 @@
-# Upgrading from PHPMailer 5.2 to 6.0
-
-PHPMailer 6.0 is a major update, breaking backward compatibility.
-
-If you're in doubt about how you should be using PHPMailer 6, take a look at the examples as they have all been updated to work in a PHPMailer 6.0 style.
-
-## PHP Version
-
-PHPMailer 6.0 requires PHP 5.5 or later, and is fully compatible with PHP 7.0. PHPMailer 5.2 supported PHP 5.0 and upwards, so if you need to run on a legacy PHP version, see the [PHPMailer 5.2-stable branch on Github](https://github.com/PHPMailer/PHPMailer/tree/5.2-stable).
-
-## Loading PHPMailer
-
-The single biggest change will be in the way that you load PHPMailer. In earlier versions you may have done this:
-
-```php
-require 'PHPMailerAutoload.php';
-```
-
-or
-
-```php
-require 'class.phpmailer.php';
-require 'class.smtp.php';
-```
-
-We recommend that you load PHPMailer via composer, using its standard autoloader, which you probably won't need to load if you're using it already, but in case you're not, you will need to do this instead:
-
-```php
-require 'vendor/autoload.php';
-```
-
-If you're not using composer, you can still load the classes manually, depending on what you're using:
-
-```php
-require 'src/PHPMailer.php';
-require 'src/SMTP.php';
-require 'src/Exception.php';
-```
-
-## Namespace
-PHPMailer 6 uses a [namespace](http://php.net/manual/en/language.namespaces.rationale.php) of `PHPMailer\PHPMailer`, because it's the PHPMailer project within the PHPMailer organisation. You **must** import (with a `use` statement) classes you're using explicitly into your own namespace, or reference them absolutely in the global namespace - all the examples do this. This means the fully-qualified name of the main PHPMailer class is `PHPMailer\PHPMailer\PHPMailer`, which is a bit of a mouthful, but there's no harm in it! If you are using other PHPMailer classes explicitly (such as `SMTP` or `Exception`), you will need to import them into your namespace too.
-
-For example you might create an instance like this:
-
-```php
-errorMessage();
-} catch (Exception $e) {
- echo $e->getMessage();
-}
-```
-
-Convert it to:
-
-```php
-use PHPMailer\PHPMailer\Exception;
-...
-try {
-...
-} catch (Exception $e) {
- echo $e->errorMessage();
-} catch (\Exception $e) {
- echo $e->getMessage();
-}
-```
-
-## OAuth2 Support
-The OAuth2 implementation has been completely redesigned using the [OAuth2 packages](http://oauth2-client.thephpleague.com) from the [League of of extraordinary packages](http://thephpleague.com), providing support for many more OAuth services, and you'll need to update your code if you were using OAuth in 5.2. See [the examples](https://github.com/PHPMailer/PHPMailer/tree/master/examples) and documentation in the [PHPMailer wiki](https://github.com/PHPMailer/PHPMailer/wiki).
-
-## Extras
-Additional classes previously bundled in the `Extras` folder (such as htmlfilter and EasyPeasyICS) have been removed - use equivalent packages from [packagist.org](https://packagist.org) instead.
-
-## Other upgrade changes
-See the changelog for full details.
-* File structure simplified, classes live in the `src/` folder
-* Most statically called functions now use the `static` keyword instead of `self`, so it's possible to override static internal functions in subclasses, for example `validateAddress()`
-* Complete RFC standardisation on CRLF (`\r\n`) line breaks by default:
- * `PHPMailer::$LE` still exists, but all uses of it are changed to `static::$LE` for easier overriding. It may be changed to `\n` automatically when sending via `mail()` on UNIX-like OSs
- * `PHPMailer::CRLF` line ending constant removed
- * The length of the line break is no longer used in line length calculations
- * Similar changes to line break handling in SMTP and POP3 classes
-* All elements previously marked as deprecated have been removed:
- * `PHPMailer->Version`
- * `PHPMailer->ReturnPath`
- * `PHPMailer->PluginDir`
- * `PHPMailer->encodeQPphp()`
- * `SMTP->CRLF`
- * `SMTP->Version`
- * `SMTP->SMTP_PORT`
- * `POP3->CRLF`
- * `POP3->Version`
-* NTLM authentication has been removed - it never worked anyway!
- * `PHPMailer->Workstation`
- * `PHPMailer->Realm`
-* `SMTP::authenticate` method signature changed
-* `parseAddresses()` is now static
-* `validateAddress()` is now called statically from `parseAddresses()`
-* `idnSupported()` is now static and is called statically from `punyencodeAddress()`
-* `PHPMailer->SingleToArray` is now protected
diff --git a/core/l/PHPMailer/VERSION b/core/l/PHPMailer/VERSION
deleted file mode 100755
index 39c5d6a..0000000
--- a/core/l/PHPMailer/VERSION
+++ /dev/null
@@ -1 +0,0 @@
-6.0.3
\ No newline at end of file
diff --git a/core/l/PHPMailer/changelog.md b/core/l/PHPMailer/changelog.md
deleted file mode 100755
index 20f71a4..0000000
--- a/core/l/PHPMailer/changelog.md
+++ /dev/null
@@ -1,790 +0,0 @@
-# PHPMailer Change Log
-
-* Add some modern MIME types
-* Add Hindi translation (thanks to @dextel2)
-
-## Version 6.0.3 (January 5th 2018)
-* Correct DKIM canonicalization of line breaks for header & body - thanks to @themichaelhall
-* Make dependence on ext-filter explicit in composer.json
-
-## Version 6.0.2 (November 29th 2017)
-* Don't make max line length depend on line break format
-* Improve Travis-CI config - thanks to Filippo Tessarotto
-* Match SendGrid transaction IDs
-* `idnSupported()` now static, as previously documented
-* Improve error messages for invalid addresses
-* Improve Indonesian translation (thanks to @januridp)
-* Improve Esperanto translation (thanks to @dknacht)
-* Clean up git export ignore settings for production and zip bundles
-* Update license doc
-* Updated upgrading docs
-* Clarify `addStringEmbeddedImage` docs
-* Hide auth credentials in all but lowest level debug output, prevents leakage in bug reports
-* Code style cleanup
-
-## Version 6.0.1 (September 14th 2017)
-* Use shorter Message-ID headers (with more entropy) to avoid iCloud blackhole bug
-* Switch to Symfony code style (though it's not well defined)
-* CI builds now apply syntax & code style checks, so make your PRs tidy!
-* CI code coverage only applied on latest version of PHP to speed up builds (thanks to @Slamdunk for these CI changes)
-* Remove `composer.lock` - it's important that libraries break early; keeping it is for apps
-* Rename test scripts to PSR-4 spec
-* Make content-id values settable on attachments, not just embedded items
-* Add SMTP transaction IDs to callbacks & allow for future expansion
-* Expand test coverage
-
-## Version 6.0 (August 28th 2017)
-This is a major update that breaks backwards compatibility.
-
-* **Requires PHP 5.5 or later**
-* **Uses the `PHPMailer\PHPMailer` namespace**
-* File structure simplified and PSR-4 compatible, classes live in the `src/` folder
-* The custom autoloader has been removed: [**use composer**](https://getcomposer.org)!
-* Classes & Exceptions renamed to make use of the namespace
-* Most statically called functions now use the `static` keyword instead of `self`, so it's possible to override static internal functions in subclasses, for example `validateAddress()`
-* Complete RFC standardisation on CRLF (`\r\n`) line breaks for SMTP by default:
- * `PHPMailer:$LE` defaults to CRLF
- * All uses of `PHPMailer::$LE` property converted to use `static::$LE` constant for consistency and ease of overriding
- * Similar changes to line break handling in SMTP and POP3 classes.
- * Line break format for `mail()` transport is set automatically.
- * Warnings emitted for buggy `mail()` in PHP versions 7.0.0 - 7.0.16 and 7.1.0 - 7.1.2; either upgrade or switch to SMTP.
-* Extensive reworking of XOAUTH2, adding support for Google, Yahoo and Microsoft providers, thanks to @sherryl4george
-* Major cleanup of docs and examples
-* All elements previously marked as deprecated have been removed:
- * `PHPMailer->Version` (replaced with `VERSION` constant)
- * `PHPMailer->ReturnPath`
- * `PHPMailer->PluginDir`
- * `PHPMailer->encodeQPphp()`
- * `SMTP->CRLF` (replaced with `LE` constant)
- * `SMTP->Version` (replaced with `VERSION` constant)
- * `SMTP->SMTP_PORT` (replaced with `DEFAULT_PORT` constant)
- * `POP3->CRLF` (replaced with `LE` constant)
- * `POP3->Version` (replaced with `VERSION` constant)
- * `POP3->POP3_PORT` (replaced with `DEFAULT_PORT` constant)
- * `POP3->POP3_TIMEOUT` (replaced with `DEFAULT_TIMEOUT` constant)
-* NTLM authentication has been removed - it never worked anyway!
- * `PHPMailer->Workstation`
- * `PHPMailer->Realm`
-* `SingleTo` functionality is deprecated; this belongs at a higher level - PHPMailer is not a mailing list system.
-* `SMTP::authenticate` method signature changed
-* `parseAddresses()` is now static
-* `validateAddress()` is now called statically from `parseAddresses()`
-* `idnSupported()` is now static and is called statically from `punyencodeAddress()`
-* `PHPMailer->SingleToArray` is now protected
-* `fixEOL()` method removed - it duplicates `PHPMailer::normalizeBreaks()`, so use that instead
-* Don't try to use an auth mechanism if it's not supported by the server
-* Reorder automatic AUTH mechanism selector to try most secure method first
-* `Extras` classes have been removed - use alternative packages from [packagist.org](https://packagist.org) instead
-* Better handling of automatic transfer encoding switch in the presence of long lines
-* Simplification of address validation - now uses PHP's `FILTER_VALIDATE_EMAIL` pattern by default, retains advanced options
-* `Debugoutput` can accept a PSR-3 logger instance
-* To reduce code footprint, the examples folder is no longer included in composer deployments or github zip files
-* Trap low-level errors in SMTP, reports via debug output
-* More reliable folding of message headers
-* Inject your own SMTP implementation via `setSMTPInstance()` instead of having to subclass and override `getSMTPInstance()`.
-* Make obtaining SMTP transaction ID more reliable
-* Better handling of unreliable PHP timeouts
-* Made `SMTPDebug = 4` slightly less noisy
-
-## Version 5.2.25 (August 28th 2017)
-* Make obtaining SMTP transaction ID more reliable
-* Add Bosnian translation
-* This is the last official release in the legacy PHPMailer 5.2 series; there may be future security patches (which will be found in the [5.2-stable branch](https://github.com/PHPMailer/PHPMailer/tree/5.2-stable)), but no further non-security PRs or issues will be accepted. Migrate to PHPMailer 6.0.
-
-## Version 5.2.24 (July 26th 2017)
-* **SECURITY** Fix XSS vulnerability in one of the code examples, [CVE-2017-11503](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2017-11503). The `code_generator.phps` example did not filter user input prior to output. This file is distributed with a `.phps` extension, so it it not normally executable unless it is explicitly renamed, so it is safe by default. There was also an undisclosed potential XSS vulnerability in the default exception handler (unused by default). Patches for both issues kindly provided by Patrick Monnerat of the Fedora Project.
-* Handle bare codes (an RFC contravention) in SMTP server responses
-* Make message timestamps more dynamic - calculate the date separately for each message
-* More thorough checks for reading attachments.
-* Throw an exception when trying to send a message with an empty body caused by an internal error.
-* Replaced all use of MD5 and SHA1 hash functions with SHA256.
-* Now checks for invalid host strings when sending via SMTP.
-* Include timestamps in HTML-format debug output
-* Improve Turkish, Norwegian, Serbian, Brazilian Portuguese & simplified Chinese translations
-* Correction of Serbian ISO language code from `sr` to `rs`
-* Fix matching of multiple entries in `Host` to match IPv6 literals without breaking port selection (see #1094, caused by a3b4f6b)
-* Better capture and reporting of SMTP connection errors
-
-## Version 5.2.23 (March 15th 2017)
-* Improve trapping of TLS errors during connection so that they don't cause warnings, and are reported better in debug output
-* Amend test suite so it uses PHPUnit version 4.8, compatible with older versions of PHP, instead of the version supplied by Travis-CI
-* This forces pinning of some dev packages to older releases, but should make travis builds more reliable
-* Test suite now runs on HHVM, and thus so should PHPMailer in general
-* Improve Czech translations
-* Add links to CVE-2017-5223 resources
-
-## Version 5.2.22 (January 5th 2017)
-* **SECURITY** Fix [CVE-2017-5223](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2017-5223), local file disclosure vulnerability if content passed to `msgHTML()` is sourced from unfiltered user input. Reported by Yongxiang Li of Asiasecurity. The fix for this means that calls to `msgHTML()` without a `$basedir` will not import images with relative URLs, and relative URLs containing `..` will be ignored.
-* Add simple contact form example
-* Emoji in test content
-
-## Version 5.2.21 (December 28th 2016)
-* Fix missed number update in version file - no functional changes
-
-## Version 5.2.20 (December 28th 2016)
-* **SECURITY** Critical security update for CVE-2016-10045 please update now! Thanks to [Dawid Golunski](https://legalhackers.com) and Paul Buonopane (@Zenexer).
-* Note that this change will break VERP addresses in Sender if you're using mail() - workaround: use SMTP to localhost instead.
-
-## Version 5.2.19 (December 26th 2016)
-* Minor cleanup
-
-## Version 5.2.18 (December 24th 2016)
-* **SECURITY** Critical security update for CVE-2016-10033 please update now! Thanks to [Dawid Golunski](https://legalhackers.com).
-* Add ability to extract the SMTP transaction ID from some common SMTP success messages
-* Minor documentation tweaks
-
-## Version 5.2.17 (December 9th 2016)
-* This is officially the last feature release of 5.2. Security fixes only from now on; use PHPMailer 6.0!
-* Allow DKIM private key to be provided as a string
-* Provide mechanism to allow overriding of boundary and message ID creation
-* Improve Brazilian Portuguese, Spanish, Swedish, Romanian, and German translations
-* PHP 7.1 support for Travis-CI
-* Fix some language codes
-* Add security notices
-* Improve DKIM compatibility in older PHP versions
-* Improve trapping and capture of SMTP connection errors
-* Improve passthrough of error levels for debug output
-* PHPDoc cleanup
-
-## Version 5.2.16 (June 6th 2016)
-* Added DKIM example
-* Fixed empty additional_parameters problem
-* Fixed wrong version number in VERSION file!
-* Improve line-length tests
-* Use instance settings for SMTP::connect by default
-* Use more secure auth mechanisms first
-
-## Version 5.2.15 (May 10th 2016)
-* Added ability to inject custom address validators, and set the default validator
-* Fix TLS 1.2 compatibility
-* Remove some excess line breaks in MIME structure
-* Updated Polish, Russian, Brazilian Portuguese, Georgian translations
-* More DRY!
-* Improve error messages
-* Update dependencies
-* Add example showing how to handle multiple form file uploads
-* Improve SMTP example
-* Improve Windows compatibility
-* Use consistent names for temp files
-* Fix gmail XOAUTH2 scope, thanks to @sherryl4george
-* Fix extra line break in getSentMIMEMessage()
-* Improve DKIM signing to use SHA-2
-
-## Version 5.2.14 (Nov 1st 2015)
-* Allow addresses with IDN (Internationalized Domain Name) in PHP 5.3+, thanks to @fbonzon
-* Allow access to POP3 errors
-* Make all POP3 private properties and methods protected
-* **SECURITY** Fix vulnerability that allowed email addresses with line breaks (valid in RFC5322) to pass to SMTP, permitting message injection at the SMTP level. Mitigated in both the address validator and in the lower-level SMTP class. Thanks to Takeshi Terada.
-* Updated Brazilian Portuguese translations (Thanks to @phelipealves)
-
-## Version 5.2.13 (Sep 14th 2015)
-* Rename internal oauth class to avoid name clashes
-* Improve Estonian translations
-
-## Version 5.2.12 (Sep 1st 2015)
-* Fix incorrect composer package dependencies
-* Skip existing embedded image `cid`s in `msgHTML`
-
-## Version 5.2.11 (Aug 31st 2015)
-* Don't switch to quoted-printable for long lines if already using base64
-* Fixed Travis-CI config when run on PHP 7
-* Added Google XOAUTH2 authentication mechanism, thanks to @sherryl4george
-* Add address parser for RFC822-format addresses
-* Update MS Office MIME types
-* Don't convert line breaks when using quoted-printable encoding
-* Handle MS Exchange returning an invalid empty AUTH-type list in EHLO
-* Don't set name or filename properties on MIME parts that don't have one
-
-## Version 5.2.10 (May 4th 2015)
-* Add custom header getter
-* Use `application/javascript` for .js attachments
-* Improve RFC2821 compliance for timelimits, especially for end-of-data
-* Add Azerbaijani translations (Thanks to @mirjalal)
-* Minor code cleanup for robustness
-* Add Indonesian translations (Thanks to @ceceprawiro)
-* Avoid `error_log` Debugoutput naming clash
-* Add ability to parse server capabilities in response to EHLO (useful for SendGrid etc)
-* Amended default values for WordWrap to match RFC
-* Remove html2text converter class (has incompatible license)
-* Provide new mechanism for injecting html to text converters
-* Improve pointers to docs and support in README
-* Add example file upload script
-* Refactor and major cleanup of EasyPeasyICS, now a lot more usable
-* Make set() method simpler and more reliable
-* Add Malay translation (Thanks to @nawawi)
-* Add Bulgarian translation (Thanks to @mialy)
-* Add Armenian translation (Thanks to Hrayr Grigoryan)
-* Add Slovenian translation (Thanks to Klemen Tušar)
-* More efficient word wrapping
-* Add support for S/MIME signing with additional CA certificate (thanks to @IgitBuh)
-* Fix incorrect MIME structure when using S/MIME signing and isMail() (#372)
-* Improved checks and error messages for missing extensions
-* Store and report SMTP errors more consistently
-* Add MIME multipart preamble for better Outlook compatibility
-* Enable TLS encryption automatically if the server offers it
-* Provide detailed errors when individual recipients fail
-* Report more errors when connecting
-* Add extras classes to composer classmap
-* Expose stream_context_create options via new SMTPOptions property
-* Automatic encoding switch to quoted-printable if message lines are too long
-* Add Korean translation (Thanks to @ChalkPE)
-* Provide a pointer to troubleshooting docs on SMTP connection failure
-
-## Version 5.2.9 (Sept 25th 2014)
-* **Important: The autoloader is no longer autoloaded by the PHPMailer class**
-* Update html2text from https://github.com/mtibben/html2text
-* Improve Arabic translations (Thanks to @tarekdj)
-* Consistent handling of connection variables in SMTP and POP3
-* PHPDoc cleanup
-* Update composer to use PHPUnit 4.1
-* Pass consistent params to callbacks
-* More consistent handling of error states and debug output
-* Use property defaults, remove constructors
-* Remove unreachable code
-* Use older regex validation pattern for troublesome PCRE library versions
-* Improve PCRE detection in older PHP versions
-* Handle debug output consistently, and always in UTF-8
-* Allow user-defined debug output method via a callable
-* msgHTML now converts data URIs to embedded images
-* SMTP::getLastReply() will now always be populated
-* Improved example code in README
-* Ensure long filenames in Content-Disposition are encoded correctly
-* Simplify SMTP debug output mechanism, clarify levels with constants
-* Add SMTP connection check example
-* Simplify examples, don't use mysql* functions
-
-## Version 5.2.8 (May 14th 2014)
-* Increase timeout to match RFC2821 section 4.5.3.2 and thus not fail greetdelays, fixes #104
-* Add timestamps to default debug output
-* Add connection events and new level 3 to debug output options
-* Chinese language update (Thanks to @binaryoung)
-* Allow custom Mailer types (Thanks to @michield)
-* Cope with spaces around SMTP host specs
-* Fix processing of multiple hosts in connect string
-* Added Galician translation (Thanks to @donatorouco)
-* Autoloader now prepends
-* Docs updates
-* Add Latvian translation (Thanks to @eddsstudio)
-* Add Belarusian translation (Thanks to @amaksymiuk)
-* Make autoloader work better on older PHP versions
-* Avoid double-encoding if mbstring is overloading mail()
-* Add Portuguese translation (Thanks to @Jonadabe)
-* Make quoted-printable encoder respect line ending setting
-* Improve Chinese translation (Thanks to @PeterDaveHello)
-* Add Georgian translation (Thanks to @akalongman)
-* Add Greek translation (Thanks to @lenasterg)
-* Fix serverHostname on PHP < 5.3
-* Improve performance of SMTP class
-* Implement automatic 7bit downgrade
-* Add Vietnamese translation (Thanks to @vinades)
-* Improve example images, switch to PNG
-* Add Croatian translation (Thanks to @hrvoj3e)
-* Remove setting the Return-Path and deprecate the Return-path property - it's just wrong!
-* Fix language file loading if CWD has changed (@stephandesouza)
-* Add HTML5 email validation pattern
-* Improve Turkish translations (Thanks to @yasinaydin)
-* Improve Romanian translations (Thanks to @aflorea)
-* Check php.ini for path to sendmail/qmail before using default
-* Improve Farsi translation (Thanks to @MHM5000)
-* Don't use quoted-printable encoding for multipart types
-* Add Serbian translation (Thanks to ajevremovic at gmail.com)
-* Remove useless PHP5 check
-* Use SVG for build status badges
-* Store MessageDate on creation
-* Better default behaviour for validateAddress
-
-## Version 5.2.7 (September 12th 2013)
-* Add Ukrainian translation from @Krezalis
-* Support for do_verp
-* Fix bug in CRAM-MD5 AUTH
-* Propagate Debugoutput option to SMTP class (@Reblutus)
-* Determine MIME type of attachments automatically
-* Add cross-platform, multibyte-safe pathinfo replacement (with tests) and use it
-* Add a new 'html' Debugoutput type
-* Clean up SMTP debug output, remove embedded HTML
-* Some small changes in header formatting to improve IETF msglint test results
-* Update test_script to use some recently changed features, rename to code_generator
-* Generated code actually works!
-* Update SyntaxHighlighter
-* Major overhaul and cleanup of example code
-* New PHPMailer graphic
-* msgHTML now uses RFC2392-compliant content ids
-* Add line break normalization function and use it in msgHTML
-* Don't set unnecessary reply-to addresses
-* Make fakesendmail.sh a bit cleaner and safer
-* Set a content-transfer-encoding on multiparts (fixes msglint error)
-* Fix cid generation in msgHTML (Thanks to @digitalthought)
-* Fix handling of multiple SMTP servers (Thanks to @NanoCaiordo)
-* SMTP->connect() now supports stream context options (Thanks to @stanislavdavid)
-* Add support for iCal event alternatives (Thanks to @reblutus)
-* Update to Polish language file (Thanks to Krzysztof Kowalewski)
-* Update to Norwegian language file (Thanks to @datagutten)
-* Update to Hungarian language file (Thanks to @dominicus-75)
-* Add Persian/Farsi translation from @jaii
-* Make SMTPDebug property type match type in SMTP class
-* Add unit tests for DKIM
-* Major refactor of SMTP class
-* Reformat to PSR-2 coding standard
-* Introduce autoloader
-* Allow overriding of SMTP class
-* Overhaul of PHPDocs
-* Fix broken Q-encoding
-* Czech language update (Thanks to @nemelu)
-* Removal of excess blank lines in messages
-* Added fake POP server and unit tests for POP-before-SMTP
-
-## Version 5.2.6 (April 11th 2013)
-* Reflect move to PHPMailer GitHub organisation at https://github.com/PHPMailer/PHPMailer
-* Fix unbumped version numbers
-* Update packagist.org with new location
-* Clean up Changelog
-
-## Version 5.2.5 (April 6th 2013)
-* First official release after move from Google Code
-* Fixes for qmail when sending via mail()
-* Merge in changes from Google code 5.2.4 release
-* Minor coding standards cleanup in SMTP class
-* Improved unit tests, now tests S/MIME signing
-* Travis-CI support on GitHub, runs tests with fake SMTP server
-
-## Version 5.2.4 (February 19, 2013)
-* Fix tag and version bug.
-* un-deprecate isSMTP(), isMail(), IsSendmail() and isQmail().
-* Numerous translation updates
-
-## Version 5.2.3 (February 8, 2013)
-* Fix issue with older PCREs and ValidateAddress() (Bugz: 124)
-* Add CRAM-MD5 authentication, thanks to Elijah madden, https://github.com/okonomiyaki3000
-* Replacement of obsolete Quoted-Printable encoder with a much better implementation
-* Composer package definition
-* New language added: Hebrew
-
-## Version 5.2.2 (December 3, 2012)
-* Some fixes and syncs from https://github.com/Synchro/PHPMailer
-* Add Slovak translation, thanks to Michal Tinka
-
-## Version 5.2.2-rc2 (November 6, 2012)
-* Fix SMTP server rotation (Bugz: 118)
-* Allow override of autogen'ed 'Date' header (for Drupal's
- og_mailinglist module)
-* No whitespace after '-f' option (Bugz: 116)
-* Work around potential warning (Bugz: 114)
-
-## Version 5.2.2-rc1 (September 28, 2012)
-* Header encoding works with long lines (Bugz: 93)
-* Turkish language update (Bugz: 94)
-* undefined $pattern in EncodeQ bug squashed (Bugz: 98)
-* use of mail() in safe_mode now works (Bugz: 96)
-* ValidateAddress() now 'public static' so people can override the
- default and use their own validation scheme.
-* ValidateAddress() no longer uses broken FILTER_VALIDATE_EMAIL
-* Added in AUTH PLAIN SMTP authentication
-
-## Version 5.2.2-beta2 (August 17, 2012)
-* Fixed Postfix VERP support (Bugz: 92)
-* Allow action_function callbacks to pass/use
- the From address (passed as final param)
-* Prevent inf look for get_lines() (Bugz: 77)
-* New public var ($UseSendmailOptions). Only pass sendmail()
- options iff we really are using sendmail or something sendmail
- compatible. (Bugz: 75)
-* default setting for LE returned to "\n" due to popular demand.
-
-## Version 5.2.2-beta1 (July 13, 2012)
-* Expose PreSend() and PostSend() as public methods to allow
- for more control if serializing message sending.
-* GetSentMIMEMessage() only constructs the message copy when
- needed. Save memory.
-* Only pass params to mail() if the underlying MTA is
- "sendmail" (as defined as "having the string sendmail
- in its pathname") [#69]
-* Attachments now work with Amazon SES and others [Bugz#70]
-* Debug output now sent to stdout (via echo) or error_log [Bugz#5]
-* New var: Debugoutput (for above) [Bugz#5]
-* SMTP reads now Timeout aware (new var: Timeout=15) [Bugz#71]
-* SMTP reads now can have a Timelimit associated with them
- (new var: Timelimit=30)[Bugz#71]
-* Fix quoting issue associated with charsets
-* default setting for LE is now RFC compliant: "\r\n"
-* Return-Path can now be user defined (new var: ReturnPath)
- (the default is "" which implies no change from previous
- behavior, which was to use either From or Sender) [Bugz#46]
-* X-Mailer header can now be disabled (by setting to a
- whitespace string, eg " ") [Bugz#66]
-* Bugz closed: #68, #60, #42, #43, #59, #55, #66, #48, #49,
- #52, #31, #41, #5. #70, #69
-
-## Version 5.2.1 (January 16, 2012)
-* Closed several bugs #5
-* Performance improvements
-* MsgHTML() now returns the message as required.
-* New method: GetSentMIMEMessage() (returns full copy of sent message)
-
-## Version 5.2 (July 19, 2011)
-* protected MIME body and header
-* better DKIM DNS Resource Record support
-* better aly handling
-* htmlfilter class added to extras
-* moved to Apache Extras
-
-## Version 5.1 (October 20, 2009)
-* fixed filename issue with AddStringAttachment (thanks to Tony)
-* fixed "SingleTo" property, now works with Senmail, Qmail, and SMTP in
- addition to PHP mail()
-* added DKIM digital signing functionality, new properties:
- - DKIM_domain (sets the domain name)
- - DKIM_private (holds DKIM private key)
- - DKIM_passphrase (holds your DKIM passphrase)
- - DKIM_selector (holds the DKIM "selector")
- - DKIM_identity (holds the identifying email address)
-* added callback function support
- - callback function parameters include:
- result, to, cc, bcc, subject and body
- - see the test/test_callback.php file for usage.
-* added "auto" identity functionality
- - can automatically add:
- - Return-path (if Sender not set)
- - Reply-To (if ReplyTo not set)
- - can be disabled:
- - $mail->SetFrom('yourname@yourdomain.com','First Last',false);
- - or by adding the $mail->Sender and/or $mail->ReplyTo properties
-
-Note: "auto" identity added to help with emails ending up in spam or junk boxes because of missing headers
-
-## Version 5.0.2 (May 24, 2009)
-* Fix for missing attachments when inline graphics are present
-* Fix for missing Cc in header when using SMTP (mail was sent,
- but not displayed in header -- Cc receiver only saw email To:
- line and no Cc line, but did get the email (To receiver
- saw same)
-
-## Version 5.0.1 (April 05, 2009)
-* Temporary fix for missing attachments
-
-## Version 5.0.0 (April 02, 2009)
-With the release of this version, we are initiating a new version numbering
-system to differentiate from the PHP4 version of PHPMailer.
-Most notable in this release is fully object oriented code.
-
-### class.smtp.php:
-* Refactored class.smtp.php to support new exception handling
-* code size reduced from 29.2 Kb to 25.6 Kb
-* Removed unnecessary functions from class.smtp.php:
- - public function Expand($name) {
- - public function Help($keyword="") {
- - public function Noop() {
- - public function Send($from) {
- - public function SendOrMail($from) {
- - public function Verify($name) {
-
-### class.phpmailer.php:
-* Refactored class.phpmailer.php with new exception handling
-* Changed processing functionality of Sendmail and Qmail so they cannot be
- inadvertently used
-* removed getFile() function, just became a simple wrapper for
- file_get_contents()
-* added check for PHP version (will gracefully exit if not at least PHP 5.0)
-* enhanced code to check if an attachment source is the same as an embedded or
- inline graphic source to eliminate duplicate attachments
-
-### New /test_script
-We have written a test script you can use to test the script as part of your
-installation. Once you press submit, the test script will send a multi-mime
-email with either the message you type in or an HTML email with an inline
-graphic. Two attachments are included in the email (one of the attachments
-is also the inline graphic so you can see that only one copy of the graphic
-is sent in the email). The test script will also display the functional
-script that you can copy/paste to your editor to duplicate the functionality.
-
-### New examples
-All new examples in both basic and advanced modes. Advanced examples show
- Exception handling.
-
-### PHPDocumentator (phpdocs) documentation for PHPMailer version 5.0.0
-All new documentation
-
-## Version 2.3 (November 06, 2008)
-* added Arabic language (many thanks to Bahjat Al Mostafa)
-* removed English language from language files and made it a default within
- class.phpmailer.php - if no language is found, it will default to use
- the english language translation
-* fixed public/private declarations
-* corrected line 1728, $basedir to $directory
-* added $sign_cert_file to avoid improper duplicate use of $sign_key_file
-* corrected $this->Hello on line 612 to $this->Helo
-* changed default of $LE to "\r\n" to comply with RFC 2822. Can be set by the user
- if default is not acceptable
-* removed trim() from return results in EncodeQP
-* /test and three files it contained are removed from version 2.3
-* fixed phpunit.php for compliance with PHP5
-* changed $this->AltBody = $textMsg; to $this->AltBody = html_entity_decode($textMsg);
-* We have removed the /phpdoc from the downloads. All documentation is now on
- the http://phpmailer.codeworxtech.com website.
-
-## Version 2.2.1 () July 19 2008
-* fixed line 1092 in class.smtp.php (my apologies, error on my part)
-
-## Version 2.2 () July 15 2008
-* Fixed redirect issue (display of UTF-8 in thank you redirect)
-* fixed error in getResponse function declaration (class.pop3.php)
-* PHPMailer now PHP6 compliant
-* fixed line 1092 in class.smtp.php (endless loop from missing = sign)
-
-## Version 2.1 (Wed, June 04 2008)
-NOTE: WE HAVE A NEW LANGUAGE VARIABLE FOR DIGITALLY SIGNED S/MIME EMAILS. IF YOU CAN HELP WITH LANGUAGES OTHER THAN ENGLISH AND SPANISH, IT WOULD BE APPRECIATED.
-
-* added S/MIME functionality (ability to digitally sign emails)
- BIG THANKS TO "sergiocambra" for posting this patch back in November 2007.
- The "Signed Emails" functionality adds the Sign method to pass the private key
- filename and the password to read it, and then email will be sent with
- content-type multipart/signed and with the digital signature attached.
-* fully compatible with E_STRICT error level
- - Please note:
- In about half the test environments this development version was subjected
- to, an error was thrown for the date() functions used (line 1565 and 1569).
- This is NOT a PHPMailer error, it is the result of an incorrectly configured
- PHP5 installation. The fix is to modify your 'php.ini' file and include the
- date.timezone = Etc/UTC (or your own zone)
- directive, to your own server timezone
- - If you do get this error, and are unable to access your php.ini file:
- In your PHP script, add
- `date_default_timezone_set('Etc/UTC');`
- - do not try to use
- `$myVar = date_default_timezone_get();`
- as a test, it will throw an error.
-* added ability to define path (mainly for embedded images)
- function `MsgHTML($message,$basedir='')` ... where:
- `$basedir` is the fully qualified path
-* fixed `MsgHTML()` function:
- - Embedded Images where images are specified by `://` will not be altered or embedded
-* fixed the return value of SMTP exit code ( pclose )
-* addressed issue of multibyte characters in subject line and truncating
-* added ability to have user specified Message ID
- (default is still that PHPMailer create a unique Message ID)
-* corrected unidentified message type to 'application/octet-stream'
-* fixed chunk_split() multibyte issue (thanks to Colin Brown, et al).
-* added check for added attachments
-* enhanced conversion of HTML to text in MsgHTML (thanks to "brunny")
-
-## Version 2.1.0beta2 (Sun, Dec 02 2007)
-* implemented updated EncodeQP (thanks to coolbru, aka Marcus Bointon)
-* finished all testing, all known bugs corrected, enhancements tested
-
-Note: will NOT work with PHP4.
-
-Please note, this is BETA software **DO NOT USE THIS IN PRODUCTION OR LIVE PROJECTS; INTENDED STRICTLY FOR TESTING**
-
-## Version 2.1.0beta1
-Please note, this is BETA software
-** DO NOT USE THIS IN PRODUCTION OR LIVE PROJECTS
- INTENDED STRICTLY FOR TESTING
-
-## Version 2.0.0 rc2 (Fri, Nov 16 2007), interim release
-* implements new property to control VERP in class.smtp.php
- example (requires instantiating class.smtp.php):
- $mail->do_verp = true;
-* POP-before-SMTP functionality included, thanks to Richard Davey
- (see class.pop3.php & pop3_before_smtp_test.php for examples)
-* included example showing how to use PHPMailer with GMAIL
-* fixed the missing Cc in SendMail() and Mail()
-
-## Version 2.0.0 rc1 (Thu, Nov 08 2007), interim release
-* dramatically simplified using inline graphics ... it's fully automated and requires no user input
-* added automatic document type detection for attachments and pictures
-* added MsgHTML() function to replace Body tag for HTML emails
-* fixed the SendMail security issues (input validation vulnerability)
-* enhanced the AddAddresses functionality so that the "Name" portion is used in the email address
-* removed the need to use the AltBody method (set from the HTML, or default text used)
-* set the PHP Mail() function as the default (still support SendMail, SMTP Mail)
-* removed the need to set the IsHTML property (set automatically)
-* added Estonian language file by Indrek Päri
-* added header injection patch
-* added "set" method to permit users to create their own pseudo-properties like 'X-Headers', etc.
-* fixed warning message in SMTP get_lines method
-* added TLS/SSL SMTP support.
-* PHPMailer has been tested with PHP4 (4.4.7) and PHP5 (5.2.7)
-* Works with PHP installed as a module or as CGI-PHP
-NOTE: will NOT work with PHP5 in E_STRICT error mode
-
-## Version 1.73 (Sun, Jun 10 2005)
-* Fixed denial of service bug: http://www.cybsec.com/vuln/PHPMailer-DOS.pdf
-* Now has a total of 20 translations
-* Fixed alt attachments bug: http://tinyurl.com/98u9k
-
-## Version 1.72 (Wed, May 25 2004)
-* Added Dutch, Swedish, Czech, Norwegian, and Turkish translations.
-* Received: Removed this method because spam filter programs like
- SpamAssassin reject this header.
-* Fixed error count bug.
-* SetLanguage default is now "language/".
-* Fixed magic_quotes_runtime bug.
-
-## Version 1.71 (Tue, Jul 28 2003)
-* Made several speed enhancements
-* Added German and Italian translation files
-* Fixed HELO/AUTH bugs on keep-alive connects
-* Now provides an error message if language file does not load
-* Fixed attachment EOL bug
-* Updated some unclear documentation
-* Added additional tests and improved others
-
-## Version 1.70 (Mon, Jun 20 2003)
-* Added SMTP keep-alive support
-* Added IsError method for error detection
-* Added error message translation support (SetLanguage)
-* Refactored many methods to increase library performance
-* Hello now sends the newer EHLO message before HELO as per RFC 2821
-* Removed the boundary class and replaced it with GetBoundary
-* Removed queue support methods
-* New $Hostname variable
-* New Message-ID header
-* Received header reformat
-* Helo variable default changed to $Hostname
-* Removed extra spaces in Content-Type definition (#667182)
-* Return-Path should be set to Sender when set
-* Adds Q or B encoding to headers when necessary
-* quoted-encoding should now encode NULs \000
-* Fixed encoding of body/AltBody (#553370)
-* Adds "To: undisclosed-recipients:;" when all recipients are hidden (BCC)
-* Multiple bug fixes
-
-## Version 1.65 (Fri, Aug 09 2002)
-* Fixed non-visible attachment bug (#585097) for Outlook
-* SMTP connections are now closed after each transaction
-* Fixed SMTP::Expand return value
-* Converted SMTP class documentation to phpDocumentor format
-
-## Version 1.62 (Wed, Jun 26 2002)
-* Fixed multi-attach bug
-* Set proper word wrapping
-* Reduced memory use with attachments
-* Added more debugging
-* Changed documentation to phpDocumentor format
-
-## Version 1.60 (Sat, Mar 30 2002)
-* Sendmail pipe and address patch (Christian Holtje)
-* Added embedded image and read confirmation support (A. Ognio)
-* Added unit tests
-* Added SMTP timeout support (*nix only)
-* Added possibly temporary PluginDir variable for SMTP class
-* Added LE message line ending variable
-* Refactored boundary and attachment code
-* Eliminated SMTP class warnings
-* Added SendToQueue method for future queuing support
-
-## Version 1.54 (Wed, Dec 19 2001)
-* Add some queuing support code
-* Fixed a pesky multi/alt bug
-* Messages are no longer forced to have "To" addresses
-
-## Version 1.50 (Thu, Nov 08 2001)
-* Fix extra lines when not using SMTP mailer
-* Set WordWrap variable to int with a zero default
-
-## Version 1.47 (Tue, Oct 16 2001)
-* Fixed Received header code format
-* Fixed AltBody order error
-* Fixed alternate port warning
-
-## Version 1.45 (Tue, Sep 25 2001)
-* Added enhanced SMTP debug support
-* Added support for multiple ports on SMTP
-* Added Received header for tracing
-* Fixed AddStringAttachment encoding
-* Fixed possible header name quote bug
-* Fixed wordwrap() trim bug
-* Couple other small bug fixes
-
-## Version 1.41 (Wed, Aug 22 2001)
-* Fixed AltBody bug w/o attachments
-* Fixed rfc_date() for certain mail servers
-
-## Version 1.40 (Sun, Aug 12 2001)
-* Added multipart/alternative support (AltBody)
-* Documentation update
-* Fixed bug in Mercury MTA
-
-## Version 1.29 (Fri, Aug 03 2001)
-* Added AddStringAttachment() method
-* Added SMTP authentication support
-
-## Version 1.28 (Mon, Jul 30 2001)
-* Fixed a typo in SMTP class
-* Fixed header issue with Imail (win32) SMTP server
-* Made fopen() calls for attachments use "rb" to fix win32 error
-
-## Version 1.25 (Mon, Jul 02 2001)
-* Added RFC 822 date fix (Patrice)
-* Added improved error handling by adding a $ErrorInfo variable
-* Removed MailerDebug variable (obsolete with new error handler)
-
-## Version 1.20 (Mon, Jun 25 2001)
-* Added quoted-printable encoding (Patrice)
-* Set Version as public and removed PrintVersion()
-* Changed phpdoc to only display public variables and methods
-
-## Version 1.19 (Thu, Jun 21 2001)
-* Fixed MS Mail header bug
-* Added fix for Bcc problem with mail(). *Does not work on Win32*
- (See PHP bug report: http://www.php.net/bugs.php?id=11616)
-* mail() no longer passes a fifth parameter when not needed
-
-## Version 1.15 (Fri, Jun 15 2001)
-Note: these changes contributed by Patrice Fournier
-* Changed all remaining \n to \r\n
-* Bcc: header no longer written to message except
- when sent directly to sendmail
-* Added a small message to non-MIME compliant mail reader
-* Added Sender variable to change the Sender email
- used in -f for sendmail/mail and in 'MAIL FROM' for smtp mode
-* Changed boundary setting to a place it will be set only once
-* Removed transfer encoding for whole message when using multipart
-* Message body now uses Encoding in multipart messages
-* Can set encoding and type to attachments 7bit, 8bit
- and binary attachment are sent as is, base64 are encoded
-* Can set Encoding to base64 to send 8 bits body
- through 7 bits servers
-
-## Version 1.10 (Tue, Jun 12 2001)
-* Fixed win32 mail header bug (printed out headers in message body)
-
-## Version 1.09 (Fri, Jun 08 2001)
-* Changed date header to work with Netscape mail programs
-* Altered phpdoc documentation
-
-## Version 1.08 (Tue, Jun 05 2001)
-* Added enhanced error-checking
-* Added phpdoc documentation to source
-
-## Version 1.06 (Fri, Jun 01 2001)
-* Added optional name for file attachments
-
-## Version 1.05 (Tue, May 29 2001)
-* Code cleanup
-* Eliminated sendmail header warning message
-* Fixed possible SMTP error
-
-## Version 1.03 (Thu, May 24 2001)
-* Fixed problem where qmail sends out duplicate messages
-
-## Version 1.02 (Wed, May 23 2001)
-* Added multiple recipient and attachment Clear* methods
-* Added Sendmail public variable
-* Fixed problem with loading SMTP library multiple times
-
-## Version 0.98 (Tue, May 22 2001)
-* Fixed problem with redundant mail hosts sending out multiple messages
-* Added additional error handler code
-* Added AddCustomHeader() function
-* Added support for Microsoft mail client headers (affects priority)
-* Fixed small bug with Mailer variable
-* Added PrintVersion() function
-
-## Version 0.92 (Tue, May 15 2001)
-* Changed file names to class.phpmailer.php and class.smtp.php to match
- current PHP class trend.
-* Fixed problem where body not being printed when a message is attached
-* Several small bug fixes
-
-## Version 0.90 (Tue, April 17 2001)
-* Initial public release
diff --git a/core/l/PHPMailer/composer.json b/core/l/PHPMailer/composer.json
deleted file mode 100755
index ee4e890..0000000
--- a/core/l/PHPMailer/composer.json
+++ /dev/null
@@ -1,55 +0,0 @@
-{
- "name": "phpmailer/phpmailer",
- "type": "library",
- "description": "PHPMailer is a full-featured email creation and transfer class for PHP",
- "authors": [
- {
- "name": "Marcus Bointon",
- "email": "phpmailer@synchromedia.co.uk"
- },
- {
- "name": "Jim Jagielski",
- "email": "jimjag@gmail.com"
- },
- {
- "name": "Andy Prevost",
- "email": "codeworxtech@users.sourceforge.net"
- },
- {
- "name": "Brent R. Matzelle"
- }
- ],
- "require": {
- "php": ">=5.5.0",
- "ext-ctype": "*",
- "ext-filter": "*"
- },
- "require-dev": {
- "friendsofphp/php-cs-fixer": "^2.2",
- "phpdocumentor/phpdocumentor": "2.*",
- "phpunit/phpunit": "^4.8 || ^5.7",
- "zendframework/zend-serializer": "2.7.*",
- "doctrine/annotations": "1.2.*",
- "zendframework/zend-eventmanager": "3.0.*",
- "zendframework/zend-i18n": "2.7.3"
- },
- "suggest": {
- "psr/log": "For optional PSR-3 debug logging",
- "league/oauth2-google": "Needed for Google XOAUTH2 authentication",
- "hayageek/oauth2-yahoo": "Needed for Yahoo XOAUTH2 authentication",
- "stevenmaguire/oauth2-microsoft": "Needed for Microsoft XOAUTH2 authentication",
- "ext-mbstring": "Needed to send email in multibyte encoding charset",
- "symfony/polyfill-mbstring": "To support UTF-8 if the Mbstring PHP extension is not enabled (^1.2)"
- },
- "autoload": {
- "psr-4": {
- "PHPMailer\\PHPMailer\\": "src/"
- }
- },
- "autoload-dev": {
- "psr-4": {
- "PHPMailer\\Test\\": "test/"
- }
- },
- "license": "LGPL-2.1"
-}
diff --git a/core/l/PHPMailer/docs/README.md b/core/l/PHPMailer/docs/README.md
deleted file mode 100755
index 6f50cd7..0000000
--- a/core/l/PHPMailer/docs/README.md
+++ /dev/null
@@ -1,7 +0,0 @@
-# PHPMailer Documentation
-
-Pre-built PHPMailer API documentation is not provided with the PHP classes, but you can generate API documentation by running `phpdoc` in the top-level folder of this project, and documentation will be generated in this folder. You will need to have [phpDocumentor](https://www.phpdoc.org) installed, though you will already have that if you installed PHPMailer using composer with dev modules enabled. This documentation is also [available online](http://phpmailer.github.io/PHPMailer/), though it may not be quite up to date or match your version exactly. The configuration for phpdoc is in the [phpdoc.dist.xml file](https://github.com/PHPMailer/PHPMailer/blob/master/phpdoc.dist.xml).
-
-Further help and information is available in [the PHPMailer README](https://github.com/PHPMailer/PHPMailer/blob/master/README.md), [the examples folder](https://github.com/PHPMailer/PHPMailer/tree/master/examples), and in [the GitHub wiki](https://github.com/PHPMailer/PHPMailer/wiki).
-
-Fixes and additions to documentation are welcome - please submit pull requests or improve wiki pages.
\ No newline at end of file
diff --git a/core/l/PHPMailer/examples/DKIM_gen_keys.phps b/core/l/PHPMailer/examples/DKIM_gen_keys.phps
deleted file mode 100755
index f732c17..0000000
--- a/core/l/PHPMailer/examples/DKIM_gen_keys.phps
+++ /dev/null
@@ -1,77 +0,0 @@
- 'sha256',
- 'private_key_bits' => 2048,
- 'private_key_type' => OPENSSL_KEYTYPE_RSA,
- ]
- );
- //Save private key
- openssl_pkey_export_to_file($pk, $privatekeyfile);
- //Save public key
- $pubKey = openssl_pkey_get_details($pk);
- $publickey = $pubKey['key'];
- file_put_contents($publickeyfile, $publickey);
- $privatekey = file_get_contents($privatekeyfile);
-}
-echo "Private key (keep this private!):\n\n" . $privatekey;
-echo "\n\nPublic key:\n\n" . $publickey;
-
-//Prep public key for DNS, e.g.
-//phpmailer._domainkey.example.com IN TXT "v=DKIM1; h=sha256; t=s; p=" "MIIBIjANBg...oXlwIDAQAB"...
-$dnskey = "$selector._domainkey.$domain IN TXT";
-//Some DNS server don't like ; chars unless backslash-escaped
-$dnsvalue = '"v=DKIM1\; h=sha256\; t=s\; p=" ';
-
-//Strip and split the key into smaller parts and format for DNS
-//Many DNS systems don't like long TXT entries
-//but are OK if it's split into 255-char chunks
-//Remove PEM wrapper
-$publickey = preg_replace('/^-+.*?-+$/m', '', $publickey);
-//Strip line breaks
-$publickey = str_replace(["\r", "\n"], '', $publickey);
-//Split into chunks
-$keyparts = str_split($publickey, 253); //Becomes 255 when quotes are included
-//Quote each chunk
-foreach ($keyparts as $keypart) {
- $dnsvalue .= '"' . trim($keypart) . '" ';
-}
-echo "\n\nDNS key:\n\n" . trim($dnskey);
-echo "\n\nDNS value:\n\n" . trim($dnsvalue);
diff --git a/core/l/PHPMailer/examples/DKIM_sign.phps b/core/l/PHPMailer/examples/DKIM_sign.phps
deleted file mode 100755
index a204f93..0000000
--- a/core/l/PHPMailer/examples/DKIM_sign.phps
+++ /dev/null
@@ -1,41 +0,0 @@
-setFrom('from@example.com', 'First Last');
-$mail->addAddress('whoto@example.com', 'John Doe');
-$mail->Subject = 'PHPMailer mail() test';
-$mail->msgHTML(file_get_contents('contents.html'), __DIR__);
-
-//This should be the same as the domain of your From address
-$mail->DKIM_domain = 'example.com';
-//See the DKIM_gen_keys.phps script for making a key pair -
-//here we assume you've already done that.
-//Path to your private key:
-$mail->DKIM_private = 'dkim_private.pem';
-//Set this to your own selector
-$mail->DKIM_selector = 'phpmailer';
-//Put your private key's passphrase in here if it has one
-$mail->DKIM_passphrase = '';
-//The identity you're signing as - usually your From address
-$mail->DKIM_identity = $mail->From;
-
-//When you send, the DKIM settings will be used to sign the message
-if (!$mail->send()) {
- echo "Mailer Error: " . $mail->ErrorInfo;
-} else {
- echo "Message sent!";
-}
diff --git a/core/l/PHPMailer/examples/README.md b/core/l/PHPMailer/examples/README.md
deleted file mode 100755
index 2b7bf14..0000000
--- a/core/l/PHPMailer/examples/README.md
+++ /dev/null
@@ -1,98 +0,0 @@
-[](https://github.com/PHPMailer/PHPMailer)
-# PHPMailer code examples
-
-This folder contains a collection of examples of using [PHPMailer](https://github.com/PHPMailer/PHPMailer).
-
-## About testing email sending
-
-When working on email sending code you'll find yourself worrying about what might happen if all these test emails got sent to your mailing list. The solution is to use a fake mail server, one that acts just like the real thing, but just doesn't actually send anything out. Some offer web interfaces, feedback, logging, the ability to return specific error codes, all things that are useful for testing error handling, authentication etc. Here's a selection of mail testing tools you might like to try:
-
-* [FakeSMTP](https://github.com/Nilhcem/FakeSMTP), a Java desktop app with the ability to show an SMTP log and save messages to a folder.
-* [FakeEmail](https://github.com/isotoma/FakeEmail), a Python-based fake mail server with a web interface.
-* [smtp-sink](http://www.postfix.org/smtp-sink.1.html), part of the Postfix mail server, so you may have this installed already. This is used in the Travis-CI configuration to run PHPMailer's unit tests.
-* [smtp4dev](http://smtp4dev.codeplex.com), a dummy SMTP server for Windows.
-* [fakesendmail.sh](https://github.com/PHPMailer/PHPMailer/blob/master/test/fakesendmail.sh), part of PHPMailer's test setup, this is a shell script that emulates sendmail for testing 'mail' or 'sendmail' methods in PHPMailer.
-* [msglint](http://tools.ietf.org/tools/msglint/), not a mail server, the IETF's MIME structure analyser checks the formatting of your messages.
-
-Most of these examples use the `example.com` and `example.net` domains. These domains are reserved by IANA for illustrative purposes, as documented in [RFC 2606](http://tools.ietf.org/html/rfc2606). Don't use made-up domains like 'mydomain.com' or 'somedomain.com' in examples as someone, somewhere, probably owns them!
-
-## Security note
-Before running these examples in a web server, you'll need to rename them with '.php' extensions. They are supplied as '.phps' files which will usually be displayed with syntax highlighting by PHP instead of running them. This prevents potential security issues with running potential spam-gateway code if you happen to deploy these code examples on a live site - _please don't do that!_
-
-Similarly, don't leave your passwords in these files as they will be visible to the world!
-
-## [code_generator.phps](code_generator.phps)
-
-This script is a simple code generator - fill in the form and hit submit, and it will use what you entered to email you a message, and will also generate PHP code using your settings that you can copy and paste to use in your own apps.
-
-## [mail.phps](mail.phps)
-
-This is a basic example which creates an email message from an external HTML file, creates a plain text body, sets various addresses, adds an attachment and sends the message. It uses PHP's built-in mail() function which is the simplest to use, but relies on the presence of a local mail server, something which is not usually available on Windows. If you find yourself in that situation, either install a local mail server, or use a remote one and send using SMTP instead.
-
-## [simple_contact_form.phps](simple_contact_form.phps)
-
-This is probably the most common reason for using PHPMailer - building a contact form. This example has a basic, unstyled form and also illustrates how to filter input data before using it, how to validate addresses, how to avoid being abused as a spam gateway, and how to address messages correctly so that you don't fail SPF checks.
-
-## [exceptions.phps](exceptions.phps)
-
-Like the mail example, but shows how to use PHPMailer's optional exceptions for error handling.
-
-## [extending.phps](extending.phps)
-
-This shows how to create a subclass of PHPMailer to customise its behaviour and simplify coding in your app.
-
-## [smtp.phps](smtp.phps)
-
-A simple example sending using SMTP with authentication.
-
-## [smtp_no_auth.phps](smtp_no_auth.phps)
-
-A simple example sending using SMTP without authentication.
-
-## [send_file_upload.phps](send_file_upload.phps)
-
-Lots of people want to do this... This is a simple form which accepts a file upload and emails it.
-
-## [send_multiple_file_upload.phps](send_multiple_file_upload.phps)
-
-A slightly more complex form that allows uploading multiple files at once and sends all of them as attachments to an email.
-
-## [sendmail.phps](sendmail.phps)
-
-A simple example using sendmail. Sendmail is a program (usually found on Linux/BSD, OS X and other UNIX-alikes) that can be used to submit messages to a local mail server without a lengthy SMTP conversation. It's probably the fastest sending mechanism, but lacks some error reporting features. There are sendmail emulators for most popular mail servers including postfix, qmail, exim etc.
-
-## [gmail.phps](gmail.phps)
-
-Submitting email via Google's Gmail service is a popular use of PHPMailer. It's much the same as normal SMTP sending, just with some specific settings, namely using TLS encryption, authentication is enabled, and it connects to the SMTP submission port 587 on the smtp.gmail.com host. This example does all that.
-
-## [gmail_xoauth.phps](gmail_xoauth.phps)
-
-Gmail now likes you to use XOAUTH2 for SMTP authentication. This is extremely laborious to set up, but once it's done you can use it repeatedly and will no longer need Gmail's ineptly-named "Allow less secure apps" setting enabled. [Read the guide in the wiki](https://github.com/PHPMailer/PHPMailer/wiki/Using-Gmail-with-XOAUTH2) for how to set it up.
-
-## [pop_before_smtp.phps](pop_before_smtp.phps)
-
-Back in the stone age, before effective SMTP authentication mechanisms were available, it was common for ISPs to use POP-before-SMTP authentication. As it implies, you authenticate using the POP3 protocol (an older protocol now mostly replaced by the far superior IMAP), and then the SMTP server will allow send access from your IP address for a short while, usually 5-15 minutes. PHPMailer includes a basic POP3 protocol client with just enough functionality to carry out this sequence - it's just like a normal SMTP conversation (without authentication), but connects via POP3 first.
-
-## [mailing_list.phps](mailing_list.phps)
-
-This is a somewhat naïve, but reasonably efficient example of sending similar emails to a list of different addresses. It sets up a PHPMailer instance using SMTP, then connects to a MySQL database to retrieve a list of recipients. The code loops over this list, sending email to each person using their info and marks them as sent in the database. It makes use of SMTP keepalive which saves reconnecting and re-authenticating between each message.
-
-## [ssl_options.phps](ssl_options.phps)
-
-PHP 5.6 introduced SSL certificate verification by default, and this applies to mail servers exactly as it does to web servers. Unfortunately, SSL misconfiguration in mail servers is quite common, so this caused a common problem: those that were previously using servers with bad configs suddenly found they stopped working when they upgraded PHP. PHPMailer provides a mechanism to disable SSL certificate verification as a workaround and this example shows how to do it. Bear in mind that this is **not** a good approach - the right way is to fix your mail server config!
-
-## [smime_signed_mail.phps](smime_signed_mail.phps)
-
-An example of how to sign messages using [S/MIME](https://en.wikipedia.org/wiki/S/MIME), ensuring that your data can't be tampered with in transit, and proves to recipients that it was you that sent it.
-
-* * *
-
-## [smtp_check.phps](smtp_check.phps)
-
-This is an example showing how to use the SMTP class by itself (without PHPMailer) to check an SMTP connection.
-
-## [smtp_low_memory.phps](smtp_low_memory.phps)
-
-This demonstrates how to extend the SMTP class and make PHPMailer use it. In this case it's an effort to make the SMTP class use less memory when sending large attachments.
-
-* * *
diff --git a/core/l/PHPMailer/examples/callback.phps b/core/l/PHPMailer/examples/callback.phps
deleted file mode 100755
index 080f167..0000000
--- a/core/l/PHPMailer/examples/callback.phps
+++ /dev/null
@@ -1,75 +0,0 @@
-\n";
- }
- foreach ($cc as $address) {
- echo "Message CC to {$address[1]} <{$address[0]}>\n";
- }
- foreach ($bcc as $toaddress) {
- echo "Message BCC to {$toaddress[1]} <{$toaddress[0]}>\n";
- }
- if ($result) {
- echo "Message sent successfully\n";
- } else {
- echo "Message send failed\n";
- }
-}
-
-require_once '../vendor/autoload.php';
-
-$mail = new PHPMailer;
-
-try {
- $mail->isMail();
- $mail->setFrom('you@example.com', 'Your Name');
- $mail->addAddress('jane@example.com', 'Jane Doe');
- $mail->addCC('john@example.com', 'John Doe');
- $mail->Subject = 'PHPMailer Test Subject';
- $mail->msgHTML(file_get_contents('../examples/contents.html'));
- // optional - msgHTML will create an alternate automatically
- $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';
- $mail->addAttachment('images/phpmailer_mini.png'); // attachment
- $mail->action_function = 'callbackAction';
- $mail->send();
-} catch (Exception $e) {
- echo $e->errorMessage();
-}
-
-//Alternative approach using a closure
-try {
- $mail->action_function = function ($result, $to, $cc, $bcc, $subject, $body) {
- if ($result) {
- echo "Message sent successfully\n";
- } else {
- echo "Message send failed\n";
- }
- };
- $mail->send();
-} catch (Exception $e) {
- echo $e->errorMessage();
-}
diff --git a/core/l/PHPMailer/examples/contactform.phps b/core/l/PHPMailer/examples/contactform.phps
deleted file mode 100755
index d85e204..0000000
--- a/core/l/PHPMailer/examples/contactform.phps
+++ /dev/null
@@ -1,71 +0,0 @@
-isSMTP();
- $mail->Host = 'localhost';
- $mail->Port = 25;
-
- //Use a fixed address in your own domain as the from address
- //**DO NOT** use the submitter's address here as it will be forgery
- //and will cause your messages to fail SPF checks
- $mail->setFrom('from@example.com', 'First Last');
- //Send the message to yourself, or whoever should receive contact for submissions
- $mail->addAddress('whoto@example.com', 'John Doe');
- //Put the submitter's address in a reply-to header
- //This will fail if the address provided is invalid,
- //in which case we should ignore the whole request
- if ($mail->addReplyTo($_POST['email'], $_POST['name'])) {
- $mail->Subject = 'PHPMailer contact form';
- //Keep it simple - don't use HTML
- $mail->isHTML(false);
- //Build a simple message body
- $mail->Body = <<send()) {
- //The reason for failing to send will be in $mail->ErrorInfo
- //but you shouldn't display errors to users - process the error, log it on your server.
- $msg = 'Sorry, something went wrong. Please try again later.';
- } else {
- $msg = 'Message sent! Thanks for contacting us.';
- }
- } else {
- $msg = 'Invalid email address, message ignored.';
- }
-}
-?>
-
-
-
-
- Contact form
-
-
-
-
-
diff --git a/core/l/PHPMailer/examples/exceptions.phps b/core/l/PHPMailer/examples/exceptions.phps
deleted file mode 100755
index a053edd..0000000
--- a/core/l/PHPMailer/examples/exceptions.phps
+++ /dev/null
@@ -1,39 +0,0 @@
-setFrom('from@example.com', 'First Last');
- //Set an alternative reply-to address
- $mail->addReplyTo('replyto@example.com', 'First Last');
- //Set who the message is to be sent to
- $mail->addAddress('whoto@example.com', 'John Doe');
- //Set the subject line
- $mail->Subject = 'PHPMailer Exceptions test';
- //Read an HTML message body from an external file, convert referenced images to embedded,
- //and convert the HTML into a basic plain-text alternative body
- $mail->msgHTML(file_get_contents('contents.html'), __DIR__);
- //Replace the plain text body with one created manually
- $mail->AltBody = 'This is a plain-text message body';
- //Attach an image file
- $mail->addAttachment('images/phpmailer_mini.png');
- //send the message
- //Note that we don't need check the response from this because it will throw an exception if it has trouble
- $mail->send();
- echo 'Message sent!';
-} catch (Exception $e) {
- echo $e->errorMessage(); //Pretty error messages from PHPMailer
-} catch (\Exception $e) { //The leading slash means the Global PHP Exception class will be caught
- echo $e->getMessage(); //Boring error messages from anything else!
-}
diff --git a/core/l/PHPMailer/examples/extending.phps b/core/l/PHPMailer/examples/extending.phps
deleted file mode 100755
index e7b2d88..0000000
--- a/core/l/PHPMailer/examples/extending.phps
+++ /dev/null
@@ -1,70 +0,0 @@
-setFrom('joe@example.com', 'Joe User');
- //Send via SMTP
- $this->isSMTP();
- //Equivalent to setting `Host`, `Port` and `SMTPSecure` all at once
- $this->Host = 'tls://smtp.example.com:587';
- //Set an HTML and plain-text body, import relative image references
- $this->msgHTML($body, './images/');
- //Show debug output
- $this->SMTPDebug = 2;
- //Inject a new debug output handler
- $this->Debugoutput = function ($str, $level) {
- echo "Debug level $level; message: $str\n";
- };
- }
-
- //Extend the send function
- public function send()
- {
- $this->Subject = '[Yay for me!] ' . $this->Subject;
- $r = parent::send();
- echo "I sent a message with subject " . $this->Subject;
-
- return $r;
- }
-}
-
-//Now creating and sending a message becomes simpler when you use this class in your app code
-try {
- //Instantiate your new class, making use of the new `$body` parameter
- $mail = new myPHPMailer(true, 'This is the message body');
- // Now you only need to set things that are different from the defaults you defined
- $mail->addAddress('jane@example.com', 'Jane User');
- $mail->Subject = 'Here is the subject';
- $mail->addAttachment(__FILE__, 'myPHPMailer.php');
- $mail->send(); //no need to check for errors - the exception handler will do it
-} catch (Exception $e) {
- //Note that this is catching the PHPMailer Exception class, not the global \Exception type!
- echo "Caught a " . get_class($e) . ": " . $e->getMessage();
-}
diff --git a/core/l/PHPMailer/examples/gmail.phps b/core/l/PHPMailer/examples/gmail.phps
deleted file mode 100755
index 349c4b4..0000000
--- a/core/l/PHPMailer/examples/gmail.phps
+++ /dev/null
@@ -1,98 +0,0 @@
-isSMTP();
-
-//Enable SMTP debugging
-// 0 = off (for production use)
-// 1 = client messages
-// 2 = client and server messages
-$mail->SMTPDebug = 2;
-
-//Set the hostname of the mail server
-$mail->Host = 'smtp.gmail.com';
-// use
-// $mail->Host = gethostbyname('smtp.gmail.com');
-// if your network does not support SMTP over IPv6
-
-//Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
-$mail->Port = 587;
-
-//Set the encryption system to use - ssl (deprecated) or tls
-$mail->SMTPSecure = 'tls';
-
-//Whether to use SMTP authentication
-$mail->SMTPAuth = true;
-
-//Username to use for SMTP authentication - use full email address for gmail
-$mail->Username = "username@gmail.com";
-
-//Password to use for SMTP authentication
-$mail->Password = "yourpassword";
-
-//Set who the message is to be sent from
-$mail->setFrom('from@example.com', 'First Last');
-
-//Set an alternative reply-to address
-$mail->addReplyTo('replyto@example.com', 'First Last');
-
-//Set who the message is to be sent to
-$mail->addAddress('whoto@example.com', 'John Doe');
-
-//Set the subject line
-$mail->Subject = 'PHPMailer GMail SMTP test';
-
-//Read an HTML message body from an external file, convert referenced images to embedded,
-//convert HTML into a basic plain-text alternative body
-$mail->msgHTML(file_get_contents('contents.html'), __DIR__);
-
-//Replace the plain text body with one created manually
-$mail->AltBody = 'This is a plain-text message body';
-
-//Attach an image file
-$mail->addAttachment('images/phpmailer_mini.png');
-
-//send the message, check for errors
-if (!$mail->send()) {
- echo "Mailer Error: " . $mail->ErrorInfo;
-} else {
- echo "Message sent!";
- //Section 2: IMAP
- //Uncomment these to save your message in the 'Sent Mail' folder.
- #if (save_mail($mail)) {
- # echo "Message saved!";
- #}
-}
-
-//Section 2: IMAP
-//IMAP commands requires the PHP IMAP Extension, found at: https://php.net/manual/en/imap.setup.php
-//Function to call which uses the PHP imap_*() functions to save messages: https://php.net/manual/en/book.imap.php
-//You can use imap_getmailboxes($imapStream, '/imap/ssl') to get a list of available folders or labels, this can
-//be useful if you are trying to get this working on a non-Gmail IMAP server.
-function save_mail($mail)
-{
- //You can change 'Sent Mail' to any other folder or tag
- $path = "{imap.gmail.com:993/imap/ssl}[Gmail]/Sent Mail";
-
- //Tell your server to open an IMAP connection using the same username and password as you used for SMTP
- $imapStream = imap_open($path, $mail->Username, $mail->Password);
-
- $result = imap_append($imapStream, $path, $mail->getSentMIMEMessage());
- imap_close($imapStream);
-
- return $result;
-}
diff --git a/core/l/PHPMailer/examples/gmail_xoauth.phps b/core/l/PHPMailer/examples/gmail_xoauth.phps
deleted file mode 100755
index f2cc1e8..0000000
--- a/core/l/PHPMailer/examples/gmail_xoauth.phps
+++ /dev/null
@@ -1,105 +0,0 @@
-isSMTP();
-
-//Enable SMTP debugging
-// 0 = off (for production use)
-// 1 = client messages
-// 2 = client and server messages
-$mail->SMTPDebug = 2;
-
-//Set the hostname of the mail server
-$mail->Host = 'smtp.gmail.com';
-
-//Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
-$mail->Port = 587;
-
-//Set the encryption system to use - ssl (deprecated) or tls
-$mail->SMTPSecure = 'tls';
-
-//Whether to use SMTP authentication
-$mail->SMTPAuth = true;
-
-//Set AuthType to use XOAUTH2
-$mail->AuthType = 'XOAUTH2';
-
-//Fill in authentication details here
-//Either the gmail account owner, or the user that gave consent
-$email = 'someone@gmail.com';
-$clientId = 'RANDOMCHARS-----duv1n2.apps.googleusercontent.com';
-$clientSecret = 'RANDOMCHARS-----lGyjPcRtvP';
-
-//Obtained by configuring and running get_oauth_token.php
-//after setting up an app in Google Developer Console.
-$refreshToken = 'RANDOMCHARS-----DWxgOvPT003r-yFUV49TQYag7_Aod7y0';
-
-//Create a new OAuth2 provider instance
-$provider = new Google(
- [
- 'clientId' => $clientId,
- 'clientSecret' => $clientSecret,
- ]
-);
-
-//Pass the OAuth provider instance to PHPMailer
-$mail->setOAuth(
- new OAuth(
- [
- 'provider' => $provider,
- 'clientId' => $clientId,
- 'clientSecret' => $clientSecret,
- 'refreshToken' => $refreshToken,
- 'userName' => $email,
- ]
- )
-);
-
-//Set who the message is to be sent from
-//For gmail, this generally needs to be the same as the user you logged in as
-$mail->setFrom($email, 'First Last');
-
-//Set who the message is to be sent to
-$mail->addAddress('someone@gmail.com', 'John Doe');
-
-//Set the subject line
-$mail->Subject = 'PHPMailer GMail XOAUTH2 SMTP test';
-
-//Read an HTML message body from an external file, convert referenced images to embedded,
-//convert HTML into a basic plain-text alternative body
-$mail->CharSet = 'utf-8';
-$mail->msgHTML(file_get_contents('contentsutf8.html'), __DIR__);
-
-//Replace the plain text body with one created manually
-$mail->AltBody = 'This is a plain-text message body';
-
-//Attach an image file
-$mail->addAttachment('images/phpmailer_mini.png');
-
-//send the message, check for errors
-if (!$mail->send()) {
- echo "Mailer Error: " . $mail->ErrorInfo;
-} else {
- echo "Message sent!";
-}
diff --git a/core/l/PHPMailer/examples/images/phpmailer.png b/core/l/PHPMailer/examples/images/phpmailer.png
deleted file mode 100755
index 9bdd83c..0000000
Binary files a/core/l/PHPMailer/examples/images/phpmailer.png and /dev/null differ
diff --git a/core/l/PHPMailer/examples/images/phpmailer_mini.png b/core/l/PHPMailer/examples/images/phpmailer_mini.png
deleted file mode 100755
index e6915f4..0000000
Binary files a/core/l/PHPMailer/examples/images/phpmailer_mini.png and /dev/null differ
diff --git a/core/l/PHPMailer/examples/mail.phps b/core/l/PHPMailer/examples/mail.phps
deleted file mode 100755
index 35d331f..0000000
--- a/core/l/PHPMailer/examples/mail.phps
+++ /dev/null
@@ -1,34 +0,0 @@
-setFrom('from@example.com', 'First Last');
-//Set an alternative reply-to address
-$mail->addReplyTo('replyto@example.com', 'First Last');
-//Set who the message is to be sent to
-$mail->addAddress('whoto@example.com', 'John Doe');
-//Set the subject line
-$mail->Subject = 'PHPMailer mail() test';
-//Read an HTML message body from an external file, convert referenced images to embedded,
-//convert HTML into a basic plain-text alternative body
-$mail->msgHTML(file_get_contents('contents.html'), __DIR__);
-//Replace the plain text body with one created manually
-$mail->AltBody = 'This is a plain-text message body';
-//Attach an image file
-$mail->addAttachment('images/phpmailer_mini.png');
-
-//send the message, check for errors
-if (!$mail->send()) {
- echo "Mailer Error: " . $mail->ErrorInfo;
-} else {
- echo "Message sent!";
-}
diff --git a/core/l/PHPMailer/examples/mailing_list.phps b/core/l/PHPMailer/examples/mailing_list.phps
deleted file mode 100755
index 828be19..0000000
--- a/core/l/PHPMailer/examples/mailing_list.phps
+++ /dev/null
@@ -1,65 +0,0 @@
-isSMTP();
-$mail->Host = 'smtp.example.com';
-$mail->SMTPAuth = true;
-$mail->SMTPKeepAlive = true; // SMTP connection will not close after each email sent, reduces SMTP overhead
-$mail->Port = 25;
-$mail->Username = 'yourname@example.com';
-$mail->Password = 'yourpassword';
-$mail->setFrom('list@example.com', 'List manager');
-$mail->addReplyTo('list@example.com', 'List manager');
-
-$mail->Subject = "PHPMailer Simple database mailing list test";
-
-//Same body for all messages, so set this before the sending loop
-//If you generate a different body for each recipient (e.g. you're using a templating system),
-//set it inside the loop
-$mail->msgHTML($body);
-//msgHTML also sets AltBody, but if you want a custom one, set it afterwards
-$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';
-
-//Connect to the database and select the recipients from your mailing list that have not yet been sent to
-//You'll need to alter this to match your database
-$mysql = mysqli_connect('localhost', 'username', 'password');
-mysqli_select_db($mysql, 'mydb');
-$result = mysqli_query($mysql, 'SELECT full_name, email, photo FROM mailinglist WHERE sent = FALSE');
-
-foreach ($result as $row) {
- $mail->addAddress($row['email'], $row['full_name']);
- if (!empty($row['photo'])) {
- $mail->addStringAttachment($row['photo'], 'YourPhoto.jpg'); //Assumes the image data is stored in the DB
- }
-
- if (!$mail->send()) {
- echo "Mailer Error (" . str_replace("@", "@", $row["email"]) . ') ' . $mail->ErrorInfo . ' ';
- break; //Abandon sending
- } else {
- echo "Message sent to :" . $row['full_name'] . ' (' . str_replace("@", "@", $row['email']) . ') ';
- //Mark it as sent in the DB
- mysqli_query(
- $mysql,
- "UPDATE mailinglist SET sent = TRUE WHERE email = '" .
- mysqli_real_escape_string($mysql, $row['email']) . "'"
- );
- }
- // Clear all addresses and attachments for next loop
- $mail->clearAddresses();
- $mail->clearAttachments();
-}
diff --git a/core/l/PHPMailer/examples/pop_before_smtp.phps b/core/l/PHPMailer/examples/pop_before_smtp.phps
deleted file mode 100755
index 94222d8..0000000
--- a/core/l/PHPMailer/examples/pop_before_smtp.phps
+++ /dev/null
@@ -1,58 +0,0 @@
-isSMTP();
- //Enable SMTP debugging
- // 0 = off (for production use)
- // 1 = client messages
- // 2 = client and server messages
- $mail->SMTPDebug = 2;
- //Set the hostname of the mail server
- $mail->Host = 'mail.example.com';
- //Set the SMTP port number - likely to be 25, 465 or 587
- $mail->Port = 25;
- //Whether to use SMTP authentication
- $mail->SMTPAuth = false;
- //Set who the message is to be sent from
- $mail->setFrom('from@example.com', 'First Last');
- //Set an alternative reply-to address
- $mail->addReplyTo('replyto@example.com', 'First Last');
- //Set who the message is to be sent to
- $mail->addAddress('whoto@example.com', 'John Doe');
- //Set the subject line
- $mail->Subject = 'PHPMailer POP-before-SMTP test';
- //Read an HTML message body from an external file, convert referenced images to embedded,
- //and convert the HTML into a basic plain-text alternative body
- $mail->msgHTML(file_get_contents('contents.html'), __DIR__);
- //Replace the plain text body with one created manually
- $mail->AltBody = 'This is a plain-text message body';
- //Attach an image file
- $mail->addAttachment('images/phpmailer_mini.png');
- //send the message
- //Note that we don't need check the response from this because it will throw an exception if it has trouble
- $mail->send();
- echo 'Message sent!';
-} catch (Exception $e) {
- echo $e->errorMessage(); //Pretty error messages from PHPMailer
-} catch (\Exception $e) {
- echo $e->getMessage(); //Boring error messages from anything else!
-}
diff --git a/core/l/PHPMailer/examples/send_file_upload.phps b/core/l/PHPMailer/examples/send_file_upload.phps
deleted file mode 100755
index 2ba3e41..0000000
--- a/core/l/PHPMailer/examples/send_file_upload.phps
+++ /dev/null
@@ -1,52 +0,0 @@
-setFrom('from@example.com', 'First Last');
- $mail->addAddress('whoto@example.com', 'John Doe');
- $mail->Subject = 'PHPMailer file sender';
- $mail->Body = 'My message body';
- // Attach the uploaded file
- $mail->addAttachment($uploadfile, 'My uploaded file');
- if (!$mail->send()) {
- $msg .= "Mailer Error: " . $mail->ErrorInfo;
- } else {
- $msg .= "Message sent!";
- }
- } else {
- $msg .= 'Failed to move file to ' . $uploadfile;
- }
-}
-?>
-
-
-
-
- PHPMailer Upload
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/core/l/PHPMailer/examples/send_multiple_file_upload.phps b/core/l/PHPMailer/examples/send_multiple_file_upload.phps
deleted file mode 100755
index 1c96b10..0000000
--- a/core/l/PHPMailer/examples/send_multiple_file_upload.phps
+++ /dev/null
@@ -1,53 +0,0 @@
-setFrom('from@example.com', 'First Last');
- $mail->addAddress('whoto@example.com', 'John Doe');
- $mail->Subject = 'PHPMailer file sender';
- $mail->Body = 'My message body';
- //Attach multiple files one by one
- for ($ct = 0; $ct < count($_FILES['userfile']['tmp_name']); $ct++) {
- $uploadfile = tempnam(sys_get_temp_dir(), hash('sha256', $_FILES['userfile']['name'][$ct]));
- $filename = $_FILES['userfile']['name'][$ct];
- if (move_uploaded_file($_FILES['userfile']['tmp_name'][$ct], $uploadfile)) {
- $mail->addAttachment($uploadfile, $filename);
- } else {
- $msg .= 'Failed to move file to ' . $uploadfile;
- }
- }
- if (!$mail->send()) {
- $msg .= "Mailer Error: " . $mail->ErrorInfo;
- } else {
- $msg .= "Message sent!";
- }
-}
-?>
-
-
-
-
- PHPMailer Upload
-
-
-
-
-
-
-
diff --git a/core/l/PHPMailer/examples/sendmail.phps b/core/l/PHPMailer/examples/sendmail.phps
deleted file mode 100755
index c05649b..0000000
--- a/core/l/PHPMailer/examples/sendmail.phps
+++ /dev/null
@@ -1,36 +0,0 @@
-isSendmail();
-//Set who the message is to be sent from
-$mail->setFrom('from@example.com', 'First Last');
-//Set an alternative reply-to address
-$mail->addReplyTo('replyto@example.com', 'First Last');
-//Set who the message is to be sent to
-$mail->addAddress('whoto@example.com', 'John Doe');
-//Set the subject line
-$mail->Subject = 'PHPMailer sendmail test';
-//Read an HTML message body from an external file, convert referenced images to embedded,
-//convert HTML into a basic plain-text alternative body
-$mail->msgHTML(file_get_contents('contents.html'), __DIR__);
-//Replace the plain text body with one created manually
-$mail->AltBody = 'This is a plain-text message body';
-//Attach an image file
-$mail->addAttachment('images/phpmailer_mini.png');
-
-//send the message, check for errors
-if (!$mail->send()) {
- echo "Mailer Error: " . $mail->ErrorInfo;
-} else {
- echo "Message sent!";
-}
diff --git a/core/l/PHPMailer/examples/simple_contact_form.phps b/core/l/PHPMailer/examples/simple_contact_form.phps
deleted file mode 100755
index 650364c..0000000
--- a/core/l/PHPMailer/examples/simple_contact_form.phps
+++ /dev/null
@@ -1,101 +0,0 @@
-isSMTP();
- $mail->Host = 'localhost';
- $mail->Port = 2500;
- $mail->CharSet = 'utf-8';
- //It's important not to use the submitter's address as the from address as it's forgery,
- //which will cause your messages to fail SPF checks.
- //Use an address in your own domain as the from address, put the submitter's address in a reply-to
- $mail->setFrom('contact@example.com', (empty($name) ? 'Contact form' : $name));
- $mail->addAddress($to);
- $mail->addReplyTo($email, $name);
- $mail->Subject = 'Contact form: ' . $subject;
- $mail->Body = "Contact form submission\n\n" . $query;
- if (!$mail->send()) {
- $msg .= "Mailer Error: " . $mail->ErrorInfo;
- } else {
- $msg .= "Message sent!";
- }
- }
-} ?>
-
-
-
-
- PHPMailer Contact Form
-
-
-
';
- }
- }
-
- /**
- * Get an array of error messages, if any.
- *
- * @return array
- */
- public function getErrors()
- {
- return $this->errors;
- }
-
- /**
- * POP3 connection error handler.
- *
- * @param int $errno
- * @param string $errstr
- * @param string $errfile
- * @param int $errline
- */
- protected function catchWarning($errno, $errstr, $errfile, $errline)
- {
- $this->setError(
- 'Connecting to the POP3 server raised a PHP warning:' .
- "errno: $errno errstr: $errstr; errfile: $errfile; errline: $errline"
- );
- }
-}
diff --git a/core/l/PHPMailer/src/SMTP.php b/core/l/PHPMailer/src/SMTP.php
deleted file mode 100755
index 27b752e..0000000
--- a/core/l/PHPMailer/src/SMTP.php
+++ /dev/null
@@ -1,1325 +0,0 @@
-
- * @author Jim Jagielski (jimjag)
- * @author Andy Prevost (codeworxtech)
- * @author Brent R. Matzelle (original founder)
- * @copyright 2012 - 2017 Marcus Bointon
- * @copyright 2010 - 2012 Jim Jagielski
- * @copyright 2004 - 2009 Andy Prevost
- * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
- * @note This program is distributed in the hope that it will be useful - WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-namespace PHPMailer\PHPMailer;
-
-/**
- * PHPMailer RFC821 SMTP email transport class.
- * Implements RFC 821 SMTP commands and provides some utility methods for sending mail to an SMTP server.
- *
- * @author Chris Ryan
- * @author Marcus Bointon
- */
-class SMTP
-{
- /**
- * The PHPMailer SMTP version number.
- *
- * @var string
- */
- const VERSION = '6.0.3';
-
- /**
- * SMTP line break constant.
- *
- * @var string
- */
- const LE = "\r\n";
-
- /**
- * The SMTP port to use if one is not specified.
- *
- * @var int
- */
- const DEFAULT_PORT = 25;
-
- /**
- * The maximum line length allowed by RFC 2822 section 2.1.1.
- *
- * @var int
- */
- const MAX_LINE_LENGTH = 998;
-
- /**
- * Debug level for no output.
- */
- const DEBUG_OFF = 0;
-
- /**
- * Debug level to show client -> server messages.
- */
- const DEBUG_CLIENT = 1;
-
- /**
- * Debug level to show client -> server and server -> client messages.
- */
- const DEBUG_SERVER = 2;
-
- /**
- * Debug level to show connection status, client -> server and server -> client messages.
- */
- const DEBUG_CONNECTION = 3;
-
- /**
- * Debug level to show all messages.
- */
- const DEBUG_LOWLEVEL = 4;
-
- /**
- * Debug output level.
- * Options:
- * * self::DEBUG_OFF (`0`) No debug output, default
- * * self::DEBUG_CLIENT (`1`) Client commands
- * * self::DEBUG_SERVER (`2`) Client commands and server responses
- * * self::DEBUG_CONNECTION (`3`) As DEBUG_SERVER plus connection status
- * * self::DEBUG_LOWLEVEL (`4`) Low-level data output, all messages.
- *
- * @var int
- */
- public $do_debug = self::DEBUG_OFF;
-
- /**
- * How to handle debug output.
- * Options:
- * * `echo` Output plain-text as-is, appropriate for CLI
- * * `html` Output escaped, line breaks converted to ` `, appropriate for browser output
- * * `error_log` Output to error log as configured in php.ini
- * Alternatively, you can provide a callable expecting two params: a message string and the debug level:
- *
- * ```php
- * $smtp->Debugoutput = function($str, $level) {echo "debug level $level; message: $str";};
- * ```
- *
- * Alternatively, you can pass in an instance of a PSR-3 compatible logger, though only `debug`
- * level output is used:
- *
- * ```php
- * $mail->Debugoutput = new myPsr3Logger;
- * ```
- *
- * @var string|callable|\Psr\Log\LoggerInterface
- */
- public $Debugoutput = 'echo';
-
- /**
- * Whether to use VERP.
- *
- * @see http://en.wikipedia.org/wiki/Variable_envelope_return_path
- * @see http://www.postfix.org/VERP_README.html Info on VERP
- *
- * @var bool
- */
- public $do_verp = false;
-
- /**
- * The timeout value for connection, in seconds.
- * Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2.
- * This needs to be quite high to function correctly with hosts using greetdelay as an anti-spam measure.
- *
- * @see http://tools.ietf.org/html/rfc2821#section-4.5.3.2
- *
- * @var int
- */
- public $Timeout = 300;
-
- /**
- * How long to wait for commands to complete, in seconds.
- * Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2.
- *
- * @var int
- */
- public $Timelimit = 300;
-
- /**
- * Patterns to extract an SMTP transaction id from reply to a DATA command.
- * The first capture group in each regex will be used as the ID.
- * MS ESMTP returns the message ID, which may not be correct for internal tracking.
- *
- * @var string[]
- */
- protected $smtp_transaction_id_patterns = [
- 'exim' => '/[0-9]{3} OK id=(.*)/',
- 'sendmail' => '/[0-9]{3} 2.0.0 (.*) Message/',
- 'postfix' => '/[0-9]{3} 2.0.0 Ok: queued as (.*)/',
- 'Microsoft_ESMTP' => '/[0-9]{3} 2.[0-9].0 (.*)@(?:.*) Queued mail for delivery/',
- 'Amazon_SES' => '/[0-9]{3} Ok (.*)/',
- 'SendGrid' => '/[0-9]{3} Ok: queued as (.*)/',
- ];
-
- /**
- * The last transaction ID issued in response to a DATA command,
- * if one was detected.
- *
- * @var string|bool|null
- */
- protected $last_smtp_transaction_id;
-
- /**
- * The socket for the server connection.
- *
- * @var ?resource
- */
- protected $smtp_conn;
-
- /**
- * Error information, if any, for the last SMTP command.
- *
- * @var array
- */
- protected $error = [
- 'error' => '',
- 'detail' => '',
- 'smtp_code' => '',
- 'smtp_code_ex' => '',
- ];
-
- /**
- * The reply the server sent to us for HELO.
- * If null, no HELO string has yet been received.
- *
- * @var string|null
- */
- protected $helo_rply = null;
-
- /**
- * The set of SMTP extensions sent in reply to EHLO command.
- * Indexes of the array are extension names.
- * Value at index 'HELO' or 'EHLO' (according to command that was sent)
- * represents the server name. In case of HELO it is the only element of the array.
- * Other values can be boolean TRUE or an array containing extension options.
- * If null, no HELO/EHLO string has yet been received.
- *
- * @var array|null
- */
- protected $server_caps = null;
-
- /**
- * The most recent reply received from the server.
- *
- * @var string
- */
- protected $last_reply = '';
-
- /**
- * Output debugging info via a user-selected method.
- *
- * @param string $str Debug string to output
- * @param int $level The debug level of this message; see DEBUG_* constants
- *
- * @see SMTP::$Debugoutput
- * @see SMTP::$do_debug
- */
- protected function edebug($str, $level = 0)
- {
- if ($level > $this->do_debug) {
- return;
- }
- //Is this a PSR-3 logger?
- if ($this->Debugoutput instanceof \Psr\Log\LoggerInterface) {
- $this->Debugoutput->debug($str);
-
- return;
- }
- //Avoid clash with built-in function names
- if (!in_array($this->Debugoutput, ['error_log', 'html', 'echo']) and is_callable($this->Debugoutput)) {
- call_user_func($this->Debugoutput, $str, $level);
-
- return;
- }
- switch ($this->Debugoutput) {
- case 'error_log':
- //Don't output, just log
- error_log($str);
- break;
- case 'html':
- //Cleans up output a bit for a better looking, HTML-safe output
- echo gmdate('Y-m-d H:i:s'), ' ', htmlentities(
- preg_replace('/[\r\n]+/', '', $str),
- ENT_QUOTES,
- 'UTF-8'
- ), " \n";
- break;
- case 'echo':
- default:
- //Normalize line breaks
- $str = preg_replace('/\r\n|\r/ms', "\n", $str);
- echo gmdate('Y-m-d H:i:s'),
- "\t",
- //Trim trailing space
- trim(
- //Indent for readability, except for trailing break
- str_replace(
- "\n",
- "\n \t ",
- trim($str)
- )
- ),
- "\n";
- }
- }
-
- /**
- * Connect to an SMTP server.
- *
- * @param string $host SMTP server IP or host name
- * @param int $port The port number to connect to
- * @param int $timeout How long to wait for the connection to open
- * @param array $options An array of options for stream_context_create()
- *
- * @return bool
- */
- public function connect($host, $port = null, $timeout = 30, $options = [])
- {
- static $streamok;
- //This is enabled by default since 5.0.0 but some providers disable it
- //Check this once and cache the result
- if (null === $streamok) {
- $streamok = function_exists('stream_socket_client');
- }
- // Clear errors to avoid confusion
- $this->setError('');
- // Make sure we are __not__ connected
- if ($this->connected()) {
- // Already connected, generate error
- $this->setError('Already connected to a server');
-
- return false;
- }
- if (empty($port)) {
- $port = self::DEFAULT_PORT;
- }
- // Connect to the SMTP server
- $this->edebug(
- "Connection: opening to $host:$port, timeout=$timeout, options=" .
- (count($options) > 0 ? var_export($options, true) : 'array()'),
- self::DEBUG_CONNECTION
- );
- $errno = 0;
- $errstr = '';
- if ($streamok) {
- $socket_context = stream_context_create($options);
- set_error_handler([$this, 'errorHandler']);
- $this->smtp_conn = stream_socket_client(
- $host . ':' . $port,
- $errno,
- $errstr,
- $timeout,
- STREAM_CLIENT_CONNECT,
- $socket_context
- );
- restore_error_handler();
- } else {
- //Fall back to fsockopen which should work in more places, but is missing some features
- $this->edebug(
- 'Connection: stream_socket_client not available, falling back to fsockopen',
- self::DEBUG_CONNECTION
- );
- set_error_handler([$this, 'errorHandler']);
- $this->smtp_conn = fsockopen(
- $host,
- $port,
- $errno,
- $errstr,
- $timeout
- );
- restore_error_handler();
- }
- // Verify we connected properly
- if (!is_resource($this->smtp_conn)) {
- $this->setError(
- 'Failed to connect to server',
- '',
- (string) $errno,
- (string) $errstr
- );
- $this->edebug(
- 'SMTP ERROR: ' . $this->error['error']
- . ": $errstr ($errno)",
- self::DEBUG_CLIENT
- );
-
- return false;
- }
- $this->edebug('Connection: opened', self::DEBUG_CONNECTION);
- // SMTP server can take longer to respond, give longer timeout for first read
- // Windows does not have support for this timeout function
- if (substr(PHP_OS, 0, 3) != 'WIN') {
- $max = ini_get('max_execution_time');
- // Don't bother if unlimited
- if (0 != $max and $timeout > $max) {
- @set_time_limit($timeout);
- }
- stream_set_timeout($this->smtp_conn, $timeout, 0);
- }
- // Get any announcement
- $announce = $this->get_lines();
- $this->edebug('SERVER -> CLIENT: ' . $announce, self::DEBUG_SERVER);
-
- return true;
- }
-
- /**
- * Initiate a TLS (encrypted) session.
- *
- * @return bool
- */
- public function startTLS()
- {
- if (!$this->sendCommand('STARTTLS', 'STARTTLS', 220)) {
- return false;
- }
-
- //Allow the best TLS version(s) we can
- $crypto_method = STREAM_CRYPTO_METHOD_TLS_CLIENT;
-
- //PHP 5.6.7 dropped inclusion of TLS 1.1 and 1.2 in STREAM_CRYPTO_METHOD_TLS_CLIENT
- //so add them back in manually if we can
- if (defined('STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT')) {
- $crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT;
- $crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT;
- }
-
- // Begin encrypted connection
- set_error_handler([$this, 'errorHandler']);
- $crypto_ok = stream_socket_enable_crypto(
- $this->smtp_conn,
- true,
- $crypto_method
- );
- restore_error_handler();
-
- return (bool) $crypto_ok;
- }
-
- /**
- * Perform SMTP authentication.
- * Must be run after hello().
- *
- * @see hello()
- *
- * @param string $username The user name
- * @param string $password The password
- * @param string $authtype The auth type (CRAM-MD5, PLAIN, LOGIN, XOAUTH2)
- * @param OAuth $OAuth An optional OAuth instance for XOAUTH2 authentication
- *
- * @return bool True if successfully authenticated
- */
- public function authenticate(
- $username,
- $password,
- $authtype = null,
- $OAuth = null
- ) {
- if (!$this->server_caps) {
- $this->setError('Authentication is not allowed before HELO/EHLO');
-
- return false;
- }
-
- if (array_key_exists('EHLO', $this->server_caps)) {
- // SMTP extensions are available; try to find a proper authentication method
- if (!array_key_exists('AUTH', $this->server_caps)) {
- $this->setError('Authentication is not allowed at this stage');
- // 'at this stage' means that auth may be allowed after the stage changes
- // e.g. after STARTTLS
-
- return false;
- }
-
- $this->edebug('Auth method requested: ' . ($authtype ? $authtype : 'UNKNOWN'), self::DEBUG_LOWLEVEL);
- $this->edebug(
- 'Auth methods available on the server: ' . implode(',', $this->server_caps['AUTH']),
- self::DEBUG_LOWLEVEL
- );
-
- //If we have requested a specific auth type, check the server supports it before trying others
- if (!in_array($authtype, $this->server_caps['AUTH'])) {
- $this->edebug('Requested auth method not available: ' . $authtype, self::DEBUG_LOWLEVEL);
- $authtype = null;
- }
-
- if (empty($authtype)) {
- //If no auth mechanism is specified, attempt to use these, in this order
- //Try CRAM-MD5 first as it's more secure than the others
- foreach (['CRAM-MD5', 'LOGIN', 'PLAIN', 'XOAUTH2'] as $method) {
- if (in_array($method, $this->server_caps['AUTH'])) {
- $authtype = $method;
- break;
- }
- }
- if (empty($authtype)) {
- $this->setError('No supported authentication methods found');
-
- return false;
- }
- self::edebug('Auth method selected: ' . $authtype, self::DEBUG_LOWLEVEL);
- }
-
- if (!in_array($authtype, $this->server_caps['AUTH'])) {
- $this->setError("The requested authentication method \"$authtype\" is not supported by the server");
-
- return false;
- }
- } elseif (empty($authtype)) {
- $authtype = 'LOGIN';
- }
- switch ($authtype) {
- case 'PLAIN':
- // Start authentication
- if (!$this->sendCommand('AUTH', 'AUTH PLAIN', 334)) {
- return false;
- }
- // Send encoded username and password
- if (!$this->sendCommand(
- 'User & Password',
- base64_encode("\0" . $username . "\0" . $password),
- 235
- )
- ) {
- return false;
- }
- break;
- case 'LOGIN':
- // Start authentication
- if (!$this->sendCommand('AUTH', 'AUTH LOGIN', 334)) {
- return false;
- }
- if (!$this->sendCommand('Username', base64_encode($username), 334)) {
- return false;
- }
- if (!$this->sendCommand('Password', base64_encode($password), 235)) {
- return false;
- }
- break;
- case 'CRAM-MD5':
- // Start authentication
- if (!$this->sendCommand('AUTH CRAM-MD5', 'AUTH CRAM-MD5', 334)) {
- return false;
- }
- // Get the challenge
- $challenge = base64_decode(substr($this->last_reply, 4));
-
- // Build the response
- $response = $username . ' ' . $this->hmac($challenge, $password);
-
- // send encoded credentials
- return $this->sendCommand('Username', base64_encode($response), 235);
- case 'XOAUTH2':
- //The OAuth instance must be set up prior to requesting auth.
- if (null === $OAuth) {
- return false;
- }
- $oauth = $OAuth->getOauth64();
-
- // Start authentication
- if (!$this->sendCommand('AUTH', 'AUTH XOAUTH2 ' . $oauth, 235)) {
- return false;
- }
- break;
- default:
- $this->setError("Authentication method \"$authtype\" is not supported");
-
- return false;
- }
-
- return true;
- }
-
- /**
- * Calculate an MD5 HMAC hash.
- * Works like hash_hmac('md5', $data, $key)
- * in case that function is not available.
- *
- * @param string $data The data to hash
- * @param string $key The key to hash with
- *
- * @return string
- */
- protected function hmac($data, $key)
- {
- if (function_exists('hash_hmac')) {
- return hash_hmac('md5', $data, $key);
- }
-
- // The following borrowed from
- // http://php.net/manual/en/function.mhash.php#27225
-
- // RFC 2104 HMAC implementation for php.
- // Creates an md5 HMAC.
- // Eliminates the need to install mhash to compute a HMAC
- // by Lance Rushing
-
- $bytelen = 64; // byte length for md5
- if (strlen($key) > $bytelen) {
- $key = pack('H*', md5($key));
- }
- $key = str_pad($key, $bytelen, chr(0x00));
- $ipad = str_pad('', $bytelen, chr(0x36));
- $opad = str_pad('', $bytelen, chr(0x5c));
- $k_ipad = $key ^ $ipad;
- $k_opad = $key ^ $opad;
-
- return md5($k_opad . pack('H*', md5($k_ipad . $data)));
- }
-
- /**
- * Check connection state.
- *
- * @return bool True if connected
- */
- public function connected()
- {
- if (is_resource($this->smtp_conn)) {
- $sock_status = stream_get_meta_data($this->smtp_conn);
- if ($sock_status['eof']) {
- // The socket is valid but we are not connected
- $this->edebug(
- 'SMTP NOTICE: EOF caught while checking if connected',
- self::DEBUG_CLIENT
- );
- $this->close();
-
- return false;
- }
-
- return true; // everything looks good
- }
-
- return false;
- }
-
- /**
- * Close the socket and clean up the state of the class.
- * Don't use this function without first trying to use QUIT.
- *
- * @see quit()
- */
- public function close()
- {
- $this->setError('');
- $this->server_caps = null;
- $this->helo_rply = null;
- if (is_resource($this->smtp_conn)) {
- // close the connection and cleanup
- fclose($this->smtp_conn);
- $this->smtp_conn = null; //Makes for cleaner serialization
- $this->edebug('Connection: closed', self::DEBUG_CONNECTION);
- }
- }
-
- /**
- * Send an SMTP DATA command.
- * Issues a data command and sends the msg_data to the server,
- * finializing the mail transaction. $msg_data is the message
- * that is to be send with the headers. Each header needs to be
- * on a single line followed by a with the message headers
- * and the message body being separated by an additional .
- * Implements RFC 821: DATA .
- *
- * @param string $msg_data Message data to send
- *
- * @return bool
- */
- public function data($msg_data)
- {
- //This will use the standard timelimit
- if (!$this->sendCommand('DATA', 'DATA', 354)) {
- return false;
- }
-
- /* The server is ready to accept data!
- * According to rfc821 we should not send more than 1000 characters on a single line (including the LE)
- * so we will break the data up into lines by \r and/or \n then if needed we will break each of those into
- * smaller lines to fit within the limit.
- * We will also look for lines that start with a '.' and prepend an additional '.'.
- * NOTE: this does not count towards line-length limit.
- */
-
- // Normalize line breaks before exploding
- $lines = explode("\n", str_replace(["\r\n", "\r"], "\n", $msg_data));
-
- /* To distinguish between a complete RFC822 message and a plain message body, we check if the first field
- * of the first line (':' separated) does not contain a space then it _should_ be a header and we will
- * process all lines before a blank line as headers.
- */
-
- $field = substr($lines[0], 0, strpos($lines[0], ':'));
- $in_headers = false;
- if (!empty($field) and strpos($field, ' ') === false) {
- $in_headers = true;
- }
-
- foreach ($lines as $line) {
- $lines_out = [];
- if ($in_headers and $line == '') {
- $in_headers = false;
- }
- //Break this line up into several smaller lines if it's too long
- //Micro-optimisation: isset($str[$len]) is faster than (strlen($str) > $len),
- while (isset($line[self::MAX_LINE_LENGTH])) {
- //Working backwards, try to find a space within the last MAX_LINE_LENGTH chars of the line to break on
- //so as to avoid breaking in the middle of a word
- $pos = strrpos(substr($line, 0, self::MAX_LINE_LENGTH), ' ');
- //Deliberately matches both false and 0
- if (!$pos) {
- //No nice break found, add a hard break
- $pos = self::MAX_LINE_LENGTH - 1;
- $lines_out[] = substr($line, 0, $pos);
- $line = substr($line, $pos);
- } else {
- //Break at the found point
- $lines_out[] = substr($line, 0, $pos);
- //Move along by the amount we dealt with
- $line = substr($line, $pos + 1);
- }
- //If processing headers add a LWSP-char to the front of new line RFC822 section 3.1.1
- if ($in_headers) {
- $line = "\t" . $line;
- }
- }
- $lines_out[] = $line;
-
- //Send the lines to the server
- foreach ($lines_out as $line_out) {
- //RFC2821 section 4.5.2
- if (!empty($line_out) and $line_out[0] == '.') {
- $line_out = '.' . $line_out;
- }
- $this->client_send($line_out . static::LE, 'DATA');
- }
- }
-
- //Message data has been sent, complete the command
- //Increase timelimit for end of DATA command
- $savetimelimit = $this->Timelimit;
- $this->Timelimit = $this->Timelimit * 2;
- $result = $this->sendCommand('DATA END', '.', 250);
- $this->recordLastTransactionID();
- //Restore timelimit
- $this->Timelimit = $savetimelimit;
-
- return $result;
- }
-
- /**
- * Send an SMTP HELO or EHLO command.
- * Used to identify the sending server to the receiving server.
- * This makes sure that client and server are in a known state.
- * Implements RFC 821: HELO
- * and RFC 2821 EHLO.
- *
- * @param string $host The host name or IP to connect to
- *
- * @return bool
- */
- public function hello($host = '')
- {
- //Try extended hello first (RFC 2821)
- return (bool) ($this->sendHello('EHLO', $host) or $this->sendHello('HELO', $host));
- }
-
- /**
- * Send an SMTP HELO or EHLO command.
- * Low-level implementation used by hello().
- *
- * @param string $hello The HELO string
- * @param string $host The hostname to say we are
- *
- * @return bool
- *
- * @see hello()
- */
- protected function sendHello($hello, $host)
- {
- $noerror = $this->sendCommand($hello, $hello . ' ' . $host, 250);
- $this->helo_rply = $this->last_reply;
- if ($noerror) {
- $this->parseHelloFields($hello);
- } else {
- $this->server_caps = null;
- }
-
- return $noerror;
- }
-
- /**
- * Parse a reply to HELO/EHLO command to discover server extensions.
- * In case of HELO, the only parameter that can be discovered is a server name.
- *
- * @param string $type `HELO` or `EHLO`
- */
- protected function parseHelloFields($type)
- {
- $this->server_caps = [];
- $lines = explode("\n", $this->helo_rply);
-
- foreach ($lines as $n => $s) {
- //First 4 chars contain response code followed by - or space
- $s = trim(substr($s, 4));
- if (empty($s)) {
- continue;
- }
- $fields = explode(' ', $s);
- if (!empty($fields)) {
- if (!$n) {
- $name = $type;
- $fields = $fields[0];
- } else {
- $name = array_shift($fields);
- switch ($name) {
- case 'SIZE':
- $fields = ($fields ? $fields[0] : 0);
- break;
- case 'AUTH':
- if (!is_array($fields)) {
- $fields = [];
- }
- break;
- default:
- $fields = true;
- }
- }
- $this->server_caps[$name] = $fields;
- }
- }
- }
-
- /**
- * Send an SMTP MAIL command.
- * Starts a mail transaction from the email address specified in
- * $from. Returns true if successful or false otherwise. If True
- * the mail transaction is started and then one or more recipient
- * commands may be called followed by a data command.
- * Implements RFC 821: MAIL FROM:.
- *
- * @param string $from Source address of this message
- *
- * @return bool
- */
- public function mail($from)
- {
- $useVerp = ($this->do_verp ? ' XVERP' : '');
-
- return $this->sendCommand(
- 'MAIL FROM',
- 'MAIL FROM:<' . $from . '>' . $useVerp,
- 250
- );
- }
-
- /**
- * Send an SMTP QUIT command.
- * Closes the socket if there is no error or the $close_on_error argument is true.
- * Implements from RFC 821: QUIT .
- *
- * @param bool $close_on_error Should the connection close if an error occurs?
- *
- * @return bool
- */
- public function quit($close_on_error = true)
- {
- $noerror = $this->sendCommand('QUIT', 'QUIT', 221);
- $err = $this->error; //Save any error
- if ($noerror or $close_on_error) {
- $this->close();
- $this->error = $err; //Restore any error from the quit command
- }
-
- return $noerror;
- }
-
- /**
- * Send an SMTP RCPT command.
- * Sets the TO argument to $toaddr.
- * Returns true if the recipient was accepted false if it was rejected.
- * Implements from RFC 821: RCPT TO:.
- *
- * @param string $address The address the message is being sent to
- *
- * @return bool
- */
- public function recipient($address)
- {
- return $this->sendCommand(
- 'RCPT TO',
- 'RCPT TO:<' . $address . '>',
- [250, 251]
- );
- }
-
- /**
- * Send an SMTP RSET command.
- * Abort any transaction that is currently in progress.
- * Implements RFC 821: RSET .
- *
- * @return bool True on success
- */
- public function reset()
- {
- return $this->sendCommand('RSET', 'RSET', 250);
- }
-
- /**
- * Send a command to an SMTP server and check its return code.
- *
- * @param string $command The command name - not sent to the server
- * @param string $commandstring The actual command to send
- * @param int|array $expect One or more expected integer success codes
- *
- * @return bool True on success
- */
- protected function sendCommand($command, $commandstring, $expect)
- {
- if (!$this->connected()) {
- $this->setError("Called $command without being connected");
-
- return false;
- }
- //Reject line breaks in all commands
- if (strpos($commandstring, "\n") !== false or strpos($commandstring, "\r") !== false) {
- $this->setError("Command '$command' contained line breaks");
-
- return false;
- }
- $this->client_send($commandstring . static::LE, $command);
-
- $this->last_reply = $this->get_lines();
- // Fetch SMTP code and possible error code explanation
- $matches = [];
- if (preg_match('/^([0-9]{3})[ -](?:([0-9]\\.[0-9]\\.[0-9]) )?/', $this->last_reply, $matches)) {
- $code = $matches[1];
- $code_ex = (count($matches) > 2 ? $matches[2] : null);
- // Cut off error code from each response line
- $detail = preg_replace(
- "/{$code}[ -]" .
- ($code_ex ? str_replace('.', '\\.', $code_ex) . ' ' : '') . '/m',
- '',
- $this->last_reply
- );
- } else {
- // Fall back to simple parsing if regex fails
- $code = substr($this->last_reply, 0, 3);
- $code_ex = null;
- $detail = substr($this->last_reply, 4);
- }
-
- $this->edebug('SERVER -> CLIENT: ' . $this->last_reply, self::DEBUG_SERVER);
-
- if (!in_array($code, (array) $expect)) {
- $this->setError(
- "$command command failed",
- $detail,
- $code,
- $code_ex
- );
- $this->edebug(
- 'SMTP ERROR: ' . $this->error['error'] . ': ' . $this->last_reply,
- self::DEBUG_CLIENT
- );
-
- return false;
- }
-
- $this->setError('');
-
- return true;
- }
-
- /**
- * Send an SMTP SAML command.
- * Starts a mail transaction from the email address specified in $from.
- * Returns true if successful or false otherwise. If True
- * the mail transaction is started and then one or more recipient
- * commands may be called followed by a data command. This command
- * will send the message to the users terminal if they are logged
- * in and send them an email.
- * Implements RFC 821: SAML FROM:.
- *
- * @param string $from The address the message is from
- *
- * @return bool
- */
- public function sendAndMail($from)
- {
- return $this->sendCommand('SAML', "SAML FROM:$from", 250);
- }
-
- /**
- * Send an SMTP VRFY command.
- *
- * @param string $name The name to verify
- *
- * @return bool
- */
- public function verify($name)
- {
- return $this->sendCommand('VRFY', "VRFY $name", [250, 251]);
- }
-
- /**
- * Send an SMTP NOOP command.
- * Used to keep keep-alives alive, doesn't actually do anything.
- *
- * @return bool
- */
- public function noop()
- {
- return $this->sendCommand('NOOP', 'NOOP', 250);
- }
-
- /**
- * Send an SMTP TURN command.
- * This is an optional command for SMTP that this class does not support.
- * This method is here to make the RFC821 Definition complete for this class
- * and _may_ be implemented in future.
- * Implements from RFC 821: TURN .
- *
- * @return bool
- */
- public function turn()
- {
- $this->setError('The SMTP TURN command is not implemented');
- $this->edebug('SMTP NOTICE: ' . $this->error['error'], self::DEBUG_CLIENT);
-
- return false;
- }
-
- /**
- * Send raw data to the server.
- *
- * @param string $data The data to send
- * @param string $command Optionally, the command this is part of, used only for controlling debug output
- *
- * @return int|bool The number of bytes sent to the server or false on error
- */
- public function client_send($data, $command = '')
- {
- //If SMTP transcripts are left enabled, or debug output is posted online
- //it can leak credentials, so hide credentials in all but lowest level
- if (self::DEBUG_LOWLEVEL > $this->do_debug and
- in_array($command, ['User & Password', 'Username', 'Password'], true)) {
- $this->edebug('CLIENT -> SERVER: ', self::DEBUG_CLIENT);
- } else {
- $this->edebug('CLIENT -> SERVER: ' . $data, self::DEBUG_CLIENT);
- }
- set_error_handler([$this, 'errorHandler']);
- $result = fwrite($this->smtp_conn, $data);
- restore_error_handler();
-
- return $result;
- }
-
- /**
- * Get the latest error.
- *
- * @return array
- */
- public function getError()
- {
- return $this->error;
- }
-
- /**
- * Get SMTP extensions available on the server.
- *
- * @return array|null
- */
- public function getServerExtList()
- {
- return $this->server_caps;
- }
-
- /**
- * Get metadata about the SMTP server from its HELO/EHLO response.
- * The method works in three ways, dependent on argument value and current state:
- * 1. HELO/EHLO has not been sent - returns null and populates $this->error.
- * 2. HELO has been sent -
- * $name == 'HELO': returns server name
- * $name == 'EHLO': returns boolean false
- * $name == any other string: returns null and populates $this->error
- * 3. EHLO has been sent -
- * $name == 'HELO'|'EHLO': returns the server name
- * $name == any other string: if extension $name exists, returns True
- * or its options (e.g. AUTH mechanisms supported). Otherwise returns False.
- *
- * @param string $name Name of SMTP extension or 'HELO'|'EHLO'
- *
- * @return mixed
- */
- public function getServerExt($name)
- {
- if (!$this->server_caps) {
- $this->setError('No HELO/EHLO was sent');
-
- return;
- }
-
- if (!array_key_exists($name, $this->server_caps)) {
- if ('HELO' == $name) {
- return $this->server_caps['EHLO'];
- }
- if ('EHLO' == $name || array_key_exists('EHLO', $this->server_caps)) {
- return false;
- }
- $this->setError('HELO handshake was used; No information about server extensions available');
-
- return;
- }
-
- return $this->server_caps[$name];
- }
-
- /**
- * Get the last reply from the server.
- *
- * @return string
- */
- public function getLastReply()
- {
- return $this->last_reply;
- }
-
- /**
- * Read the SMTP server's response.
- * Either before eof or socket timeout occurs on the operation.
- * With SMTP we can tell if we have more lines to read if the
- * 4th character is '-' symbol. If it is a space then we don't
- * need to read anything else.
- *
- * @return string
- */
- protected function get_lines()
- {
- // If the connection is bad, give up straight away
- if (!is_resource($this->smtp_conn)) {
- return '';
- }
- $data = '';
- $endtime = 0;
- stream_set_timeout($this->smtp_conn, $this->Timeout);
- if ($this->Timelimit > 0) {
- $endtime = time() + $this->Timelimit;
- }
- $selR = [$this->smtp_conn];
- $selW = null;
- while (is_resource($this->smtp_conn) and !feof($this->smtp_conn)) {
- //Must pass vars in here as params are by reference
- if (!stream_select($selR, $selW, $selW, $this->Timelimit)) {
- $this->edebug(
- 'SMTP -> get_lines(): timed-out (' . $this->Timeout . ' sec)',
- self::DEBUG_LOWLEVEL
- );
- break;
- }
- //Deliberate noise suppression - errors are handled afterwards
- $str = @fgets($this->smtp_conn, 515);
- $this->edebug('SMTP INBOUND: "' . trim($str) . '"', self::DEBUG_LOWLEVEL);
- $data .= $str;
- // If response is only 3 chars (not valid, but RFC5321 S4.2 says it must be handled),
- // or 4th character is a space, we are done reading, break the loop,
- // string array access is a micro-optimisation over strlen
- if (!isset($str[3]) or (isset($str[3]) and $str[3] == ' ')) {
- break;
- }
- // Timed-out? Log and break
- $info = stream_get_meta_data($this->smtp_conn);
- if ($info['timed_out']) {
- $this->edebug(
- 'SMTP -> get_lines(): timed-out (' . $this->Timeout . ' sec)',
- self::DEBUG_LOWLEVEL
- );
- break;
- }
- // Now check if reads took too long
- if ($endtime and time() > $endtime) {
- $this->edebug(
- 'SMTP -> get_lines(): timelimit reached (' .
- $this->Timelimit . ' sec)',
- self::DEBUG_LOWLEVEL
- );
- break;
- }
- }
-
- return $data;
- }
-
- /**
- * Enable or disable VERP address generation.
- *
- * @param bool $enabled
- */
- public function setVerp($enabled = false)
- {
- $this->do_verp = $enabled;
- }
-
- /**
- * Get VERP address generation mode.
- *
- * @return bool
- */
- public function getVerp()
- {
- return $this->do_verp;
- }
-
- /**
- * Set error messages and codes.
- *
- * @param string $message The error message
- * @param string $detail Further detail on the error
- * @param string $smtp_code An associated SMTP error code
- * @param string $smtp_code_ex Extended SMTP code
- */
- protected function setError($message, $detail = '', $smtp_code = '', $smtp_code_ex = '')
- {
- $this->error = [
- 'error' => $message,
- 'detail' => $detail,
- 'smtp_code' => $smtp_code,
- 'smtp_code_ex' => $smtp_code_ex,
- ];
- }
-
- /**
- * Set debug output method.
- *
- * @param string|callable $method The name of the mechanism to use for debugging output, or a callable to handle it
- */
- public function setDebugOutput($method = 'echo')
- {
- $this->Debugoutput = $method;
- }
-
- /**
- * Get debug output method.
- *
- * @return string
- */
- public function getDebugOutput()
- {
- return $this->Debugoutput;
- }
-
- /**
- * Set debug output level.
- *
- * @param int $level
- */
- public function setDebugLevel($level = 0)
- {
- $this->do_debug = $level;
- }
-
- /**
- * Get debug output level.
- *
- * @return int
- */
- public function getDebugLevel()
- {
- return $this->do_debug;
- }
-
- /**
- * Set SMTP timeout.
- *
- * @param int $timeout The timeout duration in seconds
- */
- public function setTimeout($timeout = 0)
- {
- $this->Timeout = $timeout;
- }
-
- /**
- * Get SMTP timeout.
- *
- * @return int
- */
- public function getTimeout()
- {
- return $this->Timeout;
- }
-
- /**
- * Reports an error number and string.
- *
- * @param int $errno The error number returned by PHP
- * @param string $errmsg The error message returned by PHP
- * @param string $errfile The file the error occurred in
- * @param int $errline The line number the error occurred on
- */
- protected function errorHandler($errno, $errmsg, $errfile = '', $errline = 0)
- {
- $notice = 'Connection failed.';
- $this->setError(
- $notice,
- $errmsg,
- (string) $errno
- );
- $this->edebug(
- "$notice Error #$errno: $errmsg [$errfile line $errline]",
- self::DEBUG_CONNECTION
- );
- }
-
- /**
- * Extract and return the ID of the last SMTP transaction based on
- * a list of patterns provided in SMTP::$smtp_transaction_id_patterns.
- * Relies on the host providing the ID in response to a DATA command.
- * If no reply has been received yet, it will return null.
- * If no pattern was matched, it will return false.
- *
- * @return bool|null|string
- */
- protected function recordLastTransactionID()
- {
- $reply = $this->getLastReply();
-
- if (empty($reply)) {
- $this->last_smtp_transaction_id = null;
- } else {
- $this->last_smtp_transaction_id = false;
- foreach ($this->smtp_transaction_id_patterns as $smtp_transaction_id_pattern) {
- if (preg_match($smtp_transaction_id_pattern, $reply, $matches)) {
- $this->last_smtp_transaction_id = trim($matches[1]);
- break;
- }
- }
- }
-
- return $this->last_smtp_transaction_id;
- }
-
- /**
- * Get the queue/transaction ID of the last SMTP transaction
- * If no reply has been received yet, it will return null.
- * If no pattern was matched, it will return false.
- *
- * @return bool|null|string
- *
- * @see recordLastTransactionID()
- */
- public function getLastTransactionID()
- {
- return $this->last_smtp_transaction_id;
- }
-}
diff --git a/core/l/PHPMailer/test/DebugLogTestListener.php b/core/l/PHPMailer/test/DebugLogTestListener.php
deleted file mode 100755
index f84ed8a..0000000
--- a/core/l/PHPMailer/test/DebugLogTestListener.php
+++ /dev/null
@@ -1,39 +0,0 @@
-
- * @author Andy Prevost
- * @copyright 2010 - 2017 Marcus Bointon
- * @copyright 2004 - 2009 Andy Prevost
- * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
- */
-
-namespace PHPMailer\Test;
-
-class DebugLogTestListener extends \PHPUnit_Framework_BaseTestListener
-{
- private static $debugLog = '';
-
- public function addError(\PHPUnit_Framework_Test $test, \Exception $e, $time)
- {
- echo self::$debugLog;
- }
-
- public function addFailure(\PHPUnit_Framework_Test $test, \PHPUnit_Framework_AssertionFailedError $e, $time)
- {
- echo self::$debugLog;
- }
-
- public function startTest(\PHPUnit_Framework_Test $test)
- {
- self::$debugLog = '';
- }
-
- public static function debugLog($str)
- {
- self::$debugLog .= $str . PHP_EOL;
- }
-}
diff --git a/core/l/PHPMailer/test/PHPMailerLangTest.php b/core/l/PHPMailer/test/PHPMailerLangTest.php
deleted file mode 100755
index 927592a..0000000
--- a/core/l/PHPMailer/test/PHPMailerLangTest.php
+++ /dev/null
@@ -1,72 +0,0 @@
-
- * @author Andy Prevost
- * @copyright 2010 - 2017 Marcus Bointon
- * @copyright 2004 - 2009 Andy Prevost
- * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
- */
-
-namespace PHPMailer\Test;
-
-use PHPMailer\PHPMailer\PHPMailer;
-use PHPUnit\Framework\TestCase;
-
-/**
- * Check language files for missing or excess translations.
- */
-final class PHPMailerLangTest extends TestCase
-{
- /**
- * Holds a PHPMailer instance.
- *
- * @var PHPMailer
- */
- private $Mail;
-
- /**
- * Run before each test is started.
- */
- protected function setUp()
- {
- $this->Mail = new PHPMailer();
- }
-
- /**
- * Test language files for missing and excess translations.
- * All languages are compared with English.
- *
- * @group languages
- */
- public function testTranslations()
- {
- $this->Mail->setLanguage('en');
- $definedStrings = $this->Mail->getTranslations();
- $err = '';
- foreach (new \DirectoryIterator('../language') as $fileInfo) {
- if ($fileInfo->isDot()) {
- continue;
- }
- $matches = [];
- //Only look at language files, ignore anything else in there
- if (preg_match('/^phpmailer\.lang-([a-z_]{2,})\.php$/', $fileInfo->getFilename(), $matches)) {
- $lang = $matches[1]; //Extract language code
- $PHPMAILER_LANG = []; //Language strings get put in here
- include $fileInfo->getPathname(); //Get language strings
- $missing = array_diff(array_keys($definedStrings), array_keys($PHPMAILER_LANG));
- $extra = array_diff(array_keys($PHPMAILER_LANG), array_keys($definedStrings));
- if (!empty($missing)) {
- $err .= "\nMissing translations in $lang: " . implode(', ', $missing);
- }
- if (!empty($extra)) {
- $err .= "\nExtra translations in $lang: " . implode(', ', $extra);
- }
- }
- }
- $this->assertEmpty($err, $err);
- }
-}
diff --git a/core/l/PHPMailer/test/PHPMailerTest.php b/core/l/PHPMailer/test/PHPMailerTest.php
deleted file mode 100755
index 919be93..0000000
--- a/core/l/PHPMailer/test/PHPMailerTest.php
+++ /dev/null
@@ -1,2415 +0,0 @@
-
- * @author Andy Prevost
- * @copyright 2012 - 2017 Marcus Bointon
- * @copyright 2004 - 2009 Andy Prevost
- * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
- */
-
-namespace PHPMailer\Test;
-
-use PHPMailer\PHPMailer\PHPMailer;
-use PHPMailer\PHPMailer\POP3;
-use PHPUnit\Framework\TestCase;
-
-/**
- * PHPMailer - PHP email transport unit test class.
- */
-final class PHPMailerTest extends TestCase
-{
- /**
- * Holds the PHPMailer instance.
- *
- * @var PHPMailer
- */
- private $Mail;
-
- /**
- * Holds the SMTP mail host.
- *
- * @var string
- */
- private $Host = '';
-
- /**
- * Holds the change log.
- *
- * @var string[]
- */
- private $ChangeLog = [];
-
- /**
- * Holds the note log.
- *
- * @var string[]
- */
- private $NoteLog = [];
-
- /**
- * Default include path.
- *
- * @var string
- */
- private $INCLUDE_DIR = '..';
-
- /**
- * PIDs of any processes we need to kill.
- *
- * @var array
- */
- private $pids = [];
-
- /**
- * Run before each test is started.
- */
- protected function setUp()
- {
- $this->INCLUDE_DIR = dirname(__DIR__); //Default to the dir above the test dir, i.e. the project home dir
- if (file_exists($this->INCLUDE_DIR . '/test/testbootstrap.php')) {
- include $this->INCLUDE_DIR . '/test/testbootstrap.php'; //Overrides go in here
- }
- $this->Mail = new PHPMailer();
- $this->Mail->SMTPDebug = 3; //Full debug output
- $this->Mail->Debugoutput = ['PHPMailer\Test\DebugLogTestListener', 'debugLog'];
- $this->Mail->Priority = 3;
- $this->Mail->Encoding = '8bit';
- $this->Mail->CharSet = 'iso-8859-1';
- if (array_key_exists('mail_from', $_REQUEST)) {
- $this->Mail->From = $_REQUEST['mail_from'];
- } else {
- $this->Mail->From = 'unit_test@phpmailer.example.com';
- }
- $this->Mail->FromName = 'Unit Tester';
- $this->Mail->Sender = '';
- $this->Mail->Subject = 'Unit Test';
- $this->Mail->Body = '';
- $this->Mail->AltBody = '';
- $this->Mail->WordWrap = 0;
- if (array_key_exists('mail_host', $_REQUEST)) {
- $this->Mail->Host = $_REQUEST['mail_host'];
- } else {
- $this->Mail->Host = 'mail.example.com';
- }
- if (array_key_exists('mail_port', $_REQUEST)) {
- $this->Mail->Port = $_REQUEST['mail_port'];
- } else {
- $this->Mail->Port = 25;
- }
- $this->Mail->Helo = 'localhost.localdomain';
- $this->Mail->SMTPAuth = false;
- $this->Mail->Username = '';
- $this->Mail->Password = '';
- $this->Mail->addReplyTo('no_reply@phpmailer.example.com', 'Reply Guy');
- $this->Mail->Sender = 'unit_test@phpmailer.example.com';
- if (strlen($this->Mail->Host) > 0) {
- $this->Mail->isSMTP();
- } else {
- $this->Mail->isMail();
- }
- if (array_key_exists('mail_to', $_REQUEST)) {
- $this->setAddress($_REQUEST['mail_to'], 'Test User', 'to');
- }
- if (array_key_exists('mail_cc', $_REQUEST) and strlen($_REQUEST['mail_cc']) > 0) {
- $this->setAddress($_REQUEST['mail_cc'], 'Carbon User', 'cc');
- }
- }
-
- /**
- * Run after each test is completed.
- */
- protected function tearDown()
- {
- // Clean global variables
- $this->Mail = null;
- $this->ChangeLog = [];
- $this->NoteLog = [];
-
- foreach ($this->pids as $pid) {
- $p = escapeshellarg($pid);
- shell_exec("ps $p && kill -TERM $p");
- }
- }
-
- /**
- * Build the body of the message in the appropriate format.
- */
- private function buildBody()
- {
- $this->checkChanges();
-
- // Determine line endings for message
- if ('text/html' == $this->Mail->ContentType || strlen($this->Mail->AltBody) > 0) {
- $eol = " \r\n";
- $bullet_start = '
- * - name - name of cycle (optional)
- * - values - comma separated list of values to cycle, or an array of values to cycle
- * (this can be left out for subsequent calls)
- * - reset - boolean - resets given var to true
- * - print - boolean - print var or not. default is true
- * - advance - boolean - whether or not to advance the cycle
- * - delimiter - the value delimiter, default is ","
- * - assign - boolean, assigns to template var instead of printed.
- *