diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..757fee3 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/.idea \ No newline at end of file diff --git a/Flare/.htaccess b/Flare/.htaccess new file mode 100644 index 0000000..f24db0a --- /dev/null +++ b/Flare/.htaccess @@ -0,0 +1,6 @@ + + Require all denied + + + Deny from all + diff --git a/Flare/Controllers/EFTEKHARI.php b/Flare/Controllers/EFTEKHARI.php new file mode 100644 index 0000000..a5e24ca --- /dev/null +++ b/Flare/Controllers/EFTEKHARI.php @@ -0,0 +1,60 @@ +rawQuery ($q); + + $session->start(); + //for use email use this + $Email =new Email() ; + $Email->Email() ; + */ + + // $session->start(); + // $PHPCAP =new Captcha() ; + // debug($ff); + + + + + + + + + + $data = ['welcome' => 'Flare Framework ' ] ; + return $templates->render('welcome',$data); + // or use + // return View('Welcome/Welcome') ; + + } +} diff --git a/Flare/Flare_Libraries/MysqliDb.php b/Flare/Flare_Libraries/MysqliDb.php new file mode 100644 index 0000000..6f1e957 --- /dev/null +++ b/Flare/Flare_Libraries/MysqliDb.php @@ -0,0 +1,2523 @@ + + * @author Josh Campbell + * @author Alexander V. Butenko + * @copyright Copyright (c) 2010-2017 + * @license http://opensource.org/licenses/gpl-3.0.html GNU Public License + * @link http://github.com/joshcam/PHP-MySQLi-Database-Class + * @version 2.9.3 + */ + +class MysqliDb +{ + + /** + * Static instance of self + * + * @var MysqliDb + */ + protected static $_instance; + + /** + * Table prefix + * + * @var string + */ + public static $prefix = ''; + + /** + * MySQLi instances + * + * @var mysqli[] + */ + protected $_mysqli = array(); + + /** + * The SQL query to be prepared and executed + * + * @var string + */ + protected $_query; + + /** + * The previously executed SQL query + * + * @var string + */ + protected $_lastQuery; + + /** + * The SQL query options required after SELECT, INSERT, UPDATE or DELETE + * + * @var array + */ + protected $_queryOptions = array(); + + /** + * An array that holds where joins + * + * @var array + */ + protected $_join = array(); + + /** + * An array that holds where conditions + * + * @var array + */ + protected $_where = array(); + + /** + * An array that holds where join ands + * + * @var array + */ + protected $_joinAnd = array(); + + /** + * An array that holds having conditions + * + * @var array + */ + protected $_having = array(); + + /** + * Dynamic type list for order by condition value + * + * @var array + */ + protected $_orderBy = array(); + + /** + * Dynamic type list for group by condition value + * + * @var array + */ + protected $_groupBy = array(); + + /** + * Dynamic type list for temporary locking tables. + * + * @var array + */ + protected $_tableLocks = array(); + + /** + * Variable which holds the current table lock method. + * + * @var string + */ + protected $_tableLockMethod = "READ"; + + /** + * Dynamic array that holds a combination of where condition/table data value types and parameter references + * + * @var array + */ + protected $_bindParams = array(''); // Create the empty 0 index + + /** + * Variable which holds an amount of returned rows during get/getOne/select queries + * + * @var string + */ + public $count = 0; + + /** + * Variable which holds an amount of returned rows during get/getOne/select queries with withTotalCount() + * + * @var string + */ + public $totalCount = 0; + + /** + * Variable which holds last statement error + * + * @var string + */ + protected $_stmtError; + + /** + * Variable which holds last statement error code + * + * @var int + */ + protected $_stmtErrno; + + /** + * Is Subquery object + * + * @var bool + */ + protected $isSubQuery = false; + + /** + * Name of the auto increment column + * + * @var int + */ + protected $_lastInsertId = null; + + /** + * Column names for update when using onDuplicate method + * + * @var array + */ + protected $_updateColumns = null; + + /** + * Return type: 'array' to return results as array, 'object' as object + * 'json' as json string + * + * @var string + */ + public $returnType = 'array'; + + /** + * Should join() results be nested by table + * + * @var bool + */ + protected $_nestJoin = false; + + /** + * Table name (with prefix, if used) + * + * @var string + */ + private $_tableName = ''; + + /** + * FOR UPDATE flag + * + * @var bool + */ + protected $_forUpdate = false; + + /** + * LOCK IN SHARE MODE flag + * + * @var bool + */ + protected $_lockInShareMode = false; + + /** + * Key field for Map()'ed result array + * + * @var string + */ + protected $_mapKey = null; + + /** + * Variables for query execution tracing + */ + protected $traceStartQ; + protected $traceEnabled; + protected $traceStripPrefix; + public $trace = array(); + + /** + * Per page limit for pagination + * + * @var int + */ + + public $pageLimit = 20; + /** + * Variable that holds total pages count of last paginate() query + * + * @var int + */ + public $totalPages = 0; + + /** + * @var array connections settings [profile_name=>[same_as_contruct_args]] + */ + protected $connectionsSettings = array(); + /** + * @var string the name of a default (main) mysqli connection + */ + public $defConnectionName = 'default'; + + public $autoReconnect = true; + protected $autoReconnectCount = 0; + + /** + * @var bool Operations in transaction indicator + */ + protected $_transaction_in_progress = false; + + /** + * @param string $host + * @param string $username + * @param string $password + * @param string $db + * @param int $port + * @param string $charset + * @param string $socket + */ + public function __construct($host = null, $username = null, $password = null, $db = null, $port = null, $charset = 'utf8', $socket = null) + { + $isSubQuery = false; + + // if params were passed as array + if (is_array($host)) { + foreach ($host as $key => $val) { + $$key = $val; + } + } + + $this->addConnection('default', array( + 'host' => $host, + 'username' => $username, + 'password' => $password, + 'db' => $db, + 'port' => $port, + 'socket' => $socket, + 'charset' => $charset + )); + + if ($isSubQuery) { + $this->isSubQuery = true; + return; + } + + if (isset($prefix)) { + $this->setPrefix($prefix); + } + + self::$_instance = $this; + } + + /** + * A method to connect to the database + * + * @param null|string $connectionName + * + * @throws Exception + * @return void + */ + public function connect($connectionName = 'default') + { + if(!isset($this->connectionsSettings[$connectionName])) + throw new Exception('Connection profile not set'); + + $pro = $this->connectionsSettings[$connectionName]; + $params = array_values($pro); + $charset = array_pop($params); + + if ($this->isSubQuery) { + return; + } + + if (empty($pro['host']) && empty($pro['socket'])) { + throw new Exception('MySQL host or socket is not set'); + } + + $mysqlic = new ReflectionClass('mysqli'); + $mysqli = $mysqlic->newInstanceArgs($params); + + if ($mysqli->connect_error) { + throw new Exception('Connect Error ' . $mysqli->connect_errno . ': ' . $mysqli->connect_error, $mysqli->connect_errno); + } + + if (!empty($charset)) { + $mysqli->set_charset($charset); + } + $this->_mysqli[$connectionName] = $mysqli; + } + + /** + * @throws Exception + */ + public function disconnectAll() + { + foreach (array_keys($this->_mysqli) as $k) { + $this->disconnect($k); + } + } + + /** + * Set the connection name to use in the next query + * + * @param string $name + * + * @return $this + * @throws Exception + */ + public function connection($name) + { + if (!isset($this->connectionsSettings[$name])) + throw new Exception('Connection ' . $name . ' was not added.'); + + $this->defConnectionName = $name; + return $this; + } + + /** + * A method to disconnect from the database + * + * @params string $connection connection name to disconnect + * + * @param string $connection + * + * @return void + */ + public function disconnect($connection = 'default') + { + if (!isset($this->_mysqli[$connection])) + return; + + $this->_mysqli[$connection]->close(); + unset($this->_mysqli[$connection]); + } + + /** + * Create & store at _mysqli new mysqli instance + * + * @param string $name + * @param array $params + * + * @return $this + */ + public function addConnection($name, array $params) + { + $this->connectionsSettings[$name] = array(); + foreach (array('host', 'username', 'password', 'db', 'port', 'socket', 'charset') as $k) { + $prm = isset($params[$k]) ? $params[$k] : null; + + if ($k == 'host') { + if (is_object($prm)) + $this->_mysqli[$name] = $prm; + + if (!is_string($prm)) + $prm = null; + } + $this->connectionsSettings[$name][$k] = $prm; + } + return $this; + } + + /** + * A method to get mysqli object or create it in case needed + * + * @return mysqli + * @throws Exception + */ + public function mysqli() + { + if (!isset($this->_mysqli[$this->defConnectionName])) { + $this->connect($this->defConnectionName); + } + return $this->_mysqli[$this->defConnectionName]; + } + + /** + * A method of returning the static instance to allow access to the + * instantiated object from within another class. + * Inheriting this class would require reloading connection info. + * + * @uses $db = MySqliDb::getInstance(); + * + * @return MysqliDb Returns the current instance. + */ + public static function getInstance() + { + return self::$_instance; + } + + /** + * Reset states after an execution + * + * @return MysqliDb Returns the current instance. + */ + protected function reset() + { + if ($this->traceEnabled) { + $this->trace[] = array($this->_lastQuery, (microtime(true) - $this->traceStartQ), $this->_traceGetCaller()); + } + + $this->_where = array(); + $this->_having = array(); + $this->_join = array(); + $this->_joinAnd = array(); + $this->_orderBy = array(); + $this->_groupBy = array(); + $this->_bindParams = array(''); // Create the empty 0 index + $this->_query = null; + $this->_queryOptions = array(); + $this->returnType = 'array'; + $this->_nestJoin = false; + $this->_forUpdate = false; + $this->_lockInShareMode = false; + $this->_tableName = ''; + $this->_lastInsertId = null; + $this->_updateColumns = null; + $this->_mapKey = null; + if(!$this->_transaction_in_progress ) { + $this->defConnectionName = 'default'; + } + $this->autoReconnectCount = 0; + return $this; + } + + /** + * Helper function to create dbObject with JSON return type + * + * @return MysqliDb + */ + public function jsonBuilder() + { + $this->returnType = 'json'; + return $this; + } + + /** + * Helper function to create dbObject with array return type + * Added for consistency as that's default output type + * + * @return MysqliDb + */ + public function arrayBuilder() + { + $this->returnType = 'array'; + return $this; + } + + /** + * Helper function to create dbObject with object return type. + * + * @return MysqliDb + */ + public function objectBuilder() + { + $this->returnType = 'object'; + return $this; + } + + /** + * Method to set a prefix + * + * @param string $prefix Contains a table prefix + * + * @return MysqliDb + */ + public function setPrefix($prefix = '') + { + self::$prefix = $prefix; + return $this; + } + + /** + * Pushes a unprepared statement to the mysqli stack. + * WARNING: Use with caution. + * This method does not escape strings by default so make sure you'll never use it in production. + * + * @author Jonas Barascu + * + * @param [[Type]] $query [[Description]] + * + * @return bool|mysqli_result + * @throws Exception + */ + private function queryUnprepared($query) + { + // Execute query + $stmt = $this->mysqli()->query($query); + + // Failed? + if ($stmt !== false) + return $stmt; + + if ($this->mysqli()->errno === 2006 && $this->autoReconnect === true && $this->autoReconnectCount === 0) { + $this->connect($this->defConnectionName); + $this->autoReconnectCount++; + return $this->queryUnprepared($query); + } + + throw new Exception(sprintf('Unprepared Query Failed, ERRNO: %u (%s)', $this->mysqli()->errno, $this->mysqli()->error), $this->mysqli()->errno); + } + + /** + * Prefix add raw SQL query. + * + * @author Emre Emir + * @param string $query User-provided query to execute. + * @return string Contains the returned rows from the query. + */ + public function rawAddPrefix($query){ + $query = str_replace(PHP_EOL, null, $query); + $query = preg_replace('/\s+/', ' ', $query); + preg_match_all("/(from|into|update|join) [\\'\\´]?([a-zA-Z0-9_-]+)[\\'\\´]?/i", $query, $matches); + list($from_table, $from, $table) = $matches; + + return str_replace($table[0], self::$prefix.$table[0], $query); + } + + /** + * Execute raw SQL query. + * + * @param string $query User-provided query to execute. + * @param array $bindParams Variables array to bind to the SQL statement. + * + * @return array Contains the returned rows from the query. + * @throws Exception + */ + public function rawQuery($query, $bindParams = null) + { + $query = $this->rawAddPrefix($query); + $params = array(''); // Create the empty 0 index + $this->_query = $query; + $stmt = $this->_prepareQuery(); + + if (is_array($bindParams) === true) { + foreach ($bindParams as $prop => $val) { + $params[0] .= $this->_determineType($val); + array_push($params, $bindParams[$prop]); + } + + call_user_func_array(array($stmt, 'bind_param'), $this->refValues($params)); + } + + $stmt->execute(); + $this->count = $stmt->affected_rows; + $this->_stmtError = $stmt->error; + $this->_stmtErrno = $stmt->errno; + $this->_lastQuery = $this->replacePlaceHolders($this->_query, $params); + $res = $this->_dynamicBindResults($stmt); + $this->reset(); + + return $res; + } + + /** + * Helper function to execute raw SQL query and return only 1 row of results. + * Note that function do not add 'limit 1' to the query by itself + * Same idea as getOne() + * + * @param string $query User-provided query to execute. + * @param array $bindParams Variables array to bind to the SQL statement. + * + * @return array|null Contains the returned row from the query. + * @throws Exception + */ + public function rawQueryOne($query, $bindParams = null) + { + $res = $this->rawQuery($query, $bindParams); + if (is_array($res) && isset($res[0])) { + return $res[0]; + } + + return null; + } + + /** + * Helper function to execute raw SQL query and return only 1 column of results. + * If 'limit 1' will be found, then string will be returned instead of array + * Same idea as getValue() + * + * @param string $query User-provided query to execute. + * @param array $bindParams Variables array to bind to the SQL statement. + * + * @return mixed Contains the returned rows from the query. + * @throws Exception + */ + public function rawQueryValue($query, $bindParams = null) + { + $res = $this->rawQuery($query, $bindParams); + if (!$res) { + return null; + } + + $limit = preg_match('/limit\s+1;?$/i', $query); + $key = key($res[0]); + if (isset($res[0][$key]) && $limit == true) { + return $res[0][$key]; + } + + $newRes = Array(); + for ($i = 0; $i < $this->count; $i++) { + $newRes[] = $res[$i][$key]; + } + return $newRes; + } + + /** + * A method to perform select query + * + * @param string $query Contains a user-provided select query. + * @param int|array $numRows Array to define SQL limit in format Array ($offset, $count) + * + * @return array Contains the returned rows from the query. + * @throws Exception + */ + public function query($query, $numRows = null) + { + $this->_query = $query; + $stmt = $this->_buildQuery($numRows); + $stmt->execute(); + $this->_stmtError = $stmt->error; + $this->_stmtErrno = $stmt->errno; + $res = $this->_dynamicBindResults($stmt); + $this->reset(); + + return $res; + } + + /** + * This method allows you to specify multiple (method chaining optional) options for SQL queries. + * + * @uses $MySqliDb->setQueryOption('name'); + * + * @param string|array $options The options name of the query. + * + * @throws Exception + * @return MysqliDb + */ + public function setQueryOption($options) + { + $allowedOptions = Array('ALL', 'DISTINCT', 'DISTINCTROW', 'HIGH_PRIORITY', 'STRAIGHT_JOIN', 'SQL_SMALL_RESULT', + 'SQL_BIG_RESULT', 'SQL_BUFFER_RESULT', 'SQL_CACHE', 'SQL_NO_CACHE', 'SQL_CALC_FOUND_ROWS', + 'LOW_PRIORITY', 'IGNORE', 'QUICK', 'MYSQLI_NESTJOIN', 'FOR UPDATE', 'LOCK IN SHARE MODE'); + + if (!is_array($options)) { + $options = Array($options); + } + + foreach ($options as $option) { + $option = strtoupper($option); + if (!in_array($option, $allowedOptions)) { + throw new Exception('Wrong query option: ' . $option); + } + + if ($option == 'MYSQLI_NESTJOIN') { + $this->_nestJoin = true; + } elseif ($option == 'FOR UPDATE') { + $this->_forUpdate = true; + } elseif ($option == 'LOCK IN SHARE MODE') { + $this->_lockInShareMode = true; + } else { + $this->_queryOptions[] = $option; + } + } + + return $this; + } + + /** + * Function to enable SQL_CALC_FOUND_ROWS in the get queries + * + * @return MysqliDb + * @throws Exception + */ + public function withTotalCount() + { + $this->setQueryOption('SQL_CALC_FOUND_ROWS'); + return $this; + } + + /** + * A convenient SELECT * function. + * + * @param string $tableName The name of the database table to work with. + * @param int|array $numRows Array to define SQL limit in format Array ($offset, $count) + * or only $count + * @param string $columns Desired columns + * + * @return array|MysqliDb Contains the returned rows from the select query. + * @throws Exception + */ + public function get($tableName, $numRows = null, $columns = '*') + { + if (empty($columns)) { + $columns = '*'; + } + + $column = is_array($columns) ? implode(', ', $columns) : $columns; + + if (strpos($tableName, '.') === false) { + $this->_tableName = self::$prefix . $tableName; + } else { + $this->_tableName = $tableName; + } + + $this->_query = 'SELECT ' . implode(' ', $this->_queryOptions) . ' ' . + $column . " FROM " . $this->_tableName; + $stmt = $this->_buildQuery($numRows); + + if ($this->isSubQuery) { + return $this; + } + + $stmt->execute(); + $this->_stmtError = $stmt->error; + $this->_stmtErrno = $stmt->errno; + $res = $this->_dynamicBindResults($stmt); + $this->reset(); + + return $res; + } + + /** + * A convenient SELECT * function to get one record. + * + * @param string $tableName The name of the database table to work with. + * @param string $columns Desired columns + * + * @return array Contains the returned rows from the select query. + * @throws Exception + */ + public function getOne($tableName, $columns = '*') + { + $res = $this->get($tableName, 1, $columns); + + if ($res instanceof MysqliDb) { + return $res; + } elseif (is_array($res) && isset($res[0])) { + return $res[0]; + } elseif ($res) { + return $res; + } + + return null; + } + + /** + * A convenient SELECT COLUMN function to get a single column value from one row + * + * @param string $tableName The name of the database table to work with. + * @param string $column The desired column + * @param int $limit Limit of rows to select. Use null for unlimited..1 by default + * + * @return mixed Contains the value of a returned column / array of values + * @throws Exception + */ + public function getValue($tableName, $column, $limit = 1) + { + $res = $this->ArrayBuilder()->get($tableName, $limit, "{$column} AS retval"); + + if (!$res) { + return null; + } + + if ($limit == 1) { + if (isset($res[0]["retval"])) { + return $res[0]["retval"]; + } + return null; + } + + $newRes = Array(); + for ($i = 0; $i < $this->count; $i++) { + $newRes[] = $res[$i]['retval']; + } + return $newRes; + } + + /** + * Insert method to add new row + * + * @param string $tableName The name of the table. + * @param array $insertData Data containing information for inserting into the DB. + * + * @return bool Boolean indicating whether the insert query was completed successfully. + * @throws Exception + */ + public function insert($tableName, $insertData) + { + return $this->_buildInsert($tableName, $insertData, 'INSERT'); + } + + /** + * Insert method to add several rows at once + * + * @param string $tableName The name of the table. + * @param array $multiInsertData Two-dimensional Data-array containing information for inserting into the DB. + * @param array $dataKeys Optional Table Key names, if not set in insertDataSet. + * + * @return bool|array Boolean indicating the insertion failed (false), else return id-array ([int]) + * @throws Exception + */ + public function insertMulti($tableName, array $multiInsertData, array $dataKeys = null) + { + // only auto-commit our inserts, if no transaction is currently running + $autoCommit = (isset($this->_transaction_in_progress) ? !$this->_transaction_in_progress : true); + $ids = array(); + + if($autoCommit) { + $this->startTransaction(); + } + + foreach ($multiInsertData as $insertData) { + if($dataKeys !== null) { + // apply column-names if given, else assume they're already given in the data + $insertData = array_combine($dataKeys, $insertData); + } + + $id = $this->insert($tableName, $insertData); + if(!$id) { + if($autoCommit) { + $this->rollback(); + } + return false; + } + $ids[] = $id; + } + + if($autoCommit) { + $this->commit(); + } + + return $ids; + } + + /** + * Replace method to add new row + * + * @param string $tableName The name of the table. + * @param array $insertData Data containing information for inserting into the DB. + * + * @return bool Boolean indicating whether the insert query was completed successfully. + * @throws Exception + */ + public function replace($tableName, $insertData) + { + return $this->_buildInsert($tableName, $insertData, 'REPLACE'); + } + + /** + * A convenient function that returns TRUE if exists at least an element that + * satisfy the where condition specified calling the "where" method before this one. + * + * @param string $tableName The name of the database table to work with. + * + * @return bool + * @throws Exception + */ + public function has($tableName) + { + $this->getOne($tableName, '1'); + return $this->count >= 1; + } + + /** + * Update query. Be sure to first call the "where" method. + * + * @param string $tableName The name of the database table to work with. + * @param array $tableData Array of data to update the desired row. + * @param int $numRows Limit on the number of rows that can be updated. + * + * @return bool + * @throws Exception + */ + public function update($tableName, $tableData, $numRows = null) + { + if ($this->isSubQuery) { + return; + } + + $this->_query = "UPDATE " . self::$prefix . $tableName; + + $stmt = $this->_buildQuery($numRows, $tableData); + $status = $stmt->execute(); + $this->reset(); + $this->_stmtError = $stmt->error; + $this->_stmtErrno = $stmt->errno; + $this->count = $stmt->affected_rows; + + return $status; + } + + /** + * Delete query. Call the "where" method first. + * + * @param string $tableName The name of the database table to work with. + * @param int|array $numRows Array to define SQL limit in format Array ($offset, $count) + * or only $count + * + * @return bool Indicates success. 0 or 1. + * @throws Exception + */ + public function delete($tableName, $numRows = null) + { + if ($this->isSubQuery) { + return; + } + + $table = self::$prefix . $tableName; + + if (count($this->_join)) { + $this->_query = "DELETE " . preg_replace('/.* (.*)/', '$1', $table) . " FROM " . $table; + } else { + $this->_query = "DELETE FROM " . $table; + } + + $stmt = $this->_buildQuery($numRows); + $stmt->execute(); + $this->_stmtError = $stmt->error; + $this->_stmtErrno = $stmt->errno; + $this->count = $stmt->affected_rows; + $this->reset(); + + return ($stmt->affected_rows > -1); // -1 indicates that the query returned an error + } + + /** + * This method allows you to specify multiple (method chaining optional) AND WHERE statements for SQL queries. + * + * @uses $MySqliDb->where('id', 7)->where('title', 'MyTitle'); + * + * @param string $whereProp The name of the database field. + * @param mixed $whereValue The value of the database field. + * @param string $operator Comparison operator. Default is = + * @param string $cond Condition of where statement (OR, AND) + * + * @return MysqliDb + */ + public function where($whereProp, $whereValue = 'DBNULL', $operator = '=', $cond = 'AND') + { + if (count($this->_where) == 0) { + $cond = ''; + } + + $this->_where[] = array($cond, $whereProp, $operator, $whereValue); + return $this; + } + + /** + * This function store update column's name and column name of the + * autoincrement column + * + * @param array $updateColumns Variable with values + * @param string $lastInsertId Variable value + * + * @return MysqliDb + */ + public function onDuplicate($updateColumns, $lastInsertId = null) + { + $this->_lastInsertId = $lastInsertId; + $this->_updateColumns = $updateColumns; + return $this; + } + + /** + * This method allows you to specify multiple (method chaining optional) OR WHERE statements for SQL queries. + * + * @uses $MySqliDb->orWhere('id', 7)->orWhere('title', 'MyTitle'); + * + * @param string $whereProp The name of the database field. + * @param mixed $whereValue The value of the database field. + * @param string $operator Comparison operator. Default is = + * + * @return MysqliDb + */ + public function orWhere($whereProp, $whereValue = 'DBNULL', $operator = '=') + { + return $this->where($whereProp, $whereValue, $operator, 'OR'); + } + + /** + * This method allows you to specify multiple (method chaining optional) AND HAVING statements for SQL queries. + * + * @uses $MySqliDb->having('SUM(tags) > 10') + * + * @param string $havingProp The name of the database field. + * @param mixed $havingValue The value of the database field. + * @param string $operator Comparison operator. Default is = + * + * @param string $cond + * + * @return MysqliDb + */ + + public function having($havingProp, $havingValue = 'DBNULL', $operator = '=', $cond = 'AND') + { + // forkaround for an old operation api + if (is_array($havingValue) && ($key = key($havingValue)) != "0") { + $operator = $key; + $havingValue = $havingValue[$key]; + } + + if (count($this->_having) == 0) { + $cond = ''; + } + + $this->_having[] = array($cond, $havingProp, $operator, $havingValue); + return $this; + } + + /** + * This method allows you to specify multiple (method chaining optional) OR HAVING statements for SQL queries. + * + * @uses $MySqliDb->orHaving('SUM(tags) > 10') + * + * @param string $havingProp The name of the database field. + * @param mixed $havingValue The value of the database field. + * @param string $operator Comparison operator. Default is = + * + * @return MysqliDb + */ + public function orHaving($havingProp, $havingValue = null, $operator = null) + { + return $this->having($havingProp, $havingValue, $operator, 'OR'); + } + + /** + * This method allows you to concatenate joins for the final SQL statement. + * + * @uses $MySqliDb->join('table1', 'field1 <> field2', 'LEFT') + * + * @param string $joinTable The name of the table. + * @param string $joinCondition the condition. + * @param string $joinType 'LEFT', 'INNER' etc. + * + * @throws Exception + * @return MysqliDb + */ + public function join($joinTable, $joinCondition, $joinType = '') + { + $allowedTypes = array('LEFT', 'RIGHT', 'OUTER', 'INNER', 'LEFT OUTER', 'RIGHT OUTER', 'NATURAL'); + $joinType = strtoupper(trim($joinType)); + + if ($joinType && !in_array($joinType, $allowedTypes)) { + throw new Exception('Wrong JOIN type: ' . $joinType); + } + + if (!is_object($joinTable)) { + $joinTable = self::$prefix . $joinTable; + } + + $this->_join[] = Array($joinType, $joinTable, $joinCondition); + + return $this; + } + + + /** + * This is a basic method which allows you to import raw .CSV data into a table + * Please check out http://dev.mysql.com/doc/refman/5.7/en/load-data.html for a valid .csv file. + * + * @author Jonas Barascu (Noneatme) + * + * @param string $importTable The database table where the data will be imported into. + * @param string $importFile The file to be imported. Please use double backslashes \\ and make sure you + * @param string $importSettings An Array defining the import settings as described in the README.md + * + * @return boolean + * @throws Exception + */ + public function loadData($importTable, $importFile, $importSettings = null) + { + // We have to check if the file exists + if (!file_exists($importFile)) { + // Throw an exception + throw new Exception("importCSV -> importFile " . $importFile . " does not exists!"); + } + + // Define the default values + // We will merge it later + $settings = Array("fieldChar" => ';', "lineChar" => PHP_EOL, "linesToIgnore" => 1); + + // Check the import settings + if (gettype($importSettings) == "array") { + // Merge the default array with the custom one + $settings = array_merge($settings, $importSettings); + } + + // Add the prefix to the import table + $table = self::$prefix . $importTable; + + // Add 1 more slash to every slash so maria will interpret it as a path + $importFile = str_replace("\\", "\\\\", $importFile); + + // Switch between LOAD DATA and LOAD DATA LOCAL + $loadDataLocal = isset($settings["loadDataLocal"]) ? 'LOCAL' : ''; + + // Build SQL Syntax + $sqlSyntax = sprintf('LOAD DATA %s INFILE \'%s\' INTO TABLE %s', + $loadDataLocal, $importFile, $table); + + // FIELDS + $sqlSyntax .= sprintf(' FIELDS TERMINATED BY \'%s\'', $settings["fieldChar"]); + if (isset($settings["fieldEnclosure"])) { + $sqlSyntax .= sprintf(' ENCLOSED BY \'%s\'', $settings["fieldEnclosure"]); + } + + // LINES + $sqlSyntax .= sprintf(' LINES TERMINATED BY \'%s\'', $settings["lineChar"]); + if (isset($settings["lineStarting"])) { + $sqlSyntax .= sprintf(' STARTING BY \'%s\'', $settings["lineStarting"]); + } + + // IGNORE LINES + $sqlSyntax .= sprintf(' IGNORE %d LINES', $settings["linesToIgnore"]); + + // Execute the query unprepared because LOAD DATA only works with unprepared statements. + $result = $this->queryUnprepared($sqlSyntax); + + // Are there rows modified? + // Let the user know if the import failed / succeeded + return (bool) $result; + } + + /** + * This method is useful for importing XML files into a specific table. + * Check out the LOAD XML syntax for your MySQL server. + * + * @author Jonas Barascu + * + * @param string $importTable The table in which the data will be imported to. + * @param string $importFile The file which contains the .XML data. + * @param string $importSettings An Array defining the import settings as described in the README.md + * + * @return boolean Returns true if the import succeeded, false if it failed. + * @throws Exception + */ + public function loadXml($importTable, $importFile, $importSettings = null) + { + // We have to check if the file exists + if(!file_exists($importFile)) { + // Does not exists + throw new Exception("loadXml: Import file does not exists"); + return; + } + + // Create default values + $settings = Array("linesToIgnore" => 0); + + // Check the import settings + if(gettype($importSettings) == "array") { + $settings = array_merge($settings, $importSettings); + } + + // Add the prefix to the import table + $table = self::$prefix . $importTable; + + // Add 1 more slash to every slash so maria will interpret it as a path + $importFile = str_replace("\\", "\\\\", $importFile); + + // Build SQL Syntax + $sqlSyntax = sprintf('LOAD XML INFILE \'%s\' INTO TABLE %s', + $importFile, $table); + + // FIELDS + if(isset($settings["rowTag"])) { + $sqlSyntax .= sprintf(' ROWS IDENTIFIED BY \'%s\'', $settings["rowTag"]); + } + + // IGNORE LINES + $sqlSyntax .= sprintf(' IGNORE %d LINES', $settings["linesToIgnore"]); + + // Exceute the query unprepared because LOAD XML only works with unprepared statements. + $result = $this->queryUnprepared($sqlSyntax); + + // Are there rows modified? + // Let the user know if the import failed / succeeded + return (bool) $result; + } + + /** + * This method allows you to specify multiple (method chaining optional) ORDER BY statements for SQL queries. + * + * @uses $MySqliDb->orderBy('id', 'desc')->orderBy('name', 'desc', '^[a-z]')->orderBy('name', 'desc'); + * + * @param string $orderByField The name of the database field. + * @param string $orderbyDirection + * @param mixed $customFieldsOrRegExp Array with fieldset for ORDER BY FIELD() ordering or string with regular expression for ORDER BY REGEXP ordering + * + * @return MysqliDb + * @throws Exception + */ + public function orderBy($orderByField, $orderbyDirection = "DESC", $customFieldsOrRegExp = null) + { + $allowedDirection = Array("ASC", "DESC"); + $orderbyDirection = strtoupper(trim($orderbyDirection)); + $orderByField = preg_replace("/[^ -a-z0-9\.\(\),_`\*\'\"]+/i", '', $orderByField); + + // Add table prefix to orderByField if needed. + //FIXME: We are adding prefix only if table is enclosed into `` to distinguish aliases + // from table names + $orderByField = preg_replace('/(\`)([`a-zA-Z0-9_]*\.)/', '\1' . self::$prefix . '\2', $orderByField); + + + if (empty($orderbyDirection) || !in_array($orderbyDirection, $allowedDirection)) { + throw new Exception('Wrong order direction: ' . $orderbyDirection); + } + + if (is_array($customFieldsOrRegExp)) { + foreach ($customFieldsOrRegExp as $key => $value) { + $customFieldsOrRegExp[$key] = preg_replace("/[^\x80-\xff-a-z0-9\.\(\),_` ]+/i", '', $value); + } + $orderByField = 'FIELD (' . $orderByField . ', "' . implode('","', $customFieldsOrRegExp) . '")'; + }elseif(is_string($customFieldsOrRegExp)){ + $orderByField = $orderByField . " REGEXP '" . $customFieldsOrRegExp . "'"; + }elseif($customFieldsOrRegExp !== null){ + throw new Exception('Wrong custom field or Regular Expression: ' . $customFieldsOrRegExp); + } + + $this->_orderBy[$orderByField] = $orderbyDirection; + return $this; + } + + /** + * This method allows you to specify multiple (method chaining optional) GROUP BY statements for SQL queries. + * + * @uses $MySqliDb->groupBy('name'); + * + * @param string $groupByField The name of the database field. + * + * @return MysqliDb + */ + public function groupBy($groupByField) + { + $groupByField = preg_replace("/[^-a-z0-9\.\(\),_\* <>=!]+/i", '', $groupByField); + + $this->_groupBy[] = $groupByField; + return $this; + } + + + /** + * This method sets the current table lock method. + * + * @author Jonas Barascu + * + * @param string $method The table lock method. Can be READ or WRITE. + * + * @throws Exception + * @return MysqliDb + */ + public function setLockMethod($method) + { + // Switch the uppercase string + switch(strtoupper($method)) { + // Is it READ or WRITE? + case "READ" || "WRITE": + // Succeed + $this->_tableLockMethod = $method; + break; + default: + // Else throw an exception + throw new Exception("Bad lock type: Can be either READ or WRITE"); + break; + } + return $this; + } + + /** + * Locks a table for R/W action. + * + * @author Jonas Barascu + * + * @param string|array $table The table to be locked. Can be a table or a view. + * + * @return bool if succeeded; + * @throws Exception + */ + public function lock($table) + { + // Main Query + $this->_query = "LOCK TABLES"; + + // Is the table an array? + if(gettype($table) == "array") { + // Loop trough it and attach it to the query + foreach($table as $key => $value) { + if(gettype($value) == "string") { + if($key > 0) { + $this->_query .= ","; + } + $this->_query .= " ".self::$prefix.$value." ".$this->_tableLockMethod; + } + } + } + else{ + // Build the table prefix + $table = self::$prefix . $table; + + // Build the query + $this->_query = "LOCK TABLES ".$table." ".$this->_tableLockMethod; + } + + // Execute the query unprepared because LOCK only works with unprepared statements. + $result = $this->queryUnprepared($this->_query); + $errno = $this->mysqli()->errno; + + // Reset the query + $this->reset(); + + // Are there rows modified? + if($result) { + // Return true + // We can't return ourself because if one table gets locked, all other ones get unlocked! + return true; + } + // Something went wrong + else { + throw new Exception("Locking of table ".$table." failed", $errno); + } + + // Return the success value + return false; + } + + /** + * Unlocks all tables in a database. + * Also commits transactions. + * + * @author Jonas Barascu + * @return MysqliDb + * @throws Exception + */ + public function unlock() + { + // Build the query + $this->_query = "UNLOCK TABLES"; + + // Execute the query unprepared because UNLOCK and LOCK only works with unprepared statements. + $result = $this->queryUnprepared($this->_query); + $errno = $this->mysqli()->errno; + + // Reset the query + $this->reset(); + + // Are there rows modified? + if($result) { + // return self + return $this; + } + // Something went wrong + else { + throw new Exception("Unlocking of tables failed", $errno); + } + + + // Return self + return $this; + } + + + /** + * This methods returns the ID of the last inserted item + * + * @return int The last inserted item ID. + * @throws Exception + */ + public function getInsertId() + { + return $this->mysqli()->insert_id; + } + + /** + * Escape harmful characters which might affect a query. + * + * @param string $str The string to escape. + * + * @return string The escaped string. + * @throws Exception + */ + public function escape($str) + { + return $this->mysqli()->real_escape_string($str); + } + + /** + * Method to call mysqli->ping() to keep unused connections open on + * long-running scripts, or to reconnect timed out connections (if php.ini has + * global mysqli.reconnect set to true). Can't do this directly using object + * since _mysqli is protected. + * + * @return bool True if connection is up + * @throws Exception + */ + public function ping() + { + return $this->mysqli()->ping(); + } + + /** + * This method is needed for prepared statements. They require + * the data type of the field to be bound with "i" s", etc. + * This function takes the input, determines what type it is, + * and then updates the param_type. + * + * @param mixed $item Input to determine the type. + * + * @return string The joined parameter types. + */ + protected function _determineType($item) + { + switch (gettype($item)) { + case 'NULL': + case 'string': + return 's'; + break; + + case 'boolean': + case 'integer': + return 'i'; + break; + + case 'blob': + return 'b'; + break; + + case 'double': + return 'd'; + break; + } + return ''; + } + + /** + * Helper function to add variables into bind parameters array + * + * @param string Variable value + */ + protected function _bindParam($value) + { + $this->_bindParams[0] .= $this->_determineType($value); + array_push($this->_bindParams, $value); + } + + /** + * Helper function to add variables into bind parameters array in bulk + * + * @param array $values Variable with values + */ + protected function _bindParams($values) + { + foreach ($values as $value) { + $this->_bindParam($value); + } + } + + /** + * Helper function to add variables into bind parameters array and will return + * its SQL part of the query according to operator in ' $operator ?' or + * ' $operator ($subquery) ' formats + * + * @param string $operator + * @param mixed $value Variable with values + * + * @return string + */ + protected function _buildPair($operator, $value) + { + if (!is_object($value)) { + $this->_bindParam($value); + return ' ' . $operator . ' ? '; + } + + $subQuery = $value->getSubQuery(); + $this->_bindParams($subQuery['params']); + + return " " . $operator . " (" . $subQuery['query'] . ") " . $subQuery['alias']; + } + + /** + * Internal function to build and execute INSERT/REPLACE calls + * + * @param string $tableName The name of the table. + * @param array $insertData Data containing information for inserting into the DB. + * @param string $operation Type of operation (INSERT, REPLACE) + * + * @return bool Boolean indicating whether the insert query was completed successfully. + * @throws Exception + */ + private function _buildInsert($tableName, $insertData, $operation) + { + if ($this->isSubQuery) { + return; + } + + $this->_query = $operation . " " . implode(' ', $this->_queryOptions) . " INTO " . self::$prefix . $tableName; + $stmt = $this->_buildQuery(null, $insertData); + $status = $stmt->execute(); + $this->_stmtError = $stmt->error; + $this->_stmtErrno = $stmt->errno; + $haveOnDuplicate = !empty ($this->_updateColumns); + $this->reset(); + $this->count = $stmt->affected_rows; + + if ($stmt->affected_rows < 1) { + // in case of onDuplicate() usage, if no rows were inserted + if ($status && $haveOnDuplicate) { + return true; + } + return false; + } + + if ($stmt->insert_id > 0) { + return $stmt->insert_id; + } + + return true; + } + + /** + * Abstraction method that will compile the WHERE statement, + * any passed update data, and the desired rows. + * It then builds the SQL query. + * + * @param int|array $numRows Array to define SQL limit in format Array ($offset, $count) + * or only $count + * @param array $tableData Should contain an array of data for updating the database. + * + * @return mysqli_stmt|bool Returns the $stmt object. + * @throws Exception + */ + protected function _buildQuery($numRows = null, $tableData = null) + { + // $this->_buildJoinOld(); + $this->_buildJoin(); + $this->_buildInsertQuery($tableData); + $this->_buildCondition('WHERE', $this->_where); + $this->_buildGroupBy(); + $this->_buildCondition('HAVING', $this->_having); + $this->_buildOrderBy(); + $this->_buildLimit($numRows); + $this->_buildOnDuplicate($tableData); + + if ($this->_forUpdate) { + $this->_query .= ' FOR UPDATE'; + } + if ($this->_lockInShareMode) { + $this->_query .= ' LOCK IN SHARE MODE'; + } + + $this->_lastQuery = $this->replacePlaceHolders($this->_query, $this->_bindParams); + + if ($this->isSubQuery) { + return; + } + + // Prepare query + $stmt = $this->_prepareQuery(); + + // Bind parameters to statement if any + if (count($this->_bindParams) > 1) { + call_user_func_array(array($stmt, 'bind_param'), $this->refValues($this->_bindParams)); + } + + return $stmt; + } + + /** + * This helper method takes care of prepared statements' "bind_result method + * , when the number of variables to pass is unknown. + * + * @param mysqli_stmt $stmt Equal to the prepared statement object. + * + * @return array|string The results of the SQL fetch. + * @throws Exception + */ + protected function _dynamicBindResults(mysqli_stmt $stmt) + { + $parameters = array(); + $results = array(); + /** + * @see http://php.net/manual/en/mysqli-result.fetch-fields.php + */ + $mysqlLongType = 252; + $shouldStoreResult = false; + + $meta = $stmt->result_metadata(); + + // if $meta is false yet sqlstate is true, there's no sql error but the query is + // most likely an update/insert/delete which doesn't produce any results + if (!$meta && $stmt->sqlstate) + return array(); + + $row = array(); + while ($field = $meta->fetch_field()) { + if ($field->type == $mysqlLongType) { + $shouldStoreResult = true; + } + + if ($this->_nestJoin && $field->table != $this->_tableName) { + $field->table = substr($field->table, strlen(self::$prefix)); + $row[$field->table][$field->name] = null; + $parameters[] = & $row[$field->table][$field->name]; + } else { + $row[$field->name] = null; + $parameters[] = & $row[$field->name]; + } + } + + // avoid out of memory bug in php 5.2 and 5.3. Mysqli allocates lot of memory for long* + // and blob* types. So to avoid out of memory issues store_result is used + // https://github.com/joshcam/PHP-MySQLi-Database-Class/pull/119 + if ($shouldStoreResult) { + $stmt->store_result(); + } + + call_user_func_array(array($stmt, 'bind_result'), $parameters); + + $this->totalCount = 0; + $this->count = 0; + + while ($stmt->fetch()) { + if ($this->returnType == 'object') { + $result = new stdClass (); + foreach ($row as $key => $val) { + if (is_array($val)) { + $result->$key = new stdClass (); + foreach ($val as $k => $v) { + $result->$key->$k = $v; + } + } else { + $result->$key = $val; + } + } + } else { + $result = array(); + foreach ($row as $key => $val) { + if (is_array($val)) { + foreach ($val as $k => $v) { + $result[$key][$k] = $v; + } + } else { + $result[$key] = $val; + } + } + } + $this->count++; + if ($this->_mapKey) { + $results[$row[$this->_mapKey]] = count($row) > 2 ? $result : end($result); + } else { + array_push($results, $result); + } + } + + if ($shouldStoreResult) { + $stmt->free_result(); + } + + $stmt->close(); + + // stored procedures sometimes can return more then 1 resultset + if ($this->mysqli()->more_results()) { + $this->mysqli()->next_result(); + } + + if (in_array('SQL_CALC_FOUND_ROWS', $this->_queryOptions)) { + $stmt = $this->mysqli()->query('SELECT FOUND_ROWS()'); + $totalCount = $stmt->fetch_row(); + $this->totalCount = $totalCount[0]; + } + + if ($this->returnType == 'json') { + return json_encode($results); + } + + return $results; + } + + /** + * Abstraction method that will build an JOIN part of the query + * + * @return void + */ + protected function _buildJoinOld() + { + if (empty($this->_join)) { + return; + } + + foreach ($this->_join as $data) { + list ($joinType, $joinTable, $joinCondition) = $data; + + if (is_object($joinTable)) { + $joinStr = $this->_buildPair("", $joinTable); + } else { + $joinStr = $joinTable; + } + + $this->_query .= " " . $joinType . " JOIN " . $joinStr . + (false !== stripos($joinCondition, 'using') ? " " : " on ") + . $joinCondition; + } + } + + /** + * Insert/Update query helper + * + * @param array $tableData + * @param array $tableColumns + * @param bool $isInsert INSERT operation flag + * + * @throws Exception + */ + public function _buildDataPairs($tableData, $tableColumns, $isInsert) + { + foreach ($tableColumns as $column) { + $value = $tableData[$column]; + + if (!$isInsert) { + if(strpos($column,'.')===false) { + $this->_query .= "`" . $column . "` = "; + } else { + $this->_query .= str_replace('.','.`',$column) . "` = "; + } + } + + // Subquery value + if ($value instanceof MysqliDb) { + $this->_query .= $this->_buildPair("", $value) . ", "; + continue; + } + + // Simple value + if (!is_array($value)) { + $this->_bindParam($value); + $this->_query .= '?, '; + continue; + } + + // Function value + $key = key($value); + $val = $value[$key]; + switch ($key) { + case '[I]': + $this->_query .= $column . $val . ", "; + break; + case '[F]': + $this->_query .= $val[0] . ", "; + if (!empty($val[1])) { + $this->_bindParams($val[1]); + } + break; + case '[N]': + if ($val == null) { + $this->_query .= "!" . $column . ", "; + } else { + $this->_query .= "!" . $val . ", "; + } + break; + default: + throw new Exception("Wrong operation"); + } + } + $this->_query = rtrim($this->_query, ', '); + } + + /** + * Helper function to add variables into the query statement + * + * @param array $tableData Variable with values + * + * @throws Exception + */ + protected function _buildOnDuplicate($tableData) + { + if (is_array($this->_updateColumns) && !empty($this->_updateColumns)) { + $this->_query .= " ON DUPLICATE KEY UPDATE "; + if ($this->_lastInsertId) { + $this->_query .= $this->_lastInsertId . "=LAST_INSERT_ID (" . $this->_lastInsertId . "), "; + } + + foreach ($this->_updateColumns as $key => $val) { + // skip all params without a value + if (is_numeric($key)) { + $this->_updateColumns[$val] = ''; + unset($this->_updateColumns[$key]); + } else { + $tableData[$key] = $val; + } + } + $this->_buildDataPairs($tableData, array_keys($this->_updateColumns), false); + } + } + + /** + * Abstraction method that will build an INSERT or UPDATE part of the query + * + * @param array $tableData + * + * @throws Exception + */ + protected function _buildInsertQuery($tableData) + { + if (!is_array($tableData)) { + return; + } + + $isInsert = preg_match('/^[INSERT|REPLACE]/', $this->_query); + $dataColumns = array_keys($tableData); + if ($isInsert) { + if (isset ($dataColumns[0])) + $this->_query .= ' (`' . implode('`, `', $dataColumns) . '`) '; + $this->_query .= ' VALUES ('; + } else { + $this->_query .= " SET "; + } + + $this->_buildDataPairs($tableData, $dataColumns, $isInsert); + + if ($isInsert) { + $this->_query .= ')'; + } + } + + /** + * Abstraction method that will build the part of the WHERE conditions + * + * @param string $operator + * @param array $conditions + */ + protected function _buildCondition($operator, &$conditions) + { + if (empty($conditions)) { + return; + } + + //Prepare the where portion of the query + $this->_query .= ' ' . $operator; + + foreach ($conditions as $cond) { + list ($concat, $varName, $operator, $val) = $cond; + $this->_query .= " " . $concat . " " . $varName; + + switch (strtolower($operator)) { + case 'not in': + case 'in': + $comparison = ' ' . $operator . ' ('; + if (is_object($val)) { + $comparison .= $this->_buildPair("", $val); + } else { + foreach ($val as $v) { + $comparison .= ' ?,'; + $this->_bindParam($v); + } + } + $this->_query .= rtrim($comparison, ',') . ' ) '; + break; + case 'not between': + case 'between': + $this->_query .= " $operator ? AND ? "; + $this->_bindParams($val); + break; + case 'not exists': + case 'exists': + $this->_query.= $operator . $this->_buildPair("", $val); + break; + default: + if (is_array($val)) { + $this->_bindParams($val); + } elseif ($val === null) { + $this->_query .= ' ' . $operator . " NULL"; + } elseif ($val != 'DBNULL' || $val == '0') { + $this->_query .= $this->_buildPair($operator, $val); + } + } + } + } + + /** + * Abstraction method that will build the GROUP BY part of the WHERE statement + * + * @return void + */ + protected function _buildGroupBy() + { + if (empty($this->_groupBy)) { + return; + } + + $this->_query .= " GROUP BY "; + + foreach ($this->_groupBy as $key => $value) { + $this->_query .= $value . ", "; + } + + $this->_query = rtrim($this->_query, ', ') . " "; + } + + /** + * Abstraction method that will build the LIMIT part of the WHERE statement + * + * @return void + */ + protected function _buildOrderBy() + { + if (empty($this->_orderBy)) { + return; + } + + $this->_query .= " ORDER BY "; + foreach ($this->_orderBy as $prop => $value) { + if (strtolower(str_replace(" ", "", $prop)) == 'rand()') { + $this->_query .= "rand(), "; + } else { + $this->_query .= $prop . " " . $value . ", "; + } + } + + $this->_query = rtrim($this->_query, ', ') . " "; + } + + /** + * Abstraction method that will build the LIMIT part of the WHERE statement + * + * @param int|array $numRows Array to define SQL limit in format Array ($offset, $count) + * or only $count + * + * @return void + */ + protected function _buildLimit($numRows) + { + if (!isset($numRows)) { + return; + } + + if (is_array($numRows)) { + $this->_query .= ' LIMIT ' . (int) $numRows[0] . ', ' . (int) $numRows[1]; + } else { + $this->_query .= ' LIMIT ' . (int) $numRows; + } + } + + /** + * Method attempts to prepare the SQL query + * and throws an error if there was a problem. + * + * @return mysqli_stmt + * @throws Exception + */ + protected function _prepareQuery() + { + $stmt = $this->mysqli()->prepare($this->_query); + + if ($stmt !== false) { + if ($this->traceEnabled) + $this->traceStartQ = microtime(true); + return $stmt; + } + + if ($this->mysqli()->errno === 2006 && $this->autoReconnect === true && $this->autoReconnectCount === 0) { + $this->connect($this->defConnectionName); + $this->autoReconnectCount++; + return $this->_prepareQuery(); + } + + $error = $this->mysqli()->error; + $query = $this->_query; + $errno = $this->mysqli()->errno; + $this->reset(); + throw new Exception(sprintf('%s query: %s', $error, $query), $errno); + } + + /** + * Referenced data array is required by mysqli since PHP 5.3+ + * + * @param array $arr + * + * @return array + */ + protected function refValues(array &$arr) + { + //Reference in the function arguments are required for HHVM to work + //https://github.com/facebook/hhvm/issues/5155 + //Referenced data array is required by mysqli since PHP 5.3+ + if (strnatcmp(phpversion(), '5.3') >= 0) { + $refs = array(); + foreach ($arr as $key => $value) { + $refs[$key] = & $arr[$key]; + } + return $refs; + } + return $arr; + } + + /** + * Function to replace ? with variables from bind variable + * + * @param string $str + * @param array $vals + * + * @return string + */ + protected function replacePlaceHolders($str, $vals) + { + $i = 1; + $newStr = ""; + + if (empty($vals)) { + return $str; + } + + while ($pos = strpos($str, "?")) { + $val = $vals[$i++]; + if (is_object($val)) { + $val = '[object]'; + } + if ($val === null) { + $val = 'NULL'; + } + $newStr .= substr($str, 0, $pos) . "'" . $val . "'"; + $str = substr($str, $pos + 1); + } + $newStr .= $str; + return $newStr; + } + + /** + * Method returns last executed query + * + * @return string + */ + public function getLastQuery() + { + return $this->_lastQuery; + } + + /** + * Method returns mysql error + * + * @return string + * @throws Exception + */ + public function getLastError() + { + if (!isset($this->_mysqli[$this->defConnectionName])) { + return "mysqli is null"; + } + return trim($this->_stmtError . " " . $this->mysqli()->error); + } + + /** + * Method returns mysql error code + * + * @return int + */ + public function getLastErrno () { + return $this->_stmtErrno; + } + + /** + * Mostly internal method to get query and its params out of subquery object + * after get() and getAll() + * + * @return array + */ + public function getSubQuery() + { + if (!$this->isSubQuery) { + return null; + } + + array_shift($this->_bindParams); + $val = Array('query' => $this->_query, + 'params' => $this->_bindParams, + 'alias' => isset($this->connectionsSettings[$this->defConnectionName]) ? $this->connectionsSettings[$this->defConnectionName]['host'] : null + ); + $this->reset(); + return $val; + } + + /* Helper functions */ + + /** + * Method returns generated interval function as a string + * + * @param string $diff interval in the formats: + * "1", "-1d" or "- 1 day" -- For interval - 1 day + * Supported intervals [s]econd, [m]inute, [h]hour, [d]day, [M]onth, [Y]ear + * Default null; + * @param string $func Initial date + * + * @return string + * @throws Exception + */ + public function interval($diff, $func = "NOW()") + { + $types = Array("s" => "second", "m" => "minute", "h" => "hour", "d" => "day", "M" => "month", "Y" => "year"); + $incr = '+'; + $items = ''; + $type = 'd'; + + if ($diff && preg_match('/([+-]?) ?([0-9]+) ?([a-zA-Z]?)/', $diff, $matches)) { + if (!empty($matches[1])) { + $incr = $matches[1]; + } + + if (!empty($matches[2])) { + $items = $matches[2]; + } + + if (!empty($matches[3])) { + $type = $matches[3]; + } + + if (!in_array($type, array_keys($types))) { + throw new Exception("invalid interval type in '{$diff}'"); + } + + $func .= " " . $incr . " interval " . $items . " " . $types[$type] . " "; + } + return $func; + } + + /** + * Method returns generated interval function as an insert/update function + * + * @param string $diff interval in the formats: + * "1", "-1d" or "- 1 day" -- For interval - 1 day + * Supported intervals [s]econd, [m]inute, [h]hour, [d]day, [M]onth, [Y]ear + * Default null; + * @param string $func Initial date + * + * @return array + * @throws Exception + */ + public function now($diff = null, $func = "NOW()") + { + return array("[F]" => Array($this->interval($diff, $func))); + } + + /** + * Method generates incremental function call + * + * @param int $num increment by int or float. 1 by default + * + * @throws Exception + * @return array + */ + public function inc($num = 1) + { + if (!is_numeric($num)) { + throw new Exception('Argument supplied to inc must be a number'); + } + return array("[I]" => "+" . $num); + } + + /** + * Method generates decremental function call + * + * @param int $num increment by int or float. 1 by default + * + * @return array + * @throws Exception + */ + public function dec($num = 1) + { + if (!is_numeric($num)) { + throw new Exception('Argument supplied to dec must be a number'); + } + return array("[I]" => "-" . $num); + } + + /** + * Method generates change boolean function call + * + * @param string $col column name. null by default + * + * @return array + */ + public function not($col = null) + { + return array("[N]" => (string)$col); + } + + /** + * Method generates user defined function call + * + * @param string $expr user function body + * @param array $bindParams + * + * @return array + */ + public function func($expr, $bindParams = null) + { + return array("[F]" => array($expr, $bindParams)); + } + + /** + * Method creates new mysqlidb object for a subquery generation + * + * @param string $subQueryAlias + * + * @return MysqliDb + */ + public static function subQuery($subQueryAlias = "") + { + return new self(array('host' => $subQueryAlias, 'isSubQuery' => true)); + } + + /** + * Method returns a copy of a mysqlidb subquery object + * + * @return MysqliDb new mysqlidb object + */ + public function copy() + { + $copy = unserialize(serialize($this)); + $copy->_mysqli = array(); + return $copy; + } + + /** + * Begin a transaction + * + * @uses mysqli->autocommit(false) + * @uses register_shutdown_function(array($this, "_transaction_shutdown_check")) + * @throws Exception + */ + public function startTransaction() + { + $this->mysqli()->autocommit(false); + $this->_transaction_in_progress = true; + register_shutdown_function(array($this, "_transaction_status_check")); + } + + /** + * Transaction commit + * + * @uses mysqli->commit(); + * @uses mysqli->autocommit(true); + * @throws Exception + */ + public function commit() + { + $result = $this->mysqli()->commit(); + $this->_transaction_in_progress = false; + $this->mysqli()->autocommit(true); + return $result; + } + + /** + * Transaction rollback function + * + * @uses mysqli->rollback(); + * @uses mysqli->autocommit(true); + * @throws Exception + */ + public function rollback() + { + $result = $this->mysqli()->rollback(); + $this->_transaction_in_progress = false; + $this->mysqli()->autocommit(true); + return $result; + } + + /** + * Shutdown handler to rollback uncommited operations in order to keep + * atomic operations sane. + * + * @uses mysqli->rollback(); + * @throws Exception + */ + public function _transaction_status_check() + { + if (!$this->_transaction_in_progress) { + return; + } + $this->rollback(); + } + + /** + * Query execution time tracking switch + * + * @param bool $enabled Enable execution time tracking + * @param string $stripPrefix Prefix to strip from the path in exec log + * + * @return MysqliDb + */ + public function setTrace($enabled, $stripPrefix = null) + { + $this->traceEnabled = $enabled; + $this->traceStripPrefix = $stripPrefix; + return $this; + } + + /** + * Get where and what function was called for query stored in MysqliDB->trace + * + * @return string with information + */ + private function _traceGetCaller() + { + $dd = debug_backtrace(); + $caller = next($dd); + while (isset($caller) && $caller["file"] == __FILE__) { + $caller = next($dd); + } + + return __CLASS__ . "->" . $caller["function"] . "() >> file \"" . + str_replace($this->traceStripPrefix, '', $caller["file"]) . "\" line #" . $caller["line"] . " "; + } + + /** + * Method to check if needed table is created + * + * @param array $tables Table name or an Array of table names to check + * + * @return bool True if table exists + * @throws Exception + */ + public function tableExists($tables) + { + $tables = !is_array($tables) ? Array($tables) : $tables; + $count = count($tables); + if ($count == 0) { + return false; + } + + foreach ($tables as $i => $value) + $tables[$i] = self::$prefix . $value; + $db = isset($this->connectionsSettings[$this->defConnectionName]) ? $this->connectionsSettings[$this->defConnectionName]['db'] : null; + $this->where('table_schema', $db); + $this->where('table_name', $tables, 'in'); + $this->get('information_schema.tables', $count); + return $this->count == $count; + } + + /** + * Return result as an associative array with $idField field value used as a record key + * + * Array Returns an array($k => $v) if get(.."param1, param2"), array ($k => array ($v, $v)) otherwise + * + * @param string $idField field name to use for a mapped element key + * + * @return MysqliDb + */ + public function map($idField) + { + $this->_mapKey = $idField; + return $this; + } + + /** + * Pagination wrapper to get() + * + * @access public + * + * @param string $table The name of the database table to work with + * @param int $page Page number + * @param array|string $fields Array or coma separated list of fields to fetch + * + * @return array + * @throws Exception + */ + public function paginate ($table, $page, $fields = null) { + $offset = $this->pageLimit * ($page - 1); + $res = $this->withTotalCount()->get ($table, Array ($offset, $this->pageLimit), $fields); + $this->totalPages = ceil($this->totalCount / $this->pageLimit); + return $res; + } + + /** + * This method allows you to specify multiple (method chaining optional) AND WHERE statements for the join table on part of the SQL query. + * + * @uses $dbWrapper->joinWhere('user u', 'u.id', 7)->where('user u', 'u.title', 'MyTitle'); + * + * @param string $whereJoin The name of the table followed by its prefix. + * @param string $whereProp The name of the database field. + * @param mixed $whereValue The value of the database field. + * + * @param string $operator + * @param string $cond + * + * @return $this + */ + public function joinWhere($whereJoin, $whereProp, $whereValue = 'DBNULL', $operator = '=', $cond = 'AND') + { + $this->_joinAnd[self::$prefix . $whereJoin][] = Array ($cond, $whereProp, $operator, $whereValue); + return $this; + } + + /** + * This method allows you to specify multiple (method chaining optional) OR WHERE statements for the join table on part of the SQL query. + * + * @uses $dbWrapper->joinWhere('user u', 'u.id', 7)->where('user u', 'u.title', 'MyTitle'); + * + * @param string $whereJoin The name of the table followed by its prefix. + * @param string $whereProp The name of the database field. + * @param mixed $whereValue The value of the database field. + * @param string $operator + * + * @return $this + */ + public function joinOrWhere($whereJoin, $whereProp, $whereValue = 'DBNULL', $operator = '=', $cond = 'AND') + { + return $this->joinWhere($whereJoin, $whereProp, $whereValue, $operator, 'OR'); + } + + /** + * Abstraction method that will build an JOIN part of the query + */ + protected function _buildJoin () { + if (empty ($this->_join)) + return; + + foreach ($this->_join as $data) { + list ($joinType, $joinTable, $joinCondition) = $data; + + if (is_object ($joinTable)) + $joinStr = $this->_buildPair ("", $joinTable); + else + $joinStr = $joinTable; + + $this->_query .= " " . $joinType. " JOIN " . $joinStr . + (false !== stripos($joinCondition, 'using') ? " " : " on ") + . $joinCondition; + + // Add join and query + if (!empty($this->_joinAnd) && isset($this->_joinAnd[$joinStr])) { + foreach($this->_joinAnd[$joinStr] as $join_and_cond) { + list ($concat, $varName, $operator, $val) = $join_and_cond; + $this->_query .= " " . $concat ." " . $varName; + $this->conditionToSql($operator, $val); + } + } + } + } + + /** + * Convert a condition and value into the sql string + * + * @param String $operator The where constraint operator + * @param String|array $val The where constraint value + */ + private function conditionToSql($operator, $val) { + switch (strtolower ($operator)) { + case 'not in': + case 'in': + $comparison = ' ' . $operator. ' ('; + if (is_object ($val)) { + $comparison .= $this->_buildPair ("", $val); + } else { + foreach ($val as $v) { + $comparison .= ' ?,'; + $this->_bindParam ($v); + } + } + $this->_query .= rtrim($comparison, ',').' ) '; + break; + case 'not between': + case 'between': + $this->_query .= " $operator ? AND ? "; + $this->_bindParams ($val); + break; + case 'not exists': + case 'exists': + $this->_query.= $operator . $this->_buildPair ("", $val); + break; + default: + if (is_array ($val)) + $this->_bindParams ($val); + else if ($val === null) + $this->_query .= $operator . " NULL"; + else if ($val != 'DBNULL' || $val == '0') + $this->_query .= $this->_buildPair ($operator, $val); + } + } +} + +// END class diff --git a/Flare/Flare_Libraries/dbObject.php b/Flare/Flare_Libraries/dbObject.php new file mode 100644 index 0000000..304630a --- /dev/null +++ b/Flare/Flare_Libraries/dbObject.php @@ -0,0 +1,807 @@ + + * @copyright Copyright (c) 2015-2017 + * @license http://opensource.org/licenses/gpl-3.0.html GNU Public License + * @link http://github.com/joshcam/PHP-MySQLi-Database-Class + * @version 2.9-master + * + * @method int count () + * @method dbObject ArrayBuilder() + * @method dbObject JsonBuilder() + * @method dbObject ObjectBuilder() + * @method mixed byId(string $id, mixed $fields) + * @method mixed get(mixed $limit, mixed $fields) + * @method mixed getOne(mixed $fields) + * @method mixed paginate(int $page, array $fields) + * @method dbObject query($query, $numRows = null) + * @method dbObject rawQuery($query, $bindParams = null) + * @method dbObject join(string $objectName, string $key, string $joinType, string $primaryKey) + * @method dbObject with(string $objectName) + * @method dbObject groupBy(string $groupByField) + * @method dbObject orderBy($orderByField, $orderbyDirection = "DESC", $customFieldsOrRegExp = null) + * @method dbObject where($whereProp, $whereValue = 'DBNULL', $operator = '=', $cond = 'AND') + * @method dbObject orWhere($whereProp, $whereValue = 'DBNULL', $operator = '=') + * @method dbObject having($havingProp, $havingValue = 'DBNULL', $operator = '=', $cond = 'AND') + * @method dbObject orHaving($havingProp, $havingValue = null, $operator = null) + * @method dbObject setQueryOption($options) + * @method dbObject setTrace($enabled, $stripPrefix = null) + * @method dbObject withTotalCount() + * @method dbObject startTransaction() + * @method dbObject commit() + * @method dbObject rollback() + * @method dbObject ping() + * @method string getLastError() + * @method string getLastQuery() + */ +class dbObject { + /** + * Working instance of MysqliDb created earlier + * + * @var MysqliDb + */ + private $db; + /** + * Models path + * + * @var modelPath + */ + protected static $modelPath; + /** + * An array that holds object data + * + * @var array + */ + public $data; + /** + * Flag to define is object is new or loaded from database + * + * @var boolean + */ + public $isNew = true; + /** + * Return type: 'Array' to return results as array, 'Object' as object + * 'Json' as json string + * + * @var string + */ + public $returnType = 'Object'; + /** + * An array that holds has* objects which should be loaded togeather with main + * object togeather with main object + * + * @var string + */ + private $_with = Array(); + /** + * Per page limit for pagination + * + * @var int + */ + public static $pageLimit = 20; + /** + * Variable that holds total pages count of last paginate() query + * + * @var int + */ + public static $totalPages = 0; + /** + * Variable which holds an amount of returned rows during paginate queries + * @var string + */ + public static $totalCount = 0; + /** + * An array that holds insert/update/select errors + * + * @var array + */ + public $errors = null; + /** + * Primary key for an object. 'id' is a default value. + * + * @var stating + */ + protected $primaryKey = 'id'; + /** + * Table name for an object. Class name will be used by default + * + * @var stating + */ + protected $dbTable; + + /** + * @var array name of the fields that will be skipped during validation, preparing & saving + */ + protected $toSkip = array(); + + /** + * @param array $data Data to preload on object creation + */ + public function __construct ($data = null) { + $this->db = MysqliDb::getInstance(); + if (empty ($this->dbTable)) + $this->dbTable = get_class ($this); + + if ($data) + $this->data = $data; + } + + /** + * Magic setter function + * + * @return mixed + */ + public function __set ($name, $value) { + if (property_exists ($this, 'hidden') && array_search ($name, $this->hidden) !== false) + return; + + $this->data[$name] = $value; + } + + /** + * Magic getter function + * + * @param $name Variable name + * + * @return mixed + */ + public function __get ($name) { + if (property_exists ($this, 'hidden') && array_search ($name, $this->hidden) !== false) + return null; + + if (isset ($this->data[$name]) && $this->data[$name] instanceof dbObject) + return $this->data[$name]; + + if (property_exists ($this, 'relations') && isset ($this->relations[$name])) { + $relationType = strtolower ($this->relations[$name][0]); + $modelName = $this->relations[$name][1]; + switch ($relationType) { + case 'hasone': + $key = isset ($this->relations[$name][2]) ? $this->relations[$name][2] : $name; + $obj = new $modelName; + $obj->returnType = $this->returnType; + return $this->data[$name] = $obj->byId($this->data[$key]); + break; + case 'hasmany': + $key = $this->relations[$name][2]; + $obj = new $modelName; + $obj->returnType = $this->returnType; + return $this->data[$name] = $obj->where($key, $this->data[$this->primaryKey])->get(); + break; + default: + break; + } + } + + if (isset ($this->data[$name])) + return $this->data[$name]; + + if (property_exists ($this->db, $name)) + return $this->db->$name; + } + + public function __isset ($name) { + if (isset ($this->data[$name])) + return isset ($this->data[$name]); + + if (property_exists ($this->db, $name)) + return isset ($this->db->$name); + } + + public function __unset ($name) { + unset ($this->data[$name]); + } + + /** + * Helper function to create dbObject with Json return type + * + * @return dbObject + */ + private function JsonBuilder () { + $this->returnType = 'Json'; + return $this; + } + + /** + * Helper function to create dbObject with Array return type + * + * @return dbObject + */ + private function ArrayBuilder () { + $this->returnType = 'Array'; + return $this; + } + + /** + * Helper function to create dbObject with Object return type. + * Added for consistency. Works same way as new $objname () + * + * @return dbObject + */ + private function ObjectBuilder () { + $this->returnType = 'Object'; + return $this; + } + + /** + * Helper function to create a virtual table class + * + * @param string tableName Table name + * @return dbObject + */ + public static function table ($tableName) { + $tableName = preg_replace ("/[^-a-z0-9_]+/i",'', $tableName); + if (!class_exists ($tableName)) + eval ("class $tableName extends dbObject {}"); + return new $tableName (); + } + /** + * @return mixed insert id or false in case of failure + */ + public function insert () { + if (!empty ($this->timestamps) && in_array ("createdAt", $this->timestamps)) + $this->createdAt = date("Y-m-d H:i:s"); + $sqlData = $this->prepareData (); + if (!$this->validate ($sqlData)) + return false; + + $id = $this->db->insert ($this->dbTable, $sqlData); + if (!empty ($this->primaryKey) && empty ($this->data[$this->primaryKey])) + $this->data[$this->primaryKey] = $id; + $this->isNew = false; + $this->toSkip = array(); + return $id; + } + + /** + * @param array $data Optional update data to apply to the object + */ + public function update ($data = null) { + if (empty ($this->dbFields)) + return false; + + if (empty ($this->data[$this->primaryKey])) + return false; + + if ($data) { + foreach ($data as $k => $v) { + if (in_array($k, $this->toSkip)) + continue; + + $this->$k = $v; + } + } + + if (!empty ($this->timestamps) && in_array ("updatedAt", $this->timestamps)) + $this->updatedAt = date("Y-m-d H:i:s"); + + $sqlData = $this->prepareData (); + if (!$this->validate ($sqlData)) + return false; + + $this->db->where ($this->primaryKey, $this->data[$this->primaryKey]); + $res = $this->db->update ($this->dbTable, $sqlData); + $this->toSkip = array(); + return $res; + } + + /** + * Save or Update object + * + * @return mixed insert id or false in case of failure + */ + public function save ($data = null) { + if ($this->isNew) + return $this->insert(); + return $this->update ($data); + } + + /** + * Delete method. Works only if object primaryKey is defined + * + * @return boolean Indicates success. 0 or 1. + */ + public function delete () { + if (empty ($this->data[$this->primaryKey])) + return false; + + $this->db->where ($this->primaryKey, $this->data[$this->primaryKey]); + $res = $this->db->delete ($this->dbTable); + $this->toSkip = array(); + return $res; + } + + /** + * chained method that append a field or fields to skipping + * @param mixed|array|false $field field name; array of names; empty skipping if false + * @return $this + */ + public function skip($field){ + if(is_array($field)) { + foreach ($field as $f) { + $this->toSkip[] = $f; + } + } else if($field === false) { + $this->toSkip = array(); + } else{ + $this->toSkip[] = $field; + } + return $this; + } + + /** + * Get object by primary key. + * + * @access public + * @param $id Primary Key + * @param array|string $fields Array or coma separated list of fields to fetch + * + * @return dbObject|array + */ + private function byId ($id, $fields = null) { + $this->db->where (MysqliDb::$prefix . $this->dbTable . '.' . $this->primaryKey, $id); + return $this->getOne ($fields); + } + + /** + * Convinient function to fetch one object. Mostly will be togeather with where() + * + * @access public + * @param array|string $fields Array or coma separated list of fields to fetch + * + * @return dbObject + */ + protected function getOne ($fields = null) { + $this->processHasOneWith (); + $results = $this->db->ArrayBuilder()->getOne ($this->dbTable, $fields); + if ($this->db->count == 0) + return null; + + $this->processArrays ($results); + $this->data = $results; + $this->processAllWith ($results); + if ($this->returnType == 'Json') + return json_encode ($results); + if ($this->returnType == 'Array') + return $results; + + $item = new static ($results); + $item->isNew = false; + + return $item; + } + + /** + * A convenient SELECT COLUMN function to get a single column value from model object + * + * @param string $column The desired column + * @param int $limit Limit of rows to select. Use null for unlimited..1 by default + * + * @return mixed Contains the value of a returned column / array of values + * @throws Exception + */ + protected function getValue ($column, $limit = 1) { + $res = $this->db->ArrayBuilder()->getValue ($this->dbTable, $column, $limit); + if (!$res) + return null; + return $res; + } + + /** + * A convenient function that returns TRUE if exists at least an element that + * satisfy the where condition specified calling the "where" method before this one. + * + * @return bool + * @throws Exception + */ + protected function has() { + return $this->db->has($this->dbTable); + } + + /** + * Fetch all objects + * + * @access public + * @param integer|array $limit Array to define SQL limit in format Array ($count, $offset) + * or only $count + * @param array|string $fields Array or coma separated list of fields to fetch + * + * @return array Array of dbObjects + */ + protected function get ($limit = null, $fields = null) { + $objects = Array (); + $this->processHasOneWith (); + $results = $this->db->ArrayBuilder()->get ($this->dbTable, $limit, $fields); + if ($this->db->count == 0) + return null; + + foreach ($results as $k => &$r) { + $this->processArrays ($r); + $this->data = $r; + $this->processAllWith ($r, false); + if ($this->returnType == 'Object') { + $item = new static ($r); + $item->isNew = false; + $objects[$k] = $item; + } + } + $this->_with = Array(); + if ($this->returnType == 'Object') + return $objects; + + if ($this->returnType == 'Json') + return json_encode ($results); + + return $results; + } + + /** + * Function to set witch hasOne or hasMany objects should be loaded togeather with a main object + * + * @access public + * @param string $objectName Object Name + * + * @return dbObject + */ + private function with ($objectName) { + if (!property_exists ($this, 'relations') || !isset ($this->relations[$objectName])) + die ("No relation with name $objectName found"); + + $this->_with[$objectName] = $this->relations[$objectName]; + + return $this; + } + + /** + * Function to join object with another object. + * + * @access public + * @param string $objectName Object Name + * @param string $key Key for a join from primary object + * @param string $joinType SQL join type: LEFT, RIGHT, INNER, OUTER + * @param string $primaryKey SQL join On Second primaryKey + * + * @return dbObject + */ + private function join ($objectName, $key = null, $joinType = 'LEFT', $primaryKey = null) { + $joinObj = new $objectName; + if (!$key) + $key = $objectName . "id"; + + if (!$primaryKey) + $primaryKey = MysqliDb::$prefix . $joinObj->dbTable . "." . $joinObj->primaryKey; + + if (!strchr ($key, '.')) + $joinStr = MysqliDb::$prefix . $this->dbTable . ".{$key} = " . $primaryKey; + else + $joinStr = MysqliDb::$prefix . "{$key} = " . $primaryKey; + + $this->db->join ($joinObj->dbTable, $joinStr, $joinType); + return $this; + } + + /** + * Function to get a total records count + * + * @return int + */ + protected function count () { + $res = $this->db->ArrayBuilder()->getValue ($this->dbTable, "count(*)"); + if (!$res) + return 0; + return $res; + } + + /** + * Pagination wraper to get() + * + * @access public + * @param int $page Page number + * @param array|string $fields Array or coma separated list of fields to fetch + * @return array + */ + private function paginate ($page, $fields = null) { + $this->db->pageLimit = self::$pageLimit; + $objects = Array (); + $this->processHasOneWith (); + $res = $this->db->paginate ($this->dbTable, $page, $fields); + self::$totalPages = $this->db->totalPages; + self::$totalCount = $this->db->totalCount; + if ($this->db->count == 0) return null; + + foreach ($res as $k => &$r) { + $this->processArrays ($r); + $this->data = $r; + $this->processAllWith ($r, false); + if ($this->returnType == 'Object') { + $item = new static ($r); + $item->isNew = false; + $objects[$k] = $item; + } + } + $this->_with = Array(); + if ($this->returnType == 'Object') + return $objects; + + if ($this->returnType == 'Json') + return json_encode ($res); + + return $res; + } + + /** + * Catches calls to undefined methods. + * + * Provides magic access to private functions of the class and native public mysqlidb functions + * + * @param string $method + * @param mixed $arg + * + * @return mixed + */ + public function __call ($method, $arg) { + if (method_exists ($this, $method)) + return call_user_func_array (array ($this, $method), $arg); + + call_user_func_array (array ($this->db, $method), $arg); + return $this; + } + + /** + * Catches calls to undefined static methods. + * + * Transparently creating dbObject class to provide smooth API like name::get() name::orderBy()->get() + * + * @param string $method + * @param mixed $arg + * + * @return mixed + */ + public static function __callStatic ($method, $arg) { + $obj = new static; + $result = call_user_func_array (array ($obj, $method), $arg); + if (method_exists ($obj, $method)) + return $result; + return $obj; + } + + /** + * Converts object data to an associative array. + * + * @return array Converted data + */ + public function toArray () { + $data = $this->data; + $this->processAllWith ($data); + foreach ($data as &$d) { + if ($d instanceof dbObject) + $d = $d->data; + } + return $data; + } + + /** + * Converts object data to a JSON string. + * + * @return string Converted data + */ + public function toJson () { + return json_encode ($this->toArray()); + } + + /** + * Converts object data to a JSON string. + * + * @return string Converted data + */ + public function __toString () { + return $this->toJson (); + } + + /** + * Function queries hasMany relations if needed and also converts hasOne object names + * + * @param array $data + */ + private function processAllWith (&$data, $shouldReset = true) { + if (count ($this->_with) == 0) + return; + + foreach ($this->_with as $name => $opts) { + $relationType = strtolower ($opts[0]); + $modelName = $opts[1]; + if ($relationType == 'hasone') { + $obj = new $modelName; + $table = $obj->dbTable; + $primaryKey = $obj->primaryKey; + + if (!isset ($data[$table])) { + $data[$name] = $this->$name; + continue; + } + if ($data[$table][$primaryKey] === null) { + $data[$name] = null; + } else { + if ($this->returnType == 'Object') { + $item = new $modelName ($data[$table]); + $item->returnType = $this->returnType; + $item->isNew = false; + $data[$name] = $item; + } else { + $data[$name] = $data[$table]; + } + } + unset ($data[$table]); + } + else + $data[$name] = $this->$name; + } + if ($shouldReset) + $this->_with = Array(); + } + + /* + * Function building hasOne joins for get/getOne method + */ + private function processHasOneWith () { + if (count ($this->_with) == 0) + return; + foreach ($this->_with as $name => $opts) { + $relationType = strtolower ($opts[0]); + $modelName = $opts[1]; + $key = null; + if (isset ($opts[2])) + $key = $opts[2]; + if ($relationType == 'hasone') { + $this->db->setQueryOption ("MYSQLI_NESTJOIN"); + $this->join ($modelName, $key); + } + } + } + + /** + * @param array $data + */ + private function processArrays (&$data) { + if (isset ($this->jsonFields) && is_array ($this->jsonFields)) { + foreach ($this->jsonFields as $key) + $data[$key] = json_decode ($data[$key]); + } + + if (isset ($this->arrayFields) && is_array($this->arrayFields)) { + foreach ($this->arrayFields as $key) + $data[$key] = explode ("|", $data[$key]); + } + } + + /** + * @param array $data + */ + private function validate ($data) { + if (!$this->dbFields) + return true; + + foreach ($this->dbFields as $key => $desc) { + if(in_array($key, $this->toSkip)) + continue; + + $type = null; + $required = false; + if (isset ($data[$key])) + $value = $data[$key]; + else + $value = null; + + if (is_array ($value)) + continue; + + if (isset ($desc[0])) + $type = $desc[0]; + if (isset ($desc[1]) && ($desc[1] == 'required')) + $required = true; + + if ($required && strlen ($value) == 0) { + $this->errors[] = Array ($this->dbTable . "." . $key => "is required"); + continue; + } + if ($value == null) + continue; + + switch ($type) { + case "text": + $regexp = null; + break; + case "int": + $regexp = "/^[0-9]*$/"; + break; + case "double": + $regexp = "/^[0-9\.]*$/"; + break; + case "bool": + $regexp = '/^(yes|no|0|1|true|false)$/i'; + break; + case "datetime": + $regexp = "/^[0-9a-zA-Z -:]*$/"; + break; + default: + $regexp = $type; + break; + } + if (!$regexp) + continue; + + if (!preg_match ($regexp, $value)) { + $this->errors[] = Array ($this->dbTable . "." . $key => "$type validation failed"); + continue; + } + } + return !count ($this->errors) > 0; + } + + private function prepareData () { + $this->errors = Array (); + $sqlData = Array(); + if (count ($this->data) == 0) + return Array(); + + if (method_exists ($this, "preLoad")) + $this->preLoad ($this->data); + + if (!$this->dbFields) + return $this->data; + + foreach ($this->data as $key => &$value) { + if(in_array($key, $this->toSkip)) + continue; + + if ($value instanceof dbObject && $value->isNew == true) { + $id = $value->save(); + if ($id) + $value = $id; + else + $this->errors = array_merge ($this->errors, $value->errors); + } + + if (!in_array ($key, array_keys ($this->dbFields))) + continue; + + if (!is_array($value) && !is_object($value)) { + $sqlData[$key] = $value; + continue; + } + + if (isset ($this->jsonFields) && in_array ($key, $this->jsonFields)) + $sqlData[$key] = json_encode($value); + else if (isset ($this->arrayFields) && in_array ($key, $this->arrayFields)) + $sqlData[$key] = implode ("|", $value); + else + $sqlData[$key] = $value; + } + return $sqlData; + } + + private static function dbObjectAutoload ($classname) { + $filename = static::$modelPath . $classname .".php"; + if (file_exists ($filename)) + include ($filename); + } + + /* + * Enable models autoload from a specified path + * + * Calling autoload() without path will set path to dbObjectPath/models/ directory + * + * @param string $path + */ + public static function autoload ($path = null) { + if ($path) + static::$modelPath = $path . "/"; + else + static::$modelPath = __DIR__ . "/models/"; + spl_autoload_register ("dbObject::dbObjectAutoload"); + } +} diff --git a/Flare/Flare_Libraries/jdf.php b/Flare/Flare_Libraries/jdf.php new file mode 100644 index 0000000..f581f3a --- /dev/null +++ b/Flare/Flare_Libraries/jdf.php @@ -0,0 +1,656 @@ +[ 1399/11/28 = 1442/07/04 = 2021/02/16 ] + */ + +/* F */ +function jdate($format, $timestamp = '', $none = '', $time_zone = 'Asia/Tehran', $tr_num = 'fa') { + + $T_sec = 0;/* <= رفع خطاي زمان سرور ، با اعداد '+' و '-' بر حسب ثانيه */ + + if ($time_zone != 'local') date_default_timezone_set(($time_zone === '') ? 'Asia/Tehran' : $time_zone); + $ts = $T_sec + (($timestamp === '') ? time() : $this->tr_num($timestamp)); + $date = explode('_', date('H_i_j_n_O_P_s_w_Y', $ts)); + list($j_y, $j_m, $j_d) = $this->gregorian_to_jalali($date[8], $date[3], $date[2]); + $doy = ($j_m < 7) ? (($j_m - 1) * 31) + $j_d - 1 : (($j_m - 7) * 30) + $j_d + 185; + $kab = (((($j_y + 12) % 33) % 4) == 1) ? 1 : 0; + $sl = strlen($format); + $out = ''; + for ($i = 0; $i < $sl; $i++) { + $sub = substr($format, $i, 1); + if ($sub == '\\') { + $out .= substr($format, ++$i, 1); + continue; + } + switch ($sub) { + + case 'E': + case 'R': + case 'x': + case 'X': + $out .= 'http://jdf.scr.ir'; + break; + + case 'B': + case 'e': + case 'g': + case 'G': + case 'h': + case 'I': + case 'T': + case 'u': + case 'Z': + $out .= date($sub, $ts); + break; + + case 'a': + $out .= ($date[0] < 12) ? 'ق.ظ' : 'ب.ظ'; + break; + + case 'A': + $out .= ($date[0] < 12) ? 'قبل از ظهر' : 'بعد از ظهر'; + break; + + case 'b': + $out .= (int) ($j_m / 3.1) + 1; + break; + + case 'c': + $out .= $j_y . '/' . $j_m . '/' . $j_d . ' ،' . $date[0] . ':' . $date[1] . ':' . $date[6] . ' ' . $date[5]; + break; + + case 'C': + $out .= (int) (($j_y + 99) / 100); + break; + + case 'd': + $out .= ($j_d < 10) ? '0' . $j_d : $j_d; + break; + + case 'D': + $out .= $this->jdate_words(array('kh' => $date[7]), ' '); + break; + + case 'f': + $out .= $this->jdate_words(array('ff' => $j_m), ' '); + break; + + case 'F': + $out .= $this->jdate_words(array('mm' => $j_m), ' '); + break; + + case 'H': + $out .= $date[0]; + break; + + case 'i': + $out .= $date[1]; + break; + + case 'j': + $out .= $j_d; + break; + + case 'J': + $out .= $this->jdate_words(array('rr' => $j_d), ' '); + break; + + case 'k'; + $out .= $this->tr_num(100 - (int) ($doy / ($kab + 365.24) * 1000) / 10, $tr_num); + break; + + case 'K': + $out .= $this->tr_num((int) ($doy / ($kab + 365.24) * 1000) / 10, $tr_num); + break; + + case 'l': + $out .= $this->jdate_words(array('rh' => $date[7]), ' '); + break; + + case 'L': + $out .= $kab; + break; + + case 'm': + $out .= ($j_m > 9) ? $j_m : '0' . $j_m; + break; + + case 'M': + $out .= $this->jdate_words(array('km' => $j_m), ' '); + break; + + case 'n': + $out .= $j_m; + break; + + case 'N': + $out .= $date[7] + 1; + break; + + case 'o': + $jdw = ($date[7] == 6) ? 0 : $date[7] + 1; + $dny = 364 + $kab - $doy; + $out .= ($jdw > ($doy + 3) and $doy < 3) ? $j_y - 1 : (((3 - $dny) > $jdw and $dny < 3) ? $j_y + 1 : $j_y); + break; + + case 'O': + $out .= $date[4]; + break; + + case 'p': + $out .= $this->jdate_words(array('mb' => $j_m), ' '); + break; + + case 'P': + $out .= $date[5]; + break; + + case 'q': + $out .= $this->jdate_words(array('sh' => $j_y), ' '); + break; + + case 'Q': + $out .= $kab + 364 - $doy; + break; + + case 'r': + $key = $this->jdate_words(array('rh' => $date[7], 'mm' => $j_m)); + $out .= $date[0] . ':' . $date[1] . ':' . $date[6] . ' ' . $date[4] . ' ' . $key['rh'] . '، ' . $j_d . ' ' . $key['mm'] . ' ' . $j_y; + break; + + case 's': + $out .= $date[6]; + break; + + case 'S': + $out .= 'ام'; + break; + + case 't': + $out .= ($j_m != 12) ? (31 - (int) ($j_m / 6.5)) : ($kab + 29); + break; + + case 'U': + $out .= $ts; + break; + + case 'v': + $out .= $this->jdate_words(array('ss' => ($j_y % 100)), ' '); + break; + + case 'V': + $out .= $this->jdate_words(array('ss' => $j_y), ' '); + break; + + case 'w': + $out .= ($date[7] == 6) ? 0 : $date[7] + 1; + break; + + case 'W': + $avs = (($date[7] == 6) ? 0 : $date[7] + 1) - ($doy % 7); + if ($avs < 0) $avs += 7; + $num = (int) (($doy + $avs) / 7); + if ($avs < 4) { + $num++; + } elseif ($num < 1) { + $num = ($avs == 4 or $avs == ((((($j_y % 33) % 4) - 2) == ((int) (($j_y % 33) * 0.05))) ? 5 : 4)) ? 53 : 52; + } + $aks = $avs + $kab; + if ($aks == 7) $aks = 0; + $out .= (($kab + 363 - $doy) < $aks and $aks < 3) ? '01' : (($num < 10) ? '0' . $num : $num); + break; + + case 'y': + $out .= substr($j_y, 2, 2); + break; + + case 'Y': + $out .= $j_y; + break; + + case 'z': + $out .= $doy; + break; + + default: + $out .= $sub; + } + } + return ($tr_num != 'en') ? $this->tr_num($out, 'fa', '.') : $out; +} + +/* F */ +function jstrftime($format, $timestamp = '', $none = '', $time_zone = 'Asia/Tehran', $tr_num = 'fa') { + + $T_sec = 0;/* <= رفع خطاي زمان سرور ، با اعداد '+' و '-' بر حسب ثانيه */ + + if ($time_zone != 'local') date_default_timezone_set(($time_zone === '') ? 'Asia/Tehran' : $time_zone); + $ts = $T_sec + (($timestamp === '') ? time() : $this->tr_num($timestamp)); + $date = explode('_', date('h_H_i_j_n_s_w_Y', $ts)); + list($j_y, $j_m, $j_d) = $this->gregorian_to_jalali($date[7], $date[4], $date[3]); + $doy = ($j_m < 7) ? (($j_m - 1) * 31) + $j_d - 1 : (($j_m - 7) * 30) + $j_d + 185; + $kab = (((($j_y + 12) % 33) % 4) == 1) ? 1 : 0; + $sl = strlen($format); + $out = ''; + for ($i = 0; $i < $sl; $i++) { + $sub = substr($format, $i, 1); + if ($sub == '%') { + $sub = substr($format, ++$i, 1); + } else { + $out .= $sub; + continue; + } + switch ($sub) { + + /* Day */ + case 'a': + $out .= $this->jdate_words(array('kh' => $date[6]), ' '); + break; + + case 'A': + $out .= $this->jdate_words(array('rh' => $date[6]), ' '); + break; + + case 'd': + $out .= ($j_d < 10) ? '0' . $j_d : $j_d; + break; + + case 'e': + $out .= ($j_d < 10) ? ' ' . $j_d : $j_d; + break; + + case 'j': + $out .= str_pad($doy + 1, 3, 0, STR_PAD_LEFT); + break; + + case 'u': + $out .= $date[6] + 1; + break; + + case 'w': + $out .= ($date[6] == 6) ? 0 : $date[6] + 1; + break; + + /* Week */ + case 'U': + $avs = (($date[6] < 5) ? $date[6] + 2 : $date[6] - 5) - ($doy % 7); + if ($avs < 0) $avs += 7; + $num = (int) (($doy + $avs) / 7) + 1; + if ($avs > 3 or $avs == 1) $num--; + $out .= ($num < 10) ? '0' . $num : $num; + break; + + case 'V': + $avs = (($date[6] == 6) ? 0 : $date[6] + 1) - ($doy % 7); + if ($avs < 0) $avs += 7; + $num = (int) (($doy + $avs) / 7); + if ($avs < 4) { + $num++; + } elseif ($num < 1) { + $num = ($avs == 4 or $avs == ((((($j_y % 33) % 4) - 2) == ((int) (($j_y % 33) * 0.05))) ? 5 : 4)) ? 53 : 52; + } + $aks = $avs + $kab; + if ($aks == 7) $aks = 0; + $out .= (($kab + 363 - $doy) < $aks and $aks < 3) ? '01' : (($num < 10) ? '0' . $num : $num); + break; + + case 'W': + $avs = (($date[6] == 6) ? 0 : $date[6] + 1) - ($doy % 7); + if ($avs < 0) $avs += 7; + $num = (int) (($doy + $avs) / 7) + 1; + if ($avs > 3) $num--; + $out .= ($num < 10) ? '0' . $num : $num; + break; + + /* Month */ + case 'b': + case 'h': + $out .= $this->jdate_words(array('km' => $j_m), ' '); + break; + + case 'B': + $out .= $this->jdate_words(array('mm' => $j_m), ' '); + break; + + case 'm': + $out .= ($j_m > 9) ? $j_m : '0' . $j_m; + break; + + /* Year */ + case 'C': + $tmp = (int) ($j_y / 100); + $out .= ($tmp > 9) ? $tmp : '0' . $tmp; + break; + + case 'g': + $jdw = ($date[6] == 6) ? 0 : $date[6] + 1; + $dny = 364 + $kab - $doy; + $out .= substr(($jdw > ($doy + 3) and $doy < 3) ? $j_y - 1 : (((3 - $dny) > $jdw and $dny < 3) ? $j_y + 1 : $j_y), 2, 2); + break; + + case 'G': + $jdw = ($date[6] == 6) ? 0 : $date[6] + 1; + $dny = 364 + $kab - $doy; + $out .= ($jdw > ($doy + 3) and $doy < 3) ? $j_y - 1 : (((3 - $dny) > $jdw and $dny < 3) ? $j_y + 1 : $j_y); + break; + + case 'y': + $out .= substr($j_y, 2, 2); + break; + + case 'Y': + $out .= $j_y; + break; + + /* Time */ + case 'H': + $out .= $date[1]; + break; + + case 'I': + $out .= $date[0]; + break; + + case 'l': + $out .= ($date[0] > 9) ? $date[0] : ' ' . (int) $date[0]; + break; + + case 'M': + $out .= $date[2]; + break; + + case 'p': + $out .= ($date[1] < 12) ? 'قبل از ظهر' : 'بعد از ظهر'; + break; + + case 'P': + $out .= ($date[1] < 12) ? 'ق.ظ' : 'ب.ظ'; + break; + + case 'r': + $out .= $date[0] . ':' . $date[2] . ':' . $date[5] . ' ' . (($date[1] < 12) ? 'قبل از ظهر' : 'بعد از ظهر'); + break; + + case 'R': + $out .= $date[1] . ':' . $date[2]; + break; + + case 'S': + $out .= $date[5]; + break; + + case 'T': + $out .= $date[1] . ':' . $date[2] . ':' . $date[5]; + break; + + case 'X': + $out .= $date[0] . ':' . $date[2] . ':' . $date[5]; + break; + + case 'z': + $out .= date('O', $ts); + break; + + case 'Z': + $out .= date('T', $ts); + break; + + /* Time and Date Stamps */ + case 'c': + $key = $this->jdate_words(array('rh' => $date[6], 'mm' => $j_m)); + $out .= $date[1] . ':' . $date[2] . ':' . $date[5] . ' ' . date('P', $ts) . ' ' . $key['rh'] . '، ' . $j_d . ' ' . $key['mm'] . ' ' . $j_y; + break; + + case 'D': + $out .= substr($j_y, 2, 2) . '/' . (($j_m > 9) ? $j_m : '0' . $j_m) . '/' . (($j_d < 10) ? '0' . $j_d : $j_d); + break; + + case 'F': + $out .= $j_y . '-' . (($j_m > 9) ? $j_m : '0' . $j_m) . '-' . (($j_d < 10) ? '0' . $j_d : $j_d); + break; + + case 's': + $out .= $ts; + break; + + case 'x': + $out .= substr($j_y, 2, 2) . '/' . (($j_m > 9) ? $j_m : '0' . $j_m) . '/' . (($j_d < 10) ? '0' . $j_d : $j_d); + break; + + /* Miscellaneous */ + case 'n': + $out .= "\n"; + break; + + case 't': + $out .= "\t"; + break; + + case '%': + $out .= '%'; + break; + + default: + $out .= $sub; + } + } + return ($tr_num != 'en') ? $this->tr_num($out, 'fa', '.') : $out; +} + +/* F */ +function jmktime($h = '', $m = '', $s = '', $jm = '', $jd = '', $jy = '', $none = '', $timezone = 'Asia/Tehran') { + if ($timezone != 'local') date_default_timezone_set($timezone); + if ($h === '') { + return time(); + } else { + list($h, $m, $s, $jm, $jd, $jy) = explode('_', $this->tr_num($h . '_' . $m . '_' . $s . '_' . $jm . '_' . $jd . '_' . $jy)); + if ($m === '') { + return mktime($h); + } else { + if ($s === '') { + return mktime($h, $m); + } else { + if ($jm === '') { + return mktime($h, $m, $s); + } else { + $jdate = explode('_', jdate('Y_j', '', '', $timezone, 'en')); + if ($jd === '') { + list($gy, $gm, $gd) = jalali_to_gregorian($jdate[0], $jm, $jdate[1]); + return mktime($h, $m, $s, $gm); + } else { + if ($jy === '') { + list($gy, $gm, $gd) = jalali_to_gregorian($jdate[0], $jm, $jd); + return mktime($h, $m, $s, $gm, $gd); + } else { + list($gy, $gm, $gd) = jalali_to_gregorian($jy, $jm, $jd); + return mktime($h, $m, $s, $gm, $gd, $gy); + } + } + } + } + } + } +} + +/* F */ +function jgetdate($timestamp = '', $none = '', $timezone = 'Asia/Tehran', $tn = 'en') { + $ts = ($timestamp === '') ? time() : $this->tr_num($timestamp); + $jdate = explode('_', jdate('F_G_i_j_l_n_s_w_Y_z', $ts, '', $timezone, $tn)); + return array( + 'seconds' => $this->tr_num((int) $this->tr_num($jdate[6]), $tn), + 'minutes' => $this->tr_num((int) $this->tr_num($jdate[2]), $tn), + 'hours' => $jdate[1], + 'mday' => $jdate[3], + 'wday' => $jdate[7], + 'mon' => $jdate[5], + 'year' => $jdate[8], + 'yday' => $jdate[9], + 'weekday' => $jdate[4], + 'month' => $jdate[0], + 0 => $this->tr_num($ts, $tn) + ); +} + +/* F */ +function jcheckdate($jm, $jd, $jy) { + list($jm, $jd, $jy) = explode('_', $this->tr_num($jm . '_' . $jd . '_' . $jy)); + $l_d = ($jm == 12 and ((($jy + 12) % 33) % 4) != 1) ? 29 : (31 - (int) ($jm / 6.5)); + return ($jm > 12 or $jd > $l_d or $jm < 1 or $jd < 1 or $jy < 1) ? false : true; +} + +/* F */ +public function tr_num($str, $mod = 'en', $mf = '٫') { + $num_a = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.'); + $key_a = array('۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹', $mf); + return ($mod == 'fa') ? str_replace($num_a, $key_a, $str) : str_replace($key_a, $num_a, $str); +} + +/* F */ +function jdate_words($array, $mod = '') { + foreach ($array as $type => $num) { + $num = (int) $this->tr_num($num); + switch ($type) { + + case 'ss': + $sl = strlen($num); + $xy3 = substr($num, 2 - $sl, 1); + $h3 = $h34 = $h4 = ''; + if ($xy3 == 1) { + $p34 = ''; + $k34 = array('ده', 'یازده', 'دوازده', 'سیزده', 'چهارده', 'پانزده', 'شانزده', 'هفده', 'هجده', 'نوزده'); + $h34 = $k34[substr($num, 2 - $sl, 2) - 10]; + } else { + $xy4 = substr($num, 3 - $sl, 1); + $p34 = ($xy3 == 0 or $xy4 == 0) ? '' : ' و '; + $k3 = array('', '', 'بیست', 'سی', 'چهل', 'پنجاه', 'شصت', 'هفتاد', 'هشتاد', 'نود'); + $h3 = $k3[$xy3]; + $k4 = array('', 'یک', 'دو', 'سه', 'چهار', 'پنج', 'شش', 'هفت', 'هشت', 'نه'); + $h4 = $k4[$xy4]; + } + $array[$type] = (($num > 99) ? str_replace( + array('12', '13', '14', '19', '20'), + array('هزار و دویست', 'هزار و سیصد', 'هزار و چهارصد', 'هزار و نهصد', 'دوهزار'), + substr($num, 0, 2) + ) . ((substr($num, 2, 2) == '00') ? '' : ' و ') : '') . $h3 . $p34 . $h34 . $h4; + break; + + case 'mm': + $key = array('فروردین', 'اردیبهشت', 'خرداد', 'تیر', 'مرداد', 'شهریور', 'مهر', 'آبان', 'آذر', 'دی', 'بهمن', 'اسفند'); + $array[$type] = $key[$num - 1]; + break; + + case 'rr': + $key = array( + 'یک', 'دو', 'سه', 'چهار', 'پنج', 'شش', 'هفت', 'هشت', 'نه', 'ده', 'یازده', 'دوازده', 'سیزده', 'چهارده', 'پانزده', 'شانزده', 'هفده', 'هجده', 'نوزده', 'بیست', 'بیست و یک', 'بیست و دو', 'بیست و سه', 'بیست و چهار', 'بیست و پنج', 'بیست و شش', 'بیست و هفت', 'بیست و هشت', 'بیست و نه', 'سی', 'سی و یک' + ); + $array[$type] = $key[$num - 1]; + break; + + case 'rh': + $key = array('یکشنبه', 'دوشنبه', 'سه شنبه', 'چهارشنبه', 'پنجشنبه', 'جمعه', 'شنبه'); + $array[$type] = $key[$num]; + break; + + case 'sh': + $key = array('مار', 'اسب', 'گوسفند', 'میمون', 'مرغ', 'سگ', 'خوک', 'موش', 'گاو', 'پلنگ', 'خرگوش', 'نهنگ'); + $array[$type] = $key[$num % 12]; + break; + + case 'mb': + $key = array('حمل', 'ثور', 'جوزا', 'سرطان', 'اسد', 'سنبله', 'میزان', 'عقرب', 'قوس', 'جدی', 'دلو', 'حوت'); + $array[$type] = $key[$num - 1]; + break; + + case 'ff': + $key = array('بهار', 'تابستان', 'پاییز', 'زمستان'); + $array[$type] = $key[(int) ($num / 3.1)]; + break; + + case 'km': + $key = array('فر', 'ار', 'خر', 'تی‍', 'مر', 'شه‍', 'مه‍', 'آب‍', 'آذ', 'دی', 'به‍', 'اس‍'); + $array[$type] = $key[$num - 1]; + break; + + case 'kh': + $key = array('ی', 'د', 'س', 'چ', 'پ', 'ج', 'ش'); + $array[$type] = $key[$num]; + break; + + default: + $array[$type] = $num; + } + } + return ($mod === '') ? $array : implode($mod, $array); +} + + +/** Gregorian & Jalali (Hijri_Shamsi,Solar) Date Converter Functions +Author: JDF.SCR.IR =>> Download Full Version : http://jdf.scr.ir/jdf +License: GNU/LGPL _ Open Source & Free :: Version: 2.80 : [2020=1399] +--------------------------------------------------------------------- +355746=361590-5844 & 361590=(30*33*365)+(30*8) & 5844=(16*365)+(16/4) +355666=355746-79-1 & 355668=355746-79+1 & 1595=605+990 & 605=621-16 +990=30*33 & 12053=(365*33)+(32/4) & 36524=(365*100)+(100/4)-(100/100) +1461=(365*4)+(4/4) & 146097=(365*400)+(400/4)-(400/100)+(400/400) */ + +/* F */ +function gregorian_to_jalali($gy, $gm, $gd, $mod = '') { + list($gy, $gm, $gd) = explode('_', $this->tr_num($gy . '_' . $gm . '_' . $gd));/* <= Extra :اين سطر ، جزء تابع اصلي نيست */ + $g_d_m = array(0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334); + $gy2 = ($gm > 2) ? ($gy + 1) : $gy; + $days = 355666 + (365 * $gy) + ((int) (($gy2 + 3) / 4)) - ((int) (($gy2 + 99) / 100)) + ((int) (($gy2 + 399) / 400)) + $gd + $g_d_m[$gm - 1]; + $jy = -1595 + (33 * ((int) ($days / 12053))); + $days %= 12053; + $jy += 4 * ((int) ($days / 1461)); + $days %= 1461; + if ($days > 365) { + $jy += (int) (($days - 1) / 365); + $days = ($days - 1) % 365; + } + if ($days < 186) { + $jm = 1 + (int) ($days / 31); + $jd = 1 + ($days % 31); + } else { + $jm = 7 + (int) (($days - 186) / 30); + $jd = 1 + (($days - 186) % 30); + } + return ($mod == '') ? array($jy, $jm, $jd) : $jy . $mod . $jm . $mod . $jd; +} + +/* F */ +function jalali_to_gregorian($jy, $jm, $jd, $mod = '') { + list($jy, $jm, $jd) = explode('_', $this->tr_num($jy . '_' . $jm . '_' . $jd));/* <= Extra :اين سطر ، جزء تابع اصلي نيست */ + $jy += 1595; + $days = -355668 + (365 * $jy) + (((int) ($jy / 33)) * 8) + ((int) ((($jy % 33) + 3) / 4)) + $jd + (($jm < 7) ? ($jm - 1) * 31 : (($jm - 7) * 30) + 186); + $gy = 400 * ((int) ($days / 146097)); + $days %= 146097; + if ($days > 36524) { + $gy += 100 * ((int) (--$days / 36524)); + $days %= 36524; + if ($days >= 365) $days++; + } + $gy += 4 * ((int) ($days / 1461)); + $days %= 1461; + if ($days > 365) { + $gy += (int) (($days - 1) / 365); + $days = ($days - 1) % 365; + } + $gd = $days + 1; + $sal_a = array(0, 31, (($gy % 4 == 0 and $gy % 100 != 0) or ($gy % 400 == 0)) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); + for ($gm = 0; $gm < 13 and $gd > $sal_a[$gm]; $gm++) $gd -= $sal_a[$gm]; + return ($mod == '') ? array($gy, $gm, $gd) : $gy . $mod . $gm . $mod . $gd; +} +public function jtg($tarikh ,$separator='/' ){ + + $tarikh = explode($separator,$tarikh) ; + $jdate= $this->gregorian_to_jalali(trim($tarikh['0']),trim($tarikh['1']),trim($tarikh['2']),'/') ; + return $jdate; +} +} \ No newline at end of file diff --git a/Flare/Global_Functions/Flare.php b/Flare/Global_Functions/Flare.php new file mode 100644 index 0000000..525b7a1 --- /dev/null +++ b/Flare/Global_Functions/Flare.php @@ -0,0 +1,83 @@ + + .php-debug { + position: fixed; + overflow: auto; + z-index: 99999; + left: 0; + bottom: 0; + width: 100%; + max-height: 80%; + padding: 1em 2em; + background: #292929; + color: #fff; + opacity: 0.92; + } + .php-debug::before { + content: "[DEBUG]"; + position: fixed; + bottom: 0; + right: 0; + color: #00f2ff; + padding: 1em 2em; + } + '; + if (isset($ret)){ + echo '' . '
'.$ret . '
'; + echo ' +'; + + } + +} + diff --git a/Flare/Libraries/Captcha.php b/Flare/Libraries/Captcha.php new file mode 100644 index 0000000..1411e24 --- /dev/null +++ b/Flare/Libraries/Captcha.php @@ -0,0 +1,95 @@ +"; + } + } + + // (C) VERIFY CAPTCHA + function verify ($check) { + // (C1) CAPTCHA NOT SET! +// if (!isset($_SESSION['captcha'])) { throw new Exception("CAPTCHA NOT PRIMED"); } + if (!isset($_SESSION['captcha'])) { + $khata="CAPTCHA NOT PRIMED"; + } + + // (C2) CHECK + if(isset($_SESSION['captcha'])){ + $_SESSION['captcha']= strtolower( $_SESSION['captcha'] ) ; + $check= strtolower( $check ) ; + if ($check == $_SESSION['captcha']) { + unset($_SESSION['captcha']); + return true; + } else { + return false; + } + } + + } +} + +// (D) CREATE CAPTCHA OBJECT + // Remove if session already started \ No newline at end of file diff --git a/Flare/Libraries/Email.php b/Flare/Libraries/Email.php new file mode 100644 index 0000000..25abfd1 --- /dev/null +++ b/Flare/Libraries/Email.php @@ -0,0 +1,49 @@ +SMTPDebug = SMTP::DEBUG_SERVER; //Enable verbose debug output + $mail->isSMTP(); //Send using SMTP + $mail->Host = 'smtp.example.com'; //Set the SMTP server to send through + $mail->SMTPAuth = true; //Enable SMTP authentication + $mail->Username = 'user@example.com'; //SMTP username + $mail->Password = 'secret'; //SMTP password + $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; //Enable implicit TLS encryption + $mail->Port = 465; //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS` + + //Recipients + $mail->setFrom('from@example.com', 'Mailer'); + $mail->addAddress('irani3057@outlook.com', 'sajjad'); //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 = 'Flare'; + $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}"; + } + + } +} \ No newline at end of file diff --git a/Flare/View/404/404.php b/Flare/View/404/404.php new file mode 100644 index 0000000..def4613 --- /dev/null +++ b/Flare/View/404/404.php @@ -0,0 +1,112 @@ + + + + + 404 + + + + + +
+
+
+
+ + Error 404 +
+ + Page Not Found + + +
+ + \ No newline at end of file diff --git a/Flare/View/Plates/w-template.php b/Flare/View/Plates/w-template.php new file mode 100644 index 0000000..f3d3ad6 --- /dev/null +++ b/Flare/View/Plates/w-template.php @@ -0,0 +1,102 @@ + + + + + <?=$this->e($title)?> + + + + + + +section('content')?> + + + \ No newline at end of file diff --git a/Flare/View/Plates/welcome.php b/Flare/View/Plates/welcome.php new file mode 100644 index 0000000..b4e4ba2 --- /dev/null +++ b/Flare/View/Plates/welcome.php @@ -0,0 +1,25 @@ +layout('w-template', ['title' => 'Welcome']) ?> + +
+
+
+
+ + Welcome to +
+ + e($welcome)?>
+ Flare - logo +

+ + '.$jdf->jstrftime('%c '); ; + ?> +© Sajjad eftekhari + + +
diff --git a/Flare/View/Welcome/Welcome.php b/Flare/View/Welcome/Welcome.php new file mode 100644 index 0000000..6b96c7e --- /dev/null +++ b/Flare/View/Welcome/Welcome.php @@ -0,0 +1,127 @@ + + + + + + Welcome + + + + + + +
+
+
+
+ + Welcome to +
+ + Flare Framework
+ honorary- logo +

+ + '.$jdf->jstrftime('%c '); ; + + ?> +© Sajjad eftekhari + + +
+ + \ No newline at end of file diff --git a/Flare/View/footer.php b/Flare/View/footer.php new file mode 100644 index 0000000..51d6d03 --- /dev/null +++ b/Flare/View/footer.php @@ -0,0 +1,4 @@ + + Copy right all received by Sajjad eftekhari + + diff --git a/Flare/View/header.php b/Flare/View/header.php new file mode 100644 index 0000000..bacc995 --- /dev/null +++ b/Flare/View/header.php @@ -0,0 +1,10 @@ + + + + + + + Eftekari framework + + \ No newline at end of file diff --git a/Flare/View/home.php b/Flare/View/home.php new file mode 100644 index 0000000..01663a6 --- /dev/null +++ b/Flare/View/home.php @@ -0,0 +1,14 @@ + + +
+
+
+
+ + PURE CSS + +
+ + PARALLAX PIXEL STARS + +
diff --git a/Flare/app/Router.php b/Flare/app/Router.php new file mode 100644 index 0000000..993f372 --- /dev/null +++ b/Flare/app/Router.php @@ -0,0 +1,31 @@ + [ + 'controllers' => CONFIG.'../Controllers', + ], + 'namespaces' => [ + 'controllers' => 'Controllers', + ], +]); + +// https://github.com/izniburak/php-router/wiki/5.-Controllers + +$router->get('/hi', function(Request $request, Response $response) { + $response->setContent('Hello World'); + return $response; +}); + +$router->get('/', 'EFTEKHARI@index'); + +$router->get('/create', 'EFTEKHARI@create'); +$router->post('/store', 'EFTEKHARI@store'); +$router->get('/edit/:id', 'EFTEKHARI@edit'); +$router->put('/update/:id', 'EFTEKHARI@update'); +$router->delete('/delete/:id', 'EFTEKHARI@delete'); +$router->error(function() { + View('404/404') ; +}); +$router->run(); diff --git a/Flare/app/config.php b/Flare/app/config.php new file mode 100644 index 0000000..ab29fc3 --- /dev/null +++ b/Flare/app/config.php @@ -0,0 +1,40 @@ +safeLoad(); +use Tracy\Debugger; +use Odan\Session\PhpSession; +$session = new PhpSession(); + +if (isset($_ENV['Dev_set'])) { + if ($_ENV['Dev_set']=='development'){ + Debugger::DEVELOPMENT ; + Debugger::$dumpTheme = 'dark'; + Debugger::$editor ; + Debugger::enable(); + }elseif ($_ENV['Dev_set']=='production'){ + + }else{ + echo 'Dev_set'.' Not set !' ; + } +} +require_once (CONFIG.'../Global_Functions/Flare.php') ; + +spl_autoload_register('autoLoader'); +spl_autoload_register('lautoLoader'); +dbObject::autoload(CONFIG."../Models"); + +if (isset($_ENV['DB_HOST'])){ + if (isset( $_ENV['DB_PREFIX'])){$_FE_prefix =$_ENV['DB_PREFIX'];}else{$_FE_prefix="";} + $db= new MysqliDb(Array ( + 'host' => $_ENV['DB_HOST'], + 'username' => $_ENV['DB_USER'], + 'password' => $_ENV['DB_PASS'], + 'db'=> $_ENV['DB_NAME'], + 'port' => 3306, + 'prefix' => $_FE_prefix , + 'charset' => 'utf8')); +} + +require_once 'Router.php' ; \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..50ca739 --- /dev/null +++ b/README.md @@ -0,0 +1,43 @@ +# Flare Framework +Made by Sajjad Eftekhari![](https://manbaenab.ir/uploads/Flare.png) +## What is Flare? + +Flare is a PHP full-stack web framework that is light, fast, flexible, and secure. +More information can be found at the [official site](https://manbaenab.ir/Flare). + +This repository holds the distributable version of the framework. + +## Important Change with index.php + +`index.php` is no longer in the root of the project! It has been moved inside the *public* folder, +for better security and separation of components. + +This means that you should configure your web server to "point" to your project's *public* folder, and +not to the project root. A better practice would be to configure a virtual host to point there. A poor practice would be to point your web server to the project root and expect to enter *public/...*, as the rest of your logic and the +framework are exposed. + + +## Server Requirements + +PHP version 8 or higher is required, with the following extensions installed: + + +### --------------------------------------------- Flare Framework --------------------------------- +## How to install +### you can use composer or download from https://github.com/sajjadef98/Flare/releases +### composer create-project flare-framework/flare mysite +# Flare built with a number of powerful and fast packages with other important features +### for env https://github.com/vlucas/phpdotenv + ### for Router and Controllers and Middlewares.i use https://github.com/izniburak/php-router +https://github.com/izniburak/php-router/wiki +### for $db and Model +### https://github.com/ThingEngineer/PHP-MySQLi-Database-Class +### https://github.com/ThingEngineer/PHP-MySQLi-Database-Class/blob/master/dbObject.md +### for View http://platesphp.com/ +### and +### for session https://odan.github.io/session/v5/ +### for email https://github.com/PHPMailer/PHPMailer +### for validation https://respect-validation.readthedocs.io/en/latest/ +### for upload https://github.com/verot/class.upload.php +### for debug https://tracy.nette.org/en/guide + diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..3294604 --- /dev/null +++ b/composer.json @@ -0,0 +1,34 @@ +{ + "name": "flare-framework/flare", + "type": "flare-framework", + "description": "flare-Framework", + "keywords": ["flare-Framework"], + "homepage": "https://github.com/sajjadef98/Flare", + "minimum-stability": "dev", + "license": "MIT", + "authors": [ + { + "name": "Sajjad eftekhari", + "homepage": "https://manbaenab.ir/profile/sajjad", + "role": "Developer" + } + ], + "require": { + "php": ">=8.0", + "vlucas/phpdotenv": "^5.3", + "tracy/tracy": "^2.8", + "izniburak/router": "^2.3", + "respect/validation": "^2.2", + "odan/session": "^5.1", + "league/plates": "^3.4", + "phpmailer/phpmailer": "^6.5", + "verot/class.upload.php": "^2.1" + }, + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/sajjadef98/Flare" + } + ] + +} \ No newline at end of file diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..945b662 --- /dev/null +++ b/composer.lock @@ -0,0 +1,1270 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "ed103f264be0dbe825daceab4b3b97df", + "packages": [ + { + "name": "graham-campbell/result-type", + "version": "v1.0.2", + "source": { + "type": "git", + "url": "https://github.com/GrahamCampbell/Result-Type.git", + "reference": "84afea85c6841deeea872f36249a206e878a5de0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/GrahamCampbell/Result-Type/zipball/84afea85c6841deeea872f36249a206e878a5de0", + "reference": "84afea85c6841deeea872f36249a206e878a5de0", + "shasum": "" + }, + "require": { + "php": "^7.0 || ^8.0", + "phpoption/phpoption": "^1.8" + }, + "require-dev": { + "phpunit/phpunit": "^6.5.14 || ^7.5.20 || ^8.5.19 || ^9.5.8" + }, + "type": "library", + "autoload": { + "psr-4": { + "GrahamCampbell\\ResultType\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk" + } + ], + "description": "An Implementation Of The Result Type", + "keywords": [ + "Graham Campbell", + "GrahamCampbell", + "Result Type", + "Result-Type", + "result" + ], + "support": { + "issues": "https://github.com/GrahamCampbell/Result-Type/issues", + "source": "https://github.com/GrahamCampbell/Result-Type/tree/v1.0.2" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/graham-campbell/result-type", + "type": "tidelift" + } + ], + "time": "2021-08-28T21:34:50+00:00" + }, + { + "name": "izniburak/router", + "version": "v2.3.1", + "source": { + "type": "git", + "url": "https://github.com/izniburak/php-router.git", + "reference": "9d9ce5a2708b1cddae965cf78c5b279355d23646" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/izniburak/php-router/zipball/9d9ce5a2708b1cddae965cf78c5b279355d23646", + "reference": "9d9ce5a2708b1cddae965cf78c5b279355d23646", + "shasum": "" + }, + "require": { + "ext-json": "*", + "php": ">=7.2.5", + "symfony/http-foundation": "^5.1" + }, + "require-dev": { + "guzzlehttp/guzzle": "^7.2", + "phpunit/phpunit": "^8.5 || ^9.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "Buki\\Router\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "İzni Burak Demirtaş", + "email": "info@burakdemirtas.org", + "homepage": "https://burakdemirtas.org" + } + ], + "description": "simple router class for php", + "homepage": "https://github.com/izniburak/php-router", + "keywords": [ + "route", + "router", + "routing" + ], + "support": { + "issues": "https://github.com/izniburak/php-router/issues", + "source": "https://github.com/izniburak/php-router/tree/v2.3.1" + }, + "time": "2021-05-09T22:51:49+00:00" + }, + { + "name": "league/plates", + "version": "v3.4.0", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/plates.git", + "reference": "6d3ee31199b536a4e003b34a356ca20f6f75496a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/plates/zipball/6d3ee31199b536a4e003b34a356ca20f6f75496a", + "reference": "6d3ee31199b536a4e003b34a356ca20f6f75496a", + "shasum": "" + }, + "require": { + "php": "^7.0|^8.0" + }, + "require-dev": { + "mikey179/vfsstream": "^1.6", + "phpunit/phpunit": "^9.5", + "squizlabs/php_codesniffer": "^3.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "psr-4": { + "League\\Plates\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jonathan Reinink", + "email": "jonathan@reinink.ca", + "role": "Developer" + }, + { + "name": "RJ Garcia", + "email": "ragboyjr@icloud.com", + "role": "Developer" + } + ], + "description": "Plates, the native PHP template system that's fast, easy to use and easy to extend.", + "homepage": "https://platesphp.com", + "keywords": [ + "league", + "package", + "templates", + "templating", + "views" + ], + "support": { + "issues": "https://github.com/thephpleague/plates/issues", + "source": "https://github.com/thephpleague/plates/tree/v3.4.0" + }, + "time": "2020-12-25T05:00:37+00:00" + }, + { + "name": "odan/session", + "version": "5.1.0", + "source": { + "type": "git", + "url": "https://github.com/odan/session.git", + "reference": "df95aeee04dec466172d4c4e0e3ac9245e8182b0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/odan/session/zipball/df95aeee04dec466172d4c4e0e3ac9245e8182b0", + "reference": "df95aeee04dec466172d4c4e0e3ac9245e8182b0", + "shasum": "" + }, + "require": { + "php": "^7.3 || ^8.0", + "psr/http-message": "^1.0", + "psr/http-server-handler": "^1.0", + "psr/http-server-middleware": "^1.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.16", + "middlewares/utils": "^3.1", + "overtrue/phplint": "^1.1 || ^2.0", + "phpstan/phpstan": "0.*", + "phpunit/phpunit": "^7 || ^8 || ^9", + "slim/psr7": "^1.1", + "squizlabs/php_codesniffer": "^3.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "Odan\\Session\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A Slim session handler", + "homepage": "https://github.com/odan/session", + "keywords": [ + "session", + "slim" + ], + "support": { + "issues": "https://github.com/odan/session/issues", + "source": "https://github.com/odan/session/tree/5.1.0" + }, + "time": "2020-12-23T18:09:07+00:00" + }, + { + "name": "phpmailer/phpmailer", + "version": "v6.5.1", + "source": { + "type": "git", + "url": "https://github.com/PHPMailer/PHPMailer.git", + "reference": "dd803df5ad7492e1b40637f7ebd258fee5ca7355" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/dd803df5ad7492e1b40637f7ebd258fee5ca7355", + "reference": "dd803df5ad7492e1b40637f7ebd258fee5ca7355", + "shasum": "" + }, + "require": { + "ext-ctype": "*", + "ext-filter": "*", + "ext-hash": "*", + "php": ">=5.5.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0", + "doctrine/annotations": "^1.2", + "php-parallel-lint/php-console-highlighter": "^0.5.0", + "php-parallel-lint/php-parallel-lint": "^1.3", + "phpcompatibility/php-compatibility": "^9.3.5", + "roave/security-advisories": "dev-latest", + "squizlabs/php_codesniffer": "^3.6.0", + "yoast/phpunit-polyfills": "^1.0.0" + }, + "suggest": { + "ext-mbstring": "Needed to send email in multibyte encoding charset or decode encoded addresses", + "hayageek/oauth2-yahoo": "Needed for Yahoo XOAUTH2 authentication", + "league/oauth2-google": "Needed for Google XOAUTH2 authentication", + "psr/log": "For optional PSR-3 debug logging", + "stevenmaguire/oauth2-microsoft": "Needed for Microsoft XOAUTH2 authentication", + "symfony/polyfill-mbstring": "To support UTF-8 if the Mbstring PHP extension is not enabled (^1.2)" + }, + "type": "library", + "autoload": { + "psr-4": { + "PHPMailer\\PHPMailer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-2.1-only" + ], + "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" + } + ], + "description": "PHPMailer is a full-featured email creation and transfer class for PHP", + "support": { + "issues": "https://github.com/PHPMailer/PHPMailer/issues", + "source": "https://github.com/PHPMailer/PHPMailer/tree/v6.5.1" + }, + "funding": [ + { + "url": "https://github.com/Synchro", + "type": "github" + } + ], + "time": "2021-08-18T09:14:16+00:00" + }, + { + "name": "phpoption/phpoption", + "version": "1.8.0", + "source": { + "type": "git", + "url": "https://github.com/schmittjoh/php-option.git", + "reference": "5455cb38aed4523f99977c4a12ef19da4bfe2a28" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/5455cb38aed4523f99977c4a12ef19da4bfe2a28", + "reference": "5455cb38aed4523f99977c4a12ef19da4bfe2a28", + "shasum": "" + }, + "require": { + "php": "^7.0 || ^8.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.4.1", + "phpunit/phpunit": "^6.5.14 || ^7.0.20 || ^8.5.19 || ^9.5.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.8-dev" + } + }, + "autoload": { + "psr-4": { + "PhpOption\\": "src/PhpOption/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Johannes M. Schmitt", + "email": "schmittjoh@gmail.com" + }, + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk" + } + ], + "description": "Option Type for PHP", + "keywords": [ + "language", + "option", + "php", + "type" + ], + "support": { + "issues": "https://github.com/schmittjoh/php-option/issues", + "source": "https://github.com/schmittjoh/php-option/tree/1.8.0" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpoption/phpoption", + "type": "tidelift" + } + ], + "time": "2021-08-28T21:27:29+00:00" + }, + { + "name": "psr/http-message", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-message/tree/master" + }, + "time": "2016-08-06T14:39:51+00:00" + }, + { + "name": "psr/http-server-handler", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-server-handler.git", + "reference": "aff2f80e33b7f026ec96bb42f63242dc50ffcae7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-server-handler/zipball/aff2f80e33b7f026ec96bb42f63242dc50ffcae7", + "reference": "aff2f80e33b7f026ec96bb42f63242dc50ffcae7", + "shasum": "" + }, + "require": { + "php": ">=7.0", + "psr/http-message": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Server\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP server-side request handler", + "keywords": [ + "handler", + "http", + "http-interop", + "psr", + "psr-15", + "psr-7", + "request", + "response", + "server" + ], + "support": { + "issues": "https://github.com/php-fig/http-server-handler/issues", + "source": "https://github.com/php-fig/http-server-handler/tree/master" + }, + "time": "2018-10-30T16:46:14+00:00" + }, + { + "name": "psr/http-server-middleware", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-server-middleware.git", + "reference": "2296f45510945530b9dceb8bcedb5cb84d40c5f5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-server-middleware/zipball/2296f45510945530b9dceb8bcedb5cb84d40c5f5", + "reference": "2296f45510945530b9dceb8bcedb5cb84d40c5f5", + "shasum": "" + }, + "require": { + "php": ">=7.0", + "psr/http-message": "^1.0", + "psr/http-server-handler": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Server\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP server-side middleware", + "keywords": [ + "http", + "http-interop", + "middleware", + "psr", + "psr-15", + "psr-7", + "request", + "response" + ], + "support": { + "issues": "https://github.com/php-fig/http-server-middleware/issues", + "source": "https://github.com/php-fig/http-server-middleware/tree/master" + }, + "time": "2018-10-30T17:12:04+00:00" + }, + { + "name": "respect/stringifier", + "version": "0.2.0", + "source": { + "type": "git", + "url": "https://github.com/Respect/Stringifier.git", + "reference": "e55af3c8aeaeaa2abb5fa47a58a8e9688cc23b59" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Respect/Stringifier/zipball/e55af3c8aeaeaa2abb5fa47a58a8e9688cc23b59", + "reference": "e55af3c8aeaeaa2abb5fa47a58a8e9688cc23b59", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.8", + "malukenho/docheader": "^0.1.7", + "phpunit/phpunit": "^6.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "Respect\\Stringifier\\": "src/" + }, + "files": [ + "src/stringify.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Respect/Stringifier Contributors", + "homepage": "https://github.com/Respect/Stringifier/graphs/contributors" + } + ], + "description": "Converts any value to a string", + "homepage": "http://respect.github.io/Stringifier/", + "keywords": [ + "respect", + "stringifier", + "stringify" + ], + "support": { + "issues": "https://github.com/Respect/Stringifier/issues", + "source": "https://github.com/Respect/Stringifier/tree/0.2.0" + }, + "time": "2017-12-29T19:39:25+00:00" + }, + { + "name": "respect/validation", + "version": "2.2.3", + "source": { + "type": "git", + "url": "https://github.com/Respect/Validation.git", + "reference": "4c21a7ffc9a4915673cb2c2843963919e664e627" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Respect/Validation/zipball/4c21a7ffc9a4915673cb2c2843963919e664e627", + "reference": "4c21a7ffc9a4915673cb2c2843963919e664e627", + "shasum": "" + }, + "require": { + "php": "^7.3 || ^8.0", + "respect/stringifier": "^0.2.0", + "symfony/polyfill-mbstring": "^1.2" + }, + "require-dev": { + "egulias/email-validator": "^3.0", + "malukenho/docheader": "^0.1", + "mikey179/vfsstream": "^1.6", + "phpstan/phpstan": "^0.12", + "phpstan/phpstan-deprecation-rules": "^0.12", + "phpstan/phpstan-phpunit": "^0.12", + "phpunit/phpunit": "^9.3", + "psr/http-message": "^1.0", + "respect/coding-standard": "^3.0", + "squizlabs/php_codesniffer": "^3.5", + "symfony/validator": "^3.0||^4.0", + "zendframework/zend-validator": "^2.1" + }, + "suggest": { + "egulias/email-validator": "Strict (RFC compliant) email validation", + "ext-bcmath": "Arbitrary Precision Mathematics", + "ext-fileinfo": "File Information", + "ext-mbstring": "Multibyte String Functions", + "symfony/validator": "Use Symfony validator through Respect\\Validation", + "zendframework/zend-validator": "Use Zend Framework validator through Respect\\Validation" + }, + "type": "library", + "autoload": { + "psr-4": { + "Respect\\Validation\\": "library/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Respect/Validation Contributors", + "homepage": "https://github.com/Respect/Validation/graphs/contributors" + } + ], + "description": "The most awesome validation engine ever created for PHP", + "homepage": "http://respect.github.io/Validation/", + "keywords": [ + "respect", + "validation", + "validator" + ], + "support": { + "issues": "https://github.com/Respect/Validation/issues", + "source": "https://github.com/Respect/Validation/tree/2.2.3" + }, + "time": "2021-03-19T14:12:45+00:00" + }, + { + "name": "symfony/deprecation-contracts", + "version": "v2.4.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "5f38c8804a9e97d23e0c8d63341088cd8a22d627" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/5f38c8804a9e97d23e0c8d63341088cd8a22d627", + "reference": "5f38c8804a9e97d23e0c8d63341088cd8a22d627", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.4-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "files": [ + "function.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v2.4.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-03-23T23:28:01+00:00" + }, + { + "name": "symfony/http-foundation", + "version": "v5.3.7", + "source": { + "type": "git", + "url": "https://github.com/symfony/http-foundation.git", + "reference": "e36c8e5502b4f3f0190c675f1c1f1248a64f04e5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/e36c8e5502b4f3f0190c675f1c1f1248a64f04e5", + "reference": "e36c8e5502b4f3f0190c675f1c1f1248a64f04e5", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1", + "symfony/polyfill-mbstring": "~1.1", + "symfony/polyfill-php80": "^1.16" + }, + "require-dev": { + "predis/predis": "~1.0", + "symfony/cache": "^4.4|^5.0", + "symfony/expression-language": "^4.4|^5.0", + "symfony/mime": "^4.4|^5.0" + }, + "suggest": { + "symfony/mime": "To use the file extension guesser" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\HttpFoundation\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Defines an object-oriented layer for the HTTP specification", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/http-foundation/tree/v5.3.7" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-08-27T11:20:35+00:00" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.23.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/46cd95797e9df938fdd2b03693b5fca5e64b01ce", + "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "support": { + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.23.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-02-19T12:13:01+00:00" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.23.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "9174a3d80210dca8daa7f31fec659150bbeabfc6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9174a3d80210dca8daa7f31fec659150bbeabfc6", + "reference": "9174a3d80210dca8daa7f31fec659150bbeabfc6", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.23.1" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-05-27T12:26:48+00:00" + }, + { + "name": "symfony/polyfill-php80", + "version": "v1.23.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/1100343ed1a92e3a38f9ae122fc0eb21602547be", + "reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php80/tree/v1.23.1" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-07-28T13:41:28+00:00" + }, + { + "name": "tracy/tracy", + "version": "v2.8.7", + "source": { + "type": "git", + "url": "https://github.com/nette/tracy.git", + "reference": "8e708de7c611f626c8792d43f1c78812ea24e6f6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/tracy/zipball/8e708de7c611f626c8792d43f1c78812ea24e6f6", + "reference": "8e708de7c611f626c8792d43f1c78812ea24e6f6", + "shasum": "" + }, + "require": { + "ext-json": "*", + "ext-session": "*", + "php": ">=7.2 <8.2" + }, + "conflict": { + "nette/di": "<3.0" + }, + "require-dev": { + "latte/latte": "^2.5", + "nette/di": "^3.0", + "nette/mail": "^3.0", + "nette/tester": "^2.2", + "nette/utils": "^3.0", + "phpstan/phpstan": "^0.12", + "psr/log": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.8-dev" + } + }, + "autoload": { + "classmap": [ + "src" + ], + "files": [ + "src/Tracy/functions.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "https://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "https://nette.org/contributors" + } + ], + "description": "😎 Tracy: the addictive tool to ease debugging PHP code for cool developers. Friendly design, logging, profiler, advanced features like debugging AJAX calls or CLI support. You will love it.", + "homepage": "https://tracy.nette.org", + "keywords": [ + "Xdebug", + "debug", + "debugger", + "nette", + "profiler" + ], + "support": { + "issues": "https://github.com/nette/tracy/issues", + "source": "https://github.com/nette/tracy/tree/v2.8.7" + }, + "time": "2021-08-24T16:26:27+00:00" + }, + { + "name": "verot/class.upload.php", + "version": "2.1.0", + "source": { + "type": "git", + "url": "https://github.com/verot/class.upload.php.git", + "reference": "4d9aae875245948d21e42ade332fb45f897f28bb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/verot/class.upload.php/zipball/4d9aae875245948d21e42ade332fb45f897f28bb", + "reference": "4d9aae875245948d21e42ade332fb45f897f28bb", + "shasum": "" + }, + "require": { + "php": ">=5.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/class.upload.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0-only" + ], + "authors": [ + { + "name": "Colin Verot", + "email": "colin@verot.net" + } + ], + "description": "This PHP class uploads files and manipulates images very easily.", + "homepage": "http://www.verot.net/php_class_upload.htm", + "keywords": [ + "gd", + "upload" + ], + "support": { + "email": "colin@verot.net", + "issues": "https://github.com/verot/class.upload.php/issues", + "source": "https://github.com/verot/class.upload.php/tree/2.1.0" + }, + "time": "2020-12-13T22:26:17+00:00" + }, + { + "name": "vlucas/phpdotenv", + "version": "v5.3.0", + "source": { + "type": "git", + "url": "https://github.com/vlucas/phpdotenv.git", + "reference": "b3eac5c7ac896e52deab4a99068e3f4ab12d9e56" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/b3eac5c7ac896e52deab4a99068e3f4ab12d9e56", + "reference": "b3eac5c7ac896e52deab4a99068e3f4ab12d9e56", + "shasum": "" + }, + "require": { + "ext-pcre": "*", + "graham-campbell/result-type": "^1.0.1", + "php": "^7.1.3 || ^8.0", + "phpoption/phpoption": "^1.7.4", + "symfony/polyfill-ctype": "^1.17", + "symfony/polyfill-mbstring": "^1.17", + "symfony/polyfill-php80": "^1.17" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.4.1", + "ext-filter": "*", + "phpunit/phpunit": "^7.5.20 || ^8.5.14 || ^9.5.1" + }, + "suggest": { + "ext-filter": "Required to use the boolean validator." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.3-dev" + } + }, + "autoload": { + "psr-4": { + "Dotenv\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "graham@alt-three.com", + "homepage": "https://gjcampbell.co.uk/" + }, + { + "name": "Vance Lucas", + "email": "vance@vancelucas.com", + "homepage": "https://vancelucas.com/" + } + ], + "description": "Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.", + "keywords": [ + "dotenv", + "env", + "environment" + ], + "support": { + "issues": "https://github.com/vlucas/phpdotenv/issues", + "source": "https://github.com/vlucas/phpdotenv/tree/v5.3.0" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/vlucas/phpdotenv", + "type": "tidelift" + } + ], + "time": "2021-01-20T15:23:13+00:00" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "dev", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": ">=8.0" + }, + "platform-dev": [], + "plugin-api-version": "2.1.0" +} diff --git a/env.example b/env.example new file mode 100644 index 0000000..d901106 --- /dev/null +++ b/env.example @@ -0,0 +1,21 @@ +# tis is a env file +# i use https://github.com/vlucas/phpdotenv for this part +# Many thanks to phpdotenv +# Sajjad Eftekhari 2021 + +#Developer settings development production +Dev_set = development + +#Site settings +BASE_URL = http://localhost/tp/debug/public/ + + + +#Database settings + +DB_HOST = localhost +DB_NAME = majid_site +DB_USER = root +DB_PASS = '' + +#DB_PREFIX \ No newline at end of file diff --git a/license.txt b/license.txt new file mode 100644 index 0000000..b69edbe --- /dev/null +++ b/license.txt @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2021-2021 British Columbia Institute of Technology +Copyright (c) 2021-2021 Flare Foundation + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/public/.htaccess b/public/.htaccess new file mode 100644 index 0000000..1a0acf5 --- /dev/null +++ b/public/.htaccess @@ -0,0 +1,49 @@ +#Disable directory browsing +Options All -Indexes + +# ---------------------------------------------------------------------- +# Rewrite engine +# ---------------------------------------------------------------------- + +# Turning on the rewrite engine is necessary for the following rules and features. +# FollowSymLinks must be enabled for this to work. + + Options +FollowSymlinks + RewriteEngine On + + # If you installed CodeIgniter in a subfolder, you will need to + # change the following line to match the subfolder you need. + # http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritebase + # RewriteBase / + # RewriteBase index.php + # Redirect Trailing Slashes... + RewriteCond %{REQUEST_FILENAME} !-d + RewriteCond %{REQUEST_URI} (.+)/$ + RewriteRule ^ %1 [L,R=301] + + # Rewrite "www.example.com -> example.com" + RewriteCond %{HTTPS} !=on + RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] + RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L] + + # Checks to see if the user is attempting to access a valid file, + # such as an image or css document, if this isn't true it sends the + # request to the front controller, index.php + RewriteCond %{REQUEST_FILENAME} !-f + RewriteCond %{REQUEST_FILENAME} !-d + RewriteRule ^([\s\S]*)$ index.php/$1 [L,NC,QSA] + + # Ensure Authorization header is passed along + RewriteCond %{HTTP:Authorization} . + RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] + + + + # If we don't have mod_rewrite installed, all 404's + # can be sent to index.php, and everything works as normal. + ErrorDocument 404 index.php + + +# Disable server signature start + ServerSignature Off +# Disable server signature end diff --git a/public/Flare.png b/public/Flare.png new file mode 100644 index 0000000..daa36d0 Binary files /dev/null and b/public/Flare.png differ diff --git a/public/Orial.ttf b/public/Orial.ttf new file mode 100644 index 0000000..c7eddd3 Binary files /dev/null and b/public/Orial.ttf differ diff --git a/public/addiel.ttf b/public/addiel.ttf new file mode 100644 index 0000000..226652a Binary files /dev/null and b/public/addiel.ttf differ diff --git a/public/captcha-back.jpg b/public/captcha-back.jpg new file mode 100644 index 0000000..84d2652 Binary files /dev/null and b/public/captcha-back.jpg differ diff --git a/public/favicon.ico b/public/favicon.ico new file mode 100644 index 0000000..3e190e6 Binary files /dev/null and b/public/favicon.ico differ diff --git a/public/index.php b/public/index.php new file mode 100644 index 0000000..ef63c61 --- /dev/null +++ b/public/index.php @@ -0,0 +1,4 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Autoload; + +/** + * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. + * + * $loader = new \Composer\Autoload\ClassLoader(); + * + * // register classes with namespaces + * $loader->add('Symfony\Component', __DIR__.'/component'); + * $loader->add('Symfony', __DIR__.'/framework'); + * + * // activate the autoloader + * $loader->register(); + * + * // to enable searching the include path (eg. for PEAR packages) + * $loader->setUseIncludePath(true); + * + * In this example, if you try to use a class in the Symfony\Component + * namespace or one of its children (Symfony\Component\Console for instance), + * the autoloader will first look for the class under the component/ + * directory, and it will then fallback to the framework/ directory if not + * found before giving up. + * + * This class is loosely based on the Symfony UniversalClassLoader. + * + * @author Fabien Potencier + * @author Jordi Boggiano + * @see https://www.php-fig.org/psr/psr-0/ + * @see https://www.php-fig.org/psr/psr-4/ + */ +class ClassLoader +{ + /** @var ?string */ + private $vendorDir; + + // PSR-4 + /** + * @var array[] + * @psalm-var array> + */ + private $prefixLengthsPsr4 = array(); + /** + * @var array[] + * @psalm-var array> + */ + private $prefixDirsPsr4 = array(); + /** + * @var array[] + * @psalm-var array + */ + private $fallbackDirsPsr4 = array(); + + // PSR-0 + /** + * @var array[] + * @psalm-var array> + */ + private $prefixesPsr0 = array(); + /** + * @var array[] + * @psalm-var array + */ + private $fallbackDirsPsr0 = array(); + + /** @var bool */ + private $useIncludePath = false; + + /** + * @var string[] + * @psalm-var array + */ + private $classMap = array(); + + /** @var bool */ + private $classMapAuthoritative = false; + + /** + * @var bool[] + * @psalm-var array + */ + private $missingClasses = array(); + + /** @var ?string */ + private $apcuPrefix; + + /** + * @var self[] + */ + private static $registeredLoaders = array(); + + /** + * @param ?string $vendorDir + */ + public function __construct($vendorDir = null) + { + $this->vendorDir = $vendorDir; + } + + /** + * @return string[] + */ + public function getPrefixes() + { + if (!empty($this->prefixesPsr0)) { + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); + } + + return array(); + } + + /** + * @return array[] + * @psalm-return array> + */ + public function getPrefixesPsr4() + { + return $this->prefixDirsPsr4; + } + + /** + * @return array[] + * @psalm-return array + */ + public function getFallbackDirs() + { + return $this->fallbackDirsPsr0; + } + + /** + * @return array[] + * @psalm-return array + */ + public function getFallbackDirsPsr4() + { + return $this->fallbackDirsPsr4; + } + + /** + * @return string[] Array of classname => path + * @psalm-var array + */ + public function getClassMap() + { + return $this->classMap; + } + + /** + * @param string[] $classMap Class to filename map + * @psalm-param array $classMap + * + * @return void + */ + public function addClassMap(array $classMap) + { + if ($this->classMap) { + $this->classMap = array_merge($this->classMap, $classMap); + } else { + $this->classMap = $classMap; + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, either + * appending or prepending to the ones previously set for this prefix. + * + * @param string $prefix The prefix + * @param string[]|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories + * + * @return void + */ + public function add($prefix, $paths, $prepend = false) + { + if (!$prefix) { + if ($prepend) { + $this->fallbackDirsPsr0 = array_merge( + (array) $paths, + $this->fallbackDirsPsr0 + ); + } else { + $this->fallbackDirsPsr0 = array_merge( + $this->fallbackDirsPsr0, + (array) $paths + ); + } + + return; + } + + $first = $prefix[0]; + if (!isset($this->prefixesPsr0[$first][$prefix])) { + $this->prefixesPsr0[$first][$prefix] = (array) $paths; + + return; + } + if ($prepend) { + $this->prefixesPsr0[$first][$prefix] = array_merge( + (array) $paths, + $this->prefixesPsr0[$first][$prefix] + ); + } else { + $this->prefixesPsr0[$first][$prefix] = array_merge( + $this->prefixesPsr0[$first][$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, either + * appending or prepending to the ones previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param string[]|string $paths The PSR-4 base directories + * @param bool $prepend Whether to prepend the directories + * + * @throws \InvalidArgumentException + * + * @return void + */ + public function addPsr4($prefix, $paths, $prepend = false) + { + if (!$prefix) { + // Register directories for the root namespace. + if ($prepend) { + $this->fallbackDirsPsr4 = array_merge( + (array) $paths, + $this->fallbackDirsPsr4 + ); + } else { + $this->fallbackDirsPsr4 = array_merge( + $this->fallbackDirsPsr4, + (array) $paths + ); + } + } elseif (!isset($this->prefixDirsPsr4[$prefix])) { + // Register directories for a new namespace. + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } elseif ($prepend) { + // Prepend directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + (array) $paths, + $this->prefixDirsPsr4[$prefix] + ); + } else { + // Append directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + $this->prefixDirsPsr4[$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, + * replacing any others previously set for this prefix. + * + * @param string $prefix The prefix + * @param string[]|string $paths The PSR-0 base directories + * + * @return void + */ + public function set($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr0 = (array) $paths; + } else { + $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, + * replacing any others previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param string[]|string $paths The PSR-4 base directories + * + * @throws \InvalidArgumentException + * + * @return void + */ + public function setPsr4($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr4 = (array) $paths; + } else { + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } + } + + /** + * Turns on searching the include path for class files. + * + * @param bool $useIncludePath + * + * @return void + */ + public function setUseIncludePath($useIncludePath) + { + $this->useIncludePath = $useIncludePath; + } + + /** + * Can be used to check if the autoloader uses the include path to check + * for classes. + * + * @return bool + */ + public function getUseIncludePath() + { + return $this->useIncludePath; + } + + /** + * Turns off searching the prefix and fallback directories for classes + * that have not been registered with the class map. + * + * @param bool $classMapAuthoritative + * + * @return void + */ + public function setClassMapAuthoritative($classMapAuthoritative) + { + $this->classMapAuthoritative = $classMapAuthoritative; + } + + /** + * Should class lookup fail if not found in the current class map? + * + * @return bool + */ + public function isClassMapAuthoritative() + { + return $this->classMapAuthoritative; + } + + /** + * APCu prefix to use to cache found/not-found classes, if the extension is enabled. + * + * @param string|null $apcuPrefix + * + * @return void + */ + public function setApcuPrefix($apcuPrefix) + { + $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null; + } + + /** + * The APCu prefix in use, or null if APCu caching is not enabled. + * + * @return string|null + */ + public function getApcuPrefix() + { + return $this->apcuPrefix; + } + + /** + * Registers this instance as an autoloader. + * + * @param bool $prepend Whether to prepend the autoloader or not + * + * @return void + */ + public function register($prepend = false) + { + spl_autoload_register(array($this, 'loadClass'), true, $prepend); + + if (null === $this->vendorDir) { + return; + } + + if ($prepend) { + self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders; + } else { + unset(self::$registeredLoaders[$this->vendorDir]); + self::$registeredLoaders[$this->vendorDir] = $this; + } + } + + /** + * Unregisters this instance as an autoloader. + * + * @return void + */ + public function unregister() + { + spl_autoload_unregister(array($this, 'loadClass')); + + if (null !== $this->vendorDir) { + unset(self::$registeredLoaders[$this->vendorDir]); + } + } + + /** + * Loads the given class or interface. + * + * @param string $class The name of the class + * @return true|null True if loaded, null otherwise + */ + public function loadClass($class) + { + if ($file = $this->findFile($class)) { + includeFile($file); + + return true; + } + + return null; + } + + /** + * Finds the path to the file where the class is defined. + * + * @param string $class The name of the class + * + * @return string|false The path if found, false otherwise + */ + public function findFile($class) + { + // class map lookup + if (isset($this->classMap[$class])) { + return $this->classMap[$class]; + } + if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { + return false; + } + if (null !== $this->apcuPrefix) { + $file = apcu_fetch($this->apcuPrefix.$class, $hit); + if ($hit) { + return $file; + } + } + + $file = $this->findFileWithExtension($class, '.php'); + + // Search for Hack files if we are running on HHVM + if (false === $file && defined('HHVM_VERSION')) { + $file = $this->findFileWithExtension($class, '.hh'); + } + + if (null !== $this->apcuPrefix) { + apcu_add($this->apcuPrefix.$class, $file); + } + + if (false === $file) { + // Remember that this class does not exist. + $this->missingClasses[$class] = true; + } + + return $file; + } + + /** + * Returns the currently registered loaders indexed by their corresponding vendor directories. + * + * @return self[] + */ + public static function getRegisteredLoaders() + { + return self::$registeredLoaders; + } + + /** + * @param string $class + * @param string $ext + * @return string|false + */ + private function findFileWithExtension($class, $ext) + { + // PSR-4 lookup + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; + + $first = $class[0]; + if (isset($this->prefixLengthsPsr4[$first])) { + $subPath = $class; + while (false !== $lastPos = strrpos($subPath, '\\')) { + $subPath = substr($subPath, 0, $lastPos); + $search = $subPath . '\\'; + if (isset($this->prefixDirsPsr4[$search])) { + $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); + foreach ($this->prefixDirsPsr4[$search] as $dir) { + if (file_exists($file = $dir . $pathEnd)) { + return $file; + } + } + } + } + } + + // PSR-4 fallback dirs + foreach ($this->fallbackDirsPsr4 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { + return $file; + } + } + + // PSR-0 lookup + if (false !== $pos = strrpos($class, '\\')) { + // namespaced class name + $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) + . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); + } else { + // PEAR-like class name + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; + } + + if (isset($this->prefixesPsr0[$first])) { + foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { + if (0 === strpos($class, $prefix)) { + foreach ($dirs as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + } + } + } + + // PSR-0 fallback dirs + foreach ($this->fallbackDirsPsr0 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + + // PSR-0 include paths. + if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { + return $file; + } + + return false; + } +} + +/** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + * + * @param string $file + * @return void + * @private + */ +function includeFile($file) +{ + include $file; +} diff --git a/vendor/composer/InstalledVersions.php b/vendor/composer/InstalledVersions.php new file mode 100644 index 0000000..7c5502c --- /dev/null +++ b/vendor/composer/InstalledVersions.php @@ -0,0 +1,337 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer; + +use Composer\Autoload\ClassLoader; +use Composer\Semver\VersionParser; + +/** + * This class is copied in every Composer installed project and available to all + * + * See also https://getcomposer.org/doc/07-runtime.md#installed-versions + * + * To require its presence, you can require `composer-runtime-api ^2.0` + */ +class InstalledVersions +{ + private static $installed; + private static $canGetVendors; + private static $installedByVendor = array(); + + /** + * Returns a list of all package names which are present, either by being installed, replaced or provided + * + * @return string[] + * @psalm-return list + */ + public static function getInstalledPackages() + { + $packages = array(); + foreach (self::getInstalled() as $installed) { + $packages[] = array_keys($installed['versions']); + } + + if (1 === \count($packages)) { + return $packages[0]; + } + + return array_keys(array_flip(\call_user_func_array('array_merge', $packages))); + } + + /** + * Returns a list of all package names with a specific type e.g. 'library' + * + * @param string $type + * @return string[] + * @psalm-return list + */ + public static function getInstalledPackagesByType($type) + { + $packagesByType = array(); + + foreach (self::getInstalled() as $installed) { + foreach ($installed['versions'] as $name => $package) { + if (isset($package['type']) && $package['type'] === $type) { + $packagesByType[] = $name; + } + } + } + + return $packagesByType; + } + + /** + * Checks whether the given package is installed + * + * This also returns true if the package name is provided or replaced by another package + * + * @param string $packageName + * @param bool $includeDevRequirements + * @return bool + */ + public static function isInstalled($packageName, $includeDevRequirements = true) + { + foreach (self::getInstalled() as $installed) { + if (isset($installed['versions'][$packageName])) { + return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']); + } + } + + return false; + } + + /** + * Checks whether the given package satisfies a version constraint + * + * e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call: + * + * Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3') + * + * @param VersionParser $parser Install composer/semver to have access to this class and functionality + * @param string $packageName + * @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package + * @return bool + */ + public static function satisfies(VersionParser $parser, $packageName, $constraint) + { + $constraint = $parser->parseConstraints($constraint); + $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); + + return $provided->matches($constraint); + } + + /** + * Returns a version constraint representing all the range(s) which are installed for a given package + * + * It is easier to use this via isInstalled() with the $constraint argument if you need to check + * whether a given version of a package is installed, and not just whether it exists + * + * @param string $packageName + * @return string Version constraint usable with composer/semver + */ + public static function getVersionRanges($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + $ranges = array(); + if (isset($installed['versions'][$packageName]['pretty_version'])) { + $ranges[] = $installed['versions'][$packageName]['pretty_version']; + } + if (array_key_exists('aliases', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']); + } + if (array_key_exists('replaced', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']); + } + if (array_key_exists('provided', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']); + } + + return implode(' || ', $ranges); + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present + */ + public static function getVersion($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['version'])) { + return null; + } + + return $installed['versions'][$packageName]['version']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present + */ + public static function getPrettyVersion($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['pretty_version'])) { + return null; + } + + return $installed['versions'][$packageName]['pretty_version']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference + */ + public static function getReference($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['reference'])) { + return null; + } + + return $installed['versions'][$packageName]['reference']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path. + */ + public static function getInstallPath($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @return array + * @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string} + */ + public static function getRootPackage() + { + $installed = self::getInstalled(); + + return $installed[0]['root']; + } + + /** + * Returns the raw installed.php data for custom implementations + * + * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect. + * @return array[] + * @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array} + */ + public static function getRawData() + { + @trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED); + + if (null === self::$installed) { + // only require the installed.php file if this file is loaded from its dumped location, + // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 + if (substr(__DIR__, -8, 1) !== 'C') { + self::$installed = include __DIR__ . '/installed.php'; + } else { + self::$installed = array(); + } + } + + return self::$installed; + } + + /** + * Returns the raw data of all installed.php which are currently loaded for custom implementations + * + * @return array[] + * @psalm-return list}> + */ + public static function getAllRawData() + { + return self::getInstalled(); + } + + /** + * Lets you reload the static array from another file + * + * This is only useful for complex integrations in which a project needs to use + * this class but then also needs to execute another project's autoloader in process, + * and wants to ensure both projects have access to their version of installed.php. + * + * A typical case would be PHPUnit, where it would need to make sure it reads all + * the data it needs from this class, then call reload() with + * `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure + * the project in which it runs can then also use this class safely, without + * interference between PHPUnit's dependencies and the project's dependencies. + * + * @param array[] $data A vendor/composer/installed.php data set + * @return void + * + * @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array} $data + */ + public static function reload($data) + { + self::$installed = $data; + self::$installedByVendor = array(); + } + + /** + * @return array[] + * @psalm-return list}> + */ + private static function getInstalled() + { + if (null === self::$canGetVendors) { + self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders'); + } + + $installed = array(); + + if (self::$canGetVendors) { + foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { + if (isset(self::$installedByVendor[$vendorDir])) { + $installed[] = self::$installedByVendor[$vendorDir]; + } elseif (is_file($vendorDir.'/composer/installed.php')) { + $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php'; + if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { + self::$installed = $installed[count($installed) - 1]; + } + } + } + } + + if (null === self::$installed) { + // only require the installed.php file if this file is loaded from its dumped location, + // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 + if (substr(__DIR__, -8, 1) !== 'C') { + self::$installed = require __DIR__ . '/installed.php'; + } else { + self::$installed = array(); + } + } + $installed[] = self::$installed; + + return $installed; + } +} diff --git a/vendor/composer/LICENSE b/vendor/composer/LICENSE new file mode 100644 index 0000000..f27399a --- /dev/null +++ b/vendor/composer/LICENSE @@ -0,0 +1,21 @@ + +Copyright (c) Nils Adermann, Jordi Boggiano + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php new file mode 100644 index 0000000..1148ffe --- /dev/null +++ b/vendor/composer/autoload_classmap.php @@ -0,0 +1,35 @@ + $vendorDir . '/symfony/polyfill-php80/Resources/stubs/Attribute.php', + 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php', + 'Stringable' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/Stringable.php', + 'Tracy\\Bar' => $vendorDir . '/tracy/tracy/src/Tracy/Bar/Bar.php', + 'Tracy\\BlueScreen' => $vendorDir . '/tracy/tracy/src/Tracy/BlueScreen/BlueScreen.php', + 'Tracy\\Bridges\\Nette\\Bridge' => $vendorDir . '/tracy/tracy/src/Bridges/Nette/Bridge.php', + 'Tracy\\Bridges\\Nette\\MailSender' => $vendorDir . '/tracy/tracy/src/Bridges/Nette/MailSender.php', + 'Tracy\\Bridges\\Nette\\TracyExtension' => $vendorDir . '/tracy/tracy/src/Bridges/Nette/TracyExtension.php', + 'Tracy\\Bridges\\Psr\\PsrToTracyLoggerAdapter' => $vendorDir . '/tracy/tracy/src/Bridges/Psr/PsrToTracyLoggerAdapter.php', + 'Tracy\\Bridges\\Psr\\TracyToPsrLoggerAdapter' => $vendorDir . '/tracy/tracy/src/Bridges/Psr/TracyToPsrLoggerAdapter.php', + 'Tracy\\Debugger' => $vendorDir . '/tracy/tracy/src/Tracy/Debugger/Debugger.php', + 'Tracy\\DefaultBarPanel' => $vendorDir . '/tracy/tracy/src/Tracy/Bar/DefaultBarPanel.php', + 'Tracy\\Dumper' => $vendorDir . '/tracy/tracy/src/Tracy/Dumper/Dumper.php', + 'Tracy\\Dumper\\Describer' => $vendorDir . '/tracy/tracy/src/Tracy/Dumper/Describer.php', + 'Tracy\\Dumper\\Exposer' => $vendorDir . '/tracy/tracy/src/Tracy/Dumper/Exposer.php', + 'Tracy\\Dumper\\Renderer' => $vendorDir . '/tracy/tracy/src/Tracy/Dumper/Renderer.php', + 'Tracy\\Dumper\\Value' => $vendorDir . '/tracy/tracy/src/Tracy/Dumper/Value.php', + 'Tracy\\FireLogger' => $vendorDir . '/tracy/tracy/src/Tracy/Logger/FireLogger.php', + 'Tracy\\Helpers' => $vendorDir . '/tracy/tracy/src/Tracy/Helpers.php', + 'Tracy\\IBarPanel' => $vendorDir . '/tracy/tracy/src/Tracy/Bar/IBarPanel.php', + 'Tracy\\ILogger' => $vendorDir . '/tracy/tracy/src/Tracy/Logger/ILogger.php', + 'Tracy\\Logger' => $vendorDir . '/tracy/tracy/src/Tracy/Logger/Logger.php', + 'Tracy\\OutputDebugger' => $vendorDir . '/tracy/tracy/src/Tracy/OutputDebugger/OutputDebugger.php', + 'UnhandledMatchError' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php', + 'ValueError' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/ValueError.php', + 'Verot\\Upload\\Upload' => $vendorDir . '/verot/class.upload.php/src/class.upload.php', +); diff --git a/vendor/composer/autoload_files.php b/vendor/composer/autoload_files.php new file mode 100644 index 0000000..93fc0a5 --- /dev/null +++ b/vendor/composer/autoload_files.php @@ -0,0 +1,15 @@ + $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php', + 'a4a119a56e50fbb293281d9a48007e0e' => $vendorDir . '/symfony/polyfill-php80/bootstrap.php', + '6e3fae29631ef280660b3cdad06f25a8' => $vendorDir . '/symfony/deprecation-contracts/function.php', + '2df68f9e79c919e2d88506611769ed2e' => $vendorDir . '/respect/stringifier/src/stringify.php', + '320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php', + 'd507e002f7fce7f0c6dbf1f22edcb902' => $vendorDir . '/tracy/tracy/src/Tracy/functions.php', +); diff --git a/vendor/composer/autoload_namespaces.php b/vendor/composer/autoload_namespaces.php new file mode 100644 index 0000000..b7fc012 --- /dev/null +++ b/vendor/composer/autoload_namespaces.php @@ -0,0 +1,9 @@ + array($vendorDir . '/symfony/polyfill-php80'), + 'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'), + 'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'), + 'Symfony\\Component\\HttpFoundation\\' => array($vendorDir . '/symfony/http-foundation'), + 'Respect\\Validation\\' => array($vendorDir . '/respect/validation/library'), + 'Respect\\Stringifier\\' => array($vendorDir . '/respect/stringifier/src'), + 'Psr\\Http\\Server\\' => array($vendorDir . '/psr/http-server-handler/src', $vendorDir . '/psr/http-server-middleware/src'), + 'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src'), + 'PhpOption\\' => array($vendorDir . '/phpoption/phpoption/src/PhpOption'), + 'PHPMailer\\PHPMailer\\' => array($vendorDir . '/phpmailer/phpmailer/src'), + 'Odan\\Session\\' => array($vendorDir . '/odan/session/src'), + 'League\\Plates\\' => array($vendorDir . '/league/plates/src'), + 'GrahamCampbell\\ResultType\\' => array($vendorDir . '/graham-campbell/result-type/src'), + 'Dotenv\\' => array($vendorDir . '/vlucas/phpdotenv/src'), + 'Buki\\Router\\' => array($vendorDir . '/izniburak/router/src'), +); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php new file mode 100644 index 0000000..f3166a0 --- /dev/null +++ b/vendor/composer/autoload_real.php @@ -0,0 +1,75 @@ += 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); + if ($useStaticLoader) { + require __DIR__ . '/autoload_static.php'; + + call_user_func(\Composer\Autoload\ComposerStaticInitf106dc40b75b094d8848fab9be239569::getInitializer($loader)); + } else { + $map = require __DIR__ . '/autoload_namespaces.php'; + foreach ($map as $namespace => $path) { + $loader->set($namespace, $path); + } + + $map = require __DIR__ . '/autoload_psr4.php'; + foreach ($map as $namespace => $path) { + $loader->setPsr4($namespace, $path); + } + + $classMap = require __DIR__ . '/autoload_classmap.php'; + if ($classMap) { + $loader->addClassMap($classMap); + } + } + + $loader->register(true); + + if ($useStaticLoader) { + $includeFiles = Composer\Autoload\ComposerStaticInitf106dc40b75b094d8848fab9be239569::$files; + } else { + $includeFiles = require __DIR__ . '/autoload_files.php'; + } + foreach ($includeFiles as $fileIdentifier => $file) { + composerRequiref106dc40b75b094d8848fab9be239569($fileIdentifier, $file); + } + + return $loader; + } +} + +function composerRequiref106dc40b75b094d8848fab9be239569($fileIdentifier, $file) +{ + if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { + require $file; + + $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; + } +} diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php new file mode 100644 index 0000000..50968ef --- /dev/null +++ b/vendor/composer/autoload_static.php @@ -0,0 +1,162 @@ + __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php', + 'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php', + '6e3fae29631ef280660b3cdad06f25a8' => __DIR__ . '/..' . '/symfony/deprecation-contracts/function.php', + '2df68f9e79c919e2d88506611769ed2e' => __DIR__ . '/..' . '/respect/stringifier/src/stringify.php', + '320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php', + 'd507e002f7fce7f0c6dbf1f22edcb902' => __DIR__ . '/..' . '/tracy/tracy/src/Tracy/functions.php', + ); + + public static $prefixLengthsPsr4 = array ( + 'S' => + array ( + 'Symfony\\Polyfill\\Php80\\' => 23, + 'Symfony\\Polyfill\\Mbstring\\' => 26, + 'Symfony\\Polyfill\\Ctype\\' => 23, + 'Symfony\\Component\\HttpFoundation\\' => 33, + ), + 'R' => + array ( + 'Respect\\Validation\\' => 19, + 'Respect\\Stringifier\\' => 20, + ), + 'P' => + array ( + 'Psr\\Http\\Server\\' => 16, + 'Psr\\Http\\Message\\' => 17, + 'PhpOption\\' => 10, + 'PHPMailer\\PHPMailer\\' => 20, + ), + 'O' => + array ( + 'Odan\\Session\\' => 13, + ), + 'L' => + array ( + 'League\\Plates\\' => 14, + ), + 'G' => + array ( + 'GrahamCampbell\\ResultType\\' => 26, + ), + 'D' => + array ( + 'Dotenv\\' => 7, + ), + 'B' => + array ( + 'Buki\\Router\\' => 12, + ), + ); + + public static $prefixDirsPsr4 = array ( + 'Symfony\\Polyfill\\Php80\\' => + array ( + 0 => __DIR__ . '/..' . '/symfony/polyfill-php80', + ), + 'Symfony\\Polyfill\\Mbstring\\' => + array ( + 0 => __DIR__ . '/..' . '/symfony/polyfill-mbstring', + ), + 'Symfony\\Polyfill\\Ctype\\' => + array ( + 0 => __DIR__ . '/..' . '/symfony/polyfill-ctype', + ), + 'Symfony\\Component\\HttpFoundation\\' => + array ( + 0 => __DIR__ . '/..' . '/symfony/http-foundation', + ), + 'Respect\\Validation\\' => + array ( + 0 => __DIR__ . '/..' . '/respect/validation/library', + ), + 'Respect\\Stringifier\\' => + array ( + 0 => __DIR__ . '/..' . '/respect/stringifier/src', + ), + 'Psr\\Http\\Server\\' => + array ( + 0 => __DIR__ . '/..' . '/psr/http-server-handler/src', + 1 => __DIR__ . '/..' . '/psr/http-server-middleware/src', + ), + 'Psr\\Http\\Message\\' => + array ( + 0 => __DIR__ . '/..' . '/psr/http-message/src', + ), + 'PhpOption\\' => + array ( + 0 => __DIR__ . '/..' . '/phpoption/phpoption/src/PhpOption', + ), + 'PHPMailer\\PHPMailer\\' => + array ( + 0 => __DIR__ . '/..' . '/phpmailer/phpmailer/src', + ), + 'Odan\\Session\\' => + array ( + 0 => __DIR__ . '/..' . '/odan/session/src', + ), + 'League\\Plates\\' => + array ( + 0 => __DIR__ . '/..' . '/league/plates/src', + ), + 'GrahamCampbell\\ResultType\\' => + array ( + 0 => __DIR__ . '/..' . '/graham-campbell/result-type/src', + ), + 'Dotenv\\' => + array ( + 0 => __DIR__ . '/..' . '/vlucas/phpdotenv/src', + ), + 'Buki\\Router\\' => + array ( + 0 => __DIR__ . '/..' . '/izniburak/router/src', + ), + ); + + public static $classMap = array ( + 'Attribute' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/Attribute.php', + 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', + 'Stringable' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/Stringable.php', + 'Tracy\\Bar' => __DIR__ . '/..' . '/tracy/tracy/src/Tracy/Bar/Bar.php', + 'Tracy\\BlueScreen' => __DIR__ . '/..' . '/tracy/tracy/src/Tracy/BlueScreen/BlueScreen.php', + 'Tracy\\Bridges\\Nette\\Bridge' => __DIR__ . '/..' . '/tracy/tracy/src/Bridges/Nette/Bridge.php', + 'Tracy\\Bridges\\Nette\\MailSender' => __DIR__ . '/..' . '/tracy/tracy/src/Bridges/Nette/MailSender.php', + 'Tracy\\Bridges\\Nette\\TracyExtension' => __DIR__ . '/..' . '/tracy/tracy/src/Bridges/Nette/TracyExtension.php', + 'Tracy\\Bridges\\Psr\\PsrToTracyLoggerAdapter' => __DIR__ . '/..' . '/tracy/tracy/src/Bridges/Psr/PsrToTracyLoggerAdapter.php', + 'Tracy\\Bridges\\Psr\\TracyToPsrLoggerAdapter' => __DIR__ . '/..' . '/tracy/tracy/src/Bridges/Psr/TracyToPsrLoggerAdapter.php', + 'Tracy\\Debugger' => __DIR__ . '/..' . '/tracy/tracy/src/Tracy/Debugger/Debugger.php', + 'Tracy\\DefaultBarPanel' => __DIR__ . '/..' . '/tracy/tracy/src/Tracy/Bar/DefaultBarPanel.php', + 'Tracy\\Dumper' => __DIR__ . '/..' . '/tracy/tracy/src/Tracy/Dumper/Dumper.php', + 'Tracy\\Dumper\\Describer' => __DIR__ . '/..' . '/tracy/tracy/src/Tracy/Dumper/Describer.php', + 'Tracy\\Dumper\\Exposer' => __DIR__ . '/..' . '/tracy/tracy/src/Tracy/Dumper/Exposer.php', + 'Tracy\\Dumper\\Renderer' => __DIR__ . '/..' . '/tracy/tracy/src/Tracy/Dumper/Renderer.php', + 'Tracy\\Dumper\\Value' => __DIR__ . '/..' . '/tracy/tracy/src/Tracy/Dumper/Value.php', + 'Tracy\\FireLogger' => __DIR__ . '/..' . '/tracy/tracy/src/Tracy/Logger/FireLogger.php', + 'Tracy\\Helpers' => __DIR__ . '/..' . '/tracy/tracy/src/Tracy/Helpers.php', + 'Tracy\\IBarPanel' => __DIR__ . '/..' . '/tracy/tracy/src/Tracy/Bar/IBarPanel.php', + 'Tracy\\ILogger' => __DIR__ . '/..' . '/tracy/tracy/src/Tracy/Logger/ILogger.php', + 'Tracy\\Logger' => __DIR__ . '/..' . '/tracy/tracy/src/Tracy/Logger/Logger.php', + 'Tracy\\OutputDebugger' => __DIR__ . '/..' . '/tracy/tracy/src/Tracy/OutputDebugger/OutputDebugger.php', + 'UnhandledMatchError' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php', + 'ValueError' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/ValueError.php', + 'Verot\\Upload\\Upload' => __DIR__ . '/..' . '/verot/class.upload.php/src/class.upload.php', + ); + + public static function getInitializer(ClassLoader $loader) + { + return \Closure::bind(function () use ($loader) { + $loader->prefixLengthsPsr4 = ComposerStaticInitf106dc40b75b094d8848fab9be239569::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInitf106dc40b75b094d8848fab9be239569::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInitf106dc40b75b094d8848fab9be239569::$classMap; + + }, null, ClassLoader::class); + } +} diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json new file mode 100644 index 0000000..a965dab --- /dev/null +++ b/vendor/composer/installed.json @@ -0,0 +1,1312 @@ +{ + "packages": [ + { + "name": "graham-campbell/result-type", + "version": "v1.0.2", + "version_normalized": "1.0.2.0", + "source": { + "type": "git", + "url": "https://github.com/GrahamCampbell/Result-Type.git", + "reference": "84afea85c6841deeea872f36249a206e878a5de0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/GrahamCampbell/Result-Type/zipball/84afea85c6841deeea872f36249a206e878a5de0", + "reference": "84afea85c6841deeea872f36249a206e878a5de0", + "shasum": "" + }, + "require": { + "php": "^7.0 || ^8.0", + "phpoption/phpoption": "^1.8" + }, + "require-dev": { + "phpunit/phpunit": "^6.5.14 || ^7.5.20 || ^8.5.19 || ^9.5.8" + }, + "time": "2021-08-28T21:34:50+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "GrahamCampbell\\ResultType\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk" + } + ], + "description": "An Implementation Of The Result Type", + "keywords": [ + "Graham Campbell", + "GrahamCampbell", + "Result Type", + "Result-Type", + "result" + ], + "support": { + "issues": "https://github.com/GrahamCampbell/Result-Type/issues", + "source": "https://github.com/GrahamCampbell/Result-Type/tree/v1.0.2" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/graham-campbell/result-type", + "type": "tidelift" + } + ], + "install-path": "../graham-campbell/result-type" + }, + { + "name": "izniburak/router", + "version": "v2.3.1", + "version_normalized": "2.3.1.0", + "source": { + "type": "git", + "url": "https://github.com/izniburak/php-router.git", + "reference": "9d9ce5a2708b1cddae965cf78c5b279355d23646" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/izniburak/php-router/zipball/9d9ce5a2708b1cddae965cf78c5b279355d23646", + "reference": "9d9ce5a2708b1cddae965cf78c5b279355d23646", + "shasum": "" + }, + "require": { + "ext-json": "*", + "php": ">=7.2.5", + "symfony/http-foundation": "^5.1" + }, + "require-dev": { + "guzzlehttp/guzzle": "^7.2", + "phpunit/phpunit": "^8.5 || ^9.4" + }, + "time": "2021-05-09T22:51:49+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Buki\\Router\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "İzni Burak Demirtaş", + "email": "info@burakdemirtas.org", + "homepage": "https://burakdemirtas.org" + } + ], + "description": "simple router class for php", + "homepage": "https://github.com/izniburak/php-router", + "keywords": [ + "route", + "router", + "routing" + ], + "support": { + "issues": "https://github.com/izniburak/php-router/issues", + "source": "https://github.com/izniburak/php-router/tree/v2.3.1" + }, + "install-path": "../izniburak/router" + }, + { + "name": "league/plates", + "version": "v3.4.0", + "version_normalized": "3.4.0.0", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/plates.git", + "reference": "6d3ee31199b536a4e003b34a356ca20f6f75496a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/plates/zipball/6d3ee31199b536a4e003b34a356ca20f6f75496a", + "reference": "6d3ee31199b536a4e003b34a356ca20f6f75496a", + "shasum": "" + }, + "require": { + "php": "^7.0|^8.0" + }, + "require-dev": { + "mikey179/vfsstream": "^1.6", + "phpunit/phpunit": "^9.5", + "squizlabs/php_codesniffer": "^3.5" + }, + "time": "2020-12-25T05:00:37+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "League\\Plates\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jonathan Reinink", + "email": "jonathan@reinink.ca", + "role": "Developer" + }, + { + "name": "RJ Garcia", + "email": "ragboyjr@icloud.com", + "role": "Developer" + } + ], + "description": "Plates, the native PHP template system that's fast, easy to use and easy to extend.", + "homepage": "https://platesphp.com", + "keywords": [ + "league", + "package", + "templates", + "templating", + "views" + ], + "support": { + "issues": "https://github.com/thephpleague/plates/issues", + "source": "https://github.com/thephpleague/plates/tree/v3.4.0" + }, + "install-path": "../league/plates" + }, + { + "name": "odan/session", + "version": "5.1.0", + "version_normalized": "5.1.0.0", + "source": { + "type": "git", + "url": "https://github.com/odan/session.git", + "reference": "df95aeee04dec466172d4c4e0e3ac9245e8182b0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/odan/session/zipball/df95aeee04dec466172d4c4e0e3ac9245e8182b0", + "reference": "df95aeee04dec466172d4c4e0e3ac9245e8182b0", + "shasum": "" + }, + "require": { + "php": "^7.3 || ^8.0", + "psr/http-message": "^1.0", + "psr/http-server-handler": "^1.0", + "psr/http-server-middleware": "^1.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.16", + "middlewares/utils": "^3.1", + "overtrue/phplint": "^1.1 || ^2.0", + "phpstan/phpstan": "0.*", + "phpunit/phpunit": "^7 || ^8 || ^9", + "slim/psr7": "^1.1", + "squizlabs/php_codesniffer": "^3.4" + }, + "time": "2020-12-23T18:09:07+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Odan\\Session\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A Slim session handler", + "homepage": "https://github.com/odan/session", + "keywords": [ + "session", + "slim" + ], + "support": { + "issues": "https://github.com/odan/session/issues", + "source": "https://github.com/odan/session/tree/5.1.0" + }, + "install-path": "../odan/session" + }, + { + "name": "phpmailer/phpmailer", + "version": "v6.5.1", + "version_normalized": "6.5.1.0", + "source": { + "type": "git", + "url": "https://github.com/PHPMailer/PHPMailer.git", + "reference": "dd803df5ad7492e1b40637f7ebd258fee5ca7355" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/dd803df5ad7492e1b40637f7ebd258fee5ca7355", + "reference": "dd803df5ad7492e1b40637f7ebd258fee5ca7355", + "shasum": "" + }, + "require": { + "ext-ctype": "*", + "ext-filter": "*", + "ext-hash": "*", + "php": ">=5.5.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0", + "doctrine/annotations": "^1.2", + "php-parallel-lint/php-console-highlighter": "^0.5.0", + "php-parallel-lint/php-parallel-lint": "^1.3", + "phpcompatibility/php-compatibility": "^9.3.5", + "roave/security-advisories": "dev-latest", + "squizlabs/php_codesniffer": "^3.6.0", + "yoast/phpunit-polyfills": "^1.0.0" + }, + "suggest": { + "ext-mbstring": "Needed to send email in multibyte encoding charset or decode encoded addresses", + "hayageek/oauth2-yahoo": "Needed for Yahoo XOAUTH2 authentication", + "league/oauth2-google": "Needed for Google XOAUTH2 authentication", + "psr/log": "For optional PSR-3 debug logging", + "stevenmaguire/oauth2-microsoft": "Needed for Microsoft XOAUTH2 authentication", + "symfony/polyfill-mbstring": "To support UTF-8 if the Mbstring PHP extension is not enabled (^1.2)" + }, + "time": "2021-08-18T09:14:16+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "PHPMailer\\PHPMailer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-2.1-only" + ], + "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" + } + ], + "description": "PHPMailer is a full-featured email creation and transfer class for PHP", + "support": { + "issues": "https://github.com/PHPMailer/PHPMailer/issues", + "source": "https://github.com/PHPMailer/PHPMailer/tree/v6.5.1" + }, + "funding": [ + { + "url": "https://github.com/Synchro", + "type": "github" + } + ], + "install-path": "../phpmailer/phpmailer" + }, + { + "name": "phpoption/phpoption", + "version": "1.8.0", + "version_normalized": "1.8.0.0", + "source": { + "type": "git", + "url": "https://github.com/schmittjoh/php-option.git", + "reference": "5455cb38aed4523f99977c4a12ef19da4bfe2a28" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/5455cb38aed4523f99977c4a12ef19da4bfe2a28", + "reference": "5455cb38aed4523f99977c4a12ef19da4bfe2a28", + "shasum": "" + }, + "require": { + "php": "^7.0 || ^8.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.4.1", + "phpunit/phpunit": "^6.5.14 || ^7.0.20 || ^8.5.19 || ^9.5.8" + }, + "time": "2021-08-28T21:27:29+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.8-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "PhpOption\\": "src/PhpOption/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Johannes M. Schmitt", + "email": "schmittjoh@gmail.com" + }, + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk" + } + ], + "description": "Option Type for PHP", + "keywords": [ + "language", + "option", + "php", + "type" + ], + "support": { + "issues": "https://github.com/schmittjoh/php-option/issues", + "source": "https://github.com/schmittjoh/php-option/tree/1.8.0" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpoption/phpoption", + "type": "tidelift" + } + ], + "install-path": "../phpoption/phpoption" + }, + { + "name": "psr/http-message", + "version": "1.0.1", + "version_normalized": "1.0.1.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "time": "2016-08-06T14:39:51+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-message/tree/master" + }, + "install-path": "../psr/http-message" + }, + { + "name": "psr/http-server-handler", + "version": "1.0.1", + "version_normalized": "1.0.1.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-server-handler.git", + "reference": "aff2f80e33b7f026ec96bb42f63242dc50ffcae7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-server-handler/zipball/aff2f80e33b7f026ec96bb42f63242dc50ffcae7", + "reference": "aff2f80e33b7f026ec96bb42f63242dc50ffcae7", + "shasum": "" + }, + "require": { + "php": ">=7.0", + "psr/http-message": "^1.0" + }, + "time": "2018-10-30T16:46:14+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Psr\\Http\\Server\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP server-side request handler", + "keywords": [ + "handler", + "http", + "http-interop", + "psr", + "psr-15", + "psr-7", + "request", + "response", + "server" + ], + "support": { + "issues": "https://github.com/php-fig/http-server-handler/issues", + "source": "https://github.com/php-fig/http-server-handler/tree/master" + }, + "install-path": "../psr/http-server-handler" + }, + { + "name": "psr/http-server-middleware", + "version": "1.0.1", + "version_normalized": "1.0.1.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-server-middleware.git", + "reference": "2296f45510945530b9dceb8bcedb5cb84d40c5f5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-server-middleware/zipball/2296f45510945530b9dceb8bcedb5cb84d40c5f5", + "reference": "2296f45510945530b9dceb8bcedb5cb84d40c5f5", + "shasum": "" + }, + "require": { + "php": ">=7.0", + "psr/http-message": "^1.0", + "psr/http-server-handler": "^1.0" + }, + "time": "2018-10-30T17:12:04+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Psr\\Http\\Server\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP server-side middleware", + "keywords": [ + "http", + "http-interop", + "middleware", + "psr", + "psr-15", + "psr-7", + "request", + "response" + ], + "support": { + "issues": "https://github.com/php-fig/http-server-middleware/issues", + "source": "https://github.com/php-fig/http-server-middleware/tree/master" + }, + "install-path": "../psr/http-server-middleware" + }, + { + "name": "respect/stringifier", + "version": "0.2.0", + "version_normalized": "0.2.0.0", + "source": { + "type": "git", + "url": "https://github.com/Respect/Stringifier.git", + "reference": "e55af3c8aeaeaa2abb5fa47a58a8e9688cc23b59" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Respect/Stringifier/zipball/e55af3c8aeaeaa2abb5fa47a58a8e9688cc23b59", + "reference": "e55af3c8aeaeaa2abb5fa47a58a8e9688cc23b59", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.8", + "malukenho/docheader": "^0.1.7", + "phpunit/phpunit": "^6.4" + }, + "time": "2017-12-29T19:39:25+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Respect\\Stringifier\\": "src/" + }, + "files": [ + "src/stringify.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Respect/Stringifier Contributors", + "homepage": "https://github.com/Respect/Stringifier/graphs/contributors" + } + ], + "description": "Converts any value to a string", + "homepage": "http://respect.github.io/Stringifier/", + "keywords": [ + "respect", + "stringifier", + "stringify" + ], + "support": { + "issues": "https://github.com/Respect/Stringifier/issues", + "source": "https://github.com/Respect/Stringifier/tree/0.2.0" + }, + "install-path": "../respect/stringifier" + }, + { + "name": "respect/validation", + "version": "2.2.3", + "version_normalized": "2.2.3.0", + "source": { + "type": "git", + "url": "https://github.com/Respect/Validation.git", + "reference": "4c21a7ffc9a4915673cb2c2843963919e664e627" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Respect/Validation/zipball/4c21a7ffc9a4915673cb2c2843963919e664e627", + "reference": "4c21a7ffc9a4915673cb2c2843963919e664e627", + "shasum": "" + }, + "require": { + "php": "^7.3 || ^8.0", + "respect/stringifier": "^0.2.0", + "symfony/polyfill-mbstring": "^1.2" + }, + "require-dev": { + "egulias/email-validator": "^3.0", + "malukenho/docheader": "^0.1", + "mikey179/vfsstream": "^1.6", + "phpstan/phpstan": "^0.12", + "phpstan/phpstan-deprecation-rules": "^0.12", + "phpstan/phpstan-phpunit": "^0.12", + "phpunit/phpunit": "^9.3", + "psr/http-message": "^1.0", + "respect/coding-standard": "^3.0", + "squizlabs/php_codesniffer": "^3.5", + "symfony/validator": "^3.0||^4.0", + "zendframework/zend-validator": "^2.1" + }, + "suggest": { + "egulias/email-validator": "Strict (RFC compliant) email validation", + "ext-bcmath": "Arbitrary Precision Mathematics", + "ext-fileinfo": "File Information", + "ext-mbstring": "Multibyte String Functions", + "symfony/validator": "Use Symfony validator through Respect\\Validation", + "zendframework/zend-validator": "Use Zend Framework validator through Respect\\Validation" + }, + "time": "2021-03-19T14:12:45+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Respect\\Validation\\": "library/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Respect/Validation Contributors", + "homepage": "https://github.com/Respect/Validation/graphs/contributors" + } + ], + "description": "The most awesome validation engine ever created for PHP", + "homepage": "http://respect.github.io/Validation/", + "keywords": [ + "respect", + "validation", + "validator" + ], + "support": { + "issues": "https://github.com/Respect/Validation/issues", + "source": "https://github.com/Respect/Validation/tree/2.2.3" + }, + "install-path": "../respect/validation" + }, + { + "name": "symfony/deprecation-contracts", + "version": "v2.4.0", + "version_normalized": "2.4.0.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "5f38c8804a9e97d23e0c8d63341088cd8a22d627" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/5f38c8804a9e97d23e0c8d63341088cd8a22d627", + "reference": "5f38c8804a9e97d23e0c8d63341088cd8a22d627", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "time": "2021-03-23T23:28:01+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.4-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "installation-source": "dist", + "autoload": { + "files": [ + "function.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v2.4.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "install-path": "../symfony/deprecation-contracts" + }, + { + "name": "symfony/http-foundation", + "version": "v5.3.7", + "version_normalized": "5.3.7.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/http-foundation.git", + "reference": "e36c8e5502b4f3f0190c675f1c1f1248a64f04e5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/e36c8e5502b4f3f0190c675f1c1f1248a64f04e5", + "reference": "e36c8e5502b4f3f0190c675f1c1f1248a64f04e5", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1", + "symfony/polyfill-mbstring": "~1.1", + "symfony/polyfill-php80": "^1.16" + }, + "require-dev": { + "predis/predis": "~1.0", + "symfony/cache": "^4.4|^5.0", + "symfony/expression-language": "^4.4|^5.0", + "symfony/mime": "^4.4|^5.0" + }, + "suggest": { + "symfony/mime": "To use the file extension guesser" + }, + "time": "2021-08-27T11:20:35+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Symfony\\Component\\HttpFoundation\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Defines an object-oriented layer for the HTTP specification", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/http-foundation/tree/v5.3.7" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "install-path": "../symfony/http-foundation" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.23.0", + "version_normalized": "1.23.0.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/46cd95797e9df938fdd2b03693b5fca5e64b01ce", + "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "time": "2021-02-19T12:13:01+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "support": { + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.23.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "install-path": "../symfony/polyfill-ctype" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.23.1", + "version_normalized": "1.23.1.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "9174a3d80210dca8daa7f31fec659150bbeabfc6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9174a3d80210dca8daa7f31fec659150bbeabfc6", + "reference": "9174a3d80210dca8daa7f31fec659150bbeabfc6", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "time": "2021-05-27T12:26:48+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.23.1" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "install-path": "../symfony/polyfill-mbstring" + }, + { + "name": "symfony/polyfill-php80", + "version": "v1.23.1", + "version_normalized": "1.23.1.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/1100343ed1a92e3a38f9ae122fc0eb21602547be", + "reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "time": "2021-07-28T13:41:28+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php80/tree/v1.23.1" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "install-path": "../symfony/polyfill-php80" + }, + { + "name": "tracy/tracy", + "version": "v2.8.7", + "version_normalized": "2.8.7.0", + "source": { + "type": "git", + "url": "https://github.com/nette/tracy.git", + "reference": "8e708de7c611f626c8792d43f1c78812ea24e6f6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/tracy/zipball/8e708de7c611f626c8792d43f1c78812ea24e6f6", + "reference": "8e708de7c611f626c8792d43f1c78812ea24e6f6", + "shasum": "" + }, + "require": { + "ext-json": "*", + "ext-session": "*", + "php": ">=7.2 <8.2" + }, + "conflict": { + "nette/di": "<3.0" + }, + "require-dev": { + "latte/latte": "^2.5", + "nette/di": "^3.0", + "nette/mail": "^3.0", + "nette/tester": "^2.2", + "nette/utils": "^3.0", + "phpstan/phpstan": "^0.12", + "psr/log": "^1.0" + }, + "time": "2021-08-24T16:26:27+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.8-dev" + } + }, + "installation-source": "dist", + "autoload": { + "classmap": [ + "src" + ], + "files": [ + "src/Tracy/functions.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "https://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "https://nette.org/contributors" + } + ], + "description": "😎 Tracy: the addictive tool to ease debugging PHP code for cool developers. Friendly design, logging, profiler, advanced features like debugging AJAX calls or CLI support. You will love it.", + "homepage": "https://tracy.nette.org", + "keywords": [ + "Xdebug", + "debug", + "debugger", + "nette", + "profiler" + ], + "support": { + "issues": "https://github.com/nette/tracy/issues", + "source": "https://github.com/nette/tracy/tree/v2.8.7" + }, + "install-path": "../tracy/tracy" + }, + { + "name": "verot/class.upload.php", + "version": "2.1.0", + "version_normalized": "2.1.0.0", + "source": { + "type": "git", + "url": "https://github.com/verot/class.upload.php.git", + "reference": "4d9aae875245948d21e42ade332fb45f897f28bb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/verot/class.upload.php/zipball/4d9aae875245948d21e42ade332fb45f897f28bb", + "reference": "4d9aae875245948d21e42ade332fb45f897f28bb", + "shasum": "" + }, + "require": { + "php": ">=5.3" + }, + "time": "2020-12-13T22:26:17+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "classmap": [ + "src/class.upload.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0-only" + ], + "authors": [ + { + "name": "Colin Verot", + "email": "colin@verot.net" + } + ], + "description": "This PHP class uploads files and manipulates images very easily.", + "homepage": "http://www.verot.net/php_class_upload.htm", + "keywords": [ + "gd", + "upload" + ], + "support": { + "email": "colin@verot.net", + "issues": "https://github.com/verot/class.upload.php/issues", + "source": "https://github.com/verot/class.upload.php/tree/2.1.0" + }, + "install-path": "../verot/class.upload.php" + }, + { + "name": "vlucas/phpdotenv", + "version": "v5.3.0", + "version_normalized": "5.3.0.0", + "source": { + "type": "git", + "url": "https://github.com/vlucas/phpdotenv.git", + "reference": "b3eac5c7ac896e52deab4a99068e3f4ab12d9e56" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/b3eac5c7ac896e52deab4a99068e3f4ab12d9e56", + "reference": "b3eac5c7ac896e52deab4a99068e3f4ab12d9e56", + "shasum": "" + }, + "require": { + "ext-pcre": "*", + "graham-campbell/result-type": "^1.0.1", + "php": "^7.1.3 || ^8.0", + "phpoption/phpoption": "^1.7.4", + "symfony/polyfill-ctype": "^1.17", + "symfony/polyfill-mbstring": "^1.17", + "symfony/polyfill-php80": "^1.17" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.4.1", + "ext-filter": "*", + "phpunit/phpunit": "^7.5.20 || ^8.5.14 || ^9.5.1" + }, + "suggest": { + "ext-filter": "Required to use the boolean validator." + }, + "time": "2021-01-20T15:23:13+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.3-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Dotenv\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "graham@alt-three.com", + "homepage": "https://gjcampbell.co.uk/" + }, + { + "name": "Vance Lucas", + "email": "vance@vancelucas.com", + "homepage": "https://vancelucas.com/" + } + ], + "description": "Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.", + "keywords": [ + "dotenv", + "env", + "environment" + ], + "support": { + "issues": "https://github.com/vlucas/phpdotenv/issues", + "source": "https://github.com/vlucas/phpdotenv/tree/v5.3.0" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/vlucas/phpdotenv", + "type": "tidelift" + } + ], + "install-path": "../vlucas/phpdotenv" + } + ], + "dev": true, + "dev-package-names": [] +} diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php new file mode 100644 index 0000000..7265dea --- /dev/null +++ b/vendor/composer/installed.php @@ -0,0 +1,194 @@ + array( + 'pretty_version' => 'dev-master', + 'version' => 'dev-master', + 'type' => 'flare-framework', + 'install_path' => __DIR__ . '/../../', + 'aliases' => array(), + 'reference' => 'fb2feafe8cfe16e4d85325b1c6d5aaa245033949', + 'name' => 'flare-framework/flare', + 'dev' => true, + ), + 'versions' => array( + 'flare-framework/flare' => array( + 'pretty_version' => 'dev-master', + 'version' => 'dev-master', + 'type' => 'flare-framework', + 'install_path' => __DIR__ . '/../../', + 'aliases' => array(), + 'reference' => 'fb2feafe8cfe16e4d85325b1c6d5aaa245033949', + 'dev_requirement' => false, + ), + 'graham-campbell/result-type' => array( + 'pretty_version' => 'v1.0.2', + 'version' => '1.0.2.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../graham-campbell/result-type', + 'aliases' => array(), + 'reference' => '84afea85c6841deeea872f36249a206e878a5de0', + 'dev_requirement' => false, + ), + 'izniburak/router' => array( + 'pretty_version' => 'v2.3.1', + 'version' => '2.3.1.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../izniburak/router', + 'aliases' => array(), + 'reference' => '9d9ce5a2708b1cddae965cf78c5b279355d23646', + 'dev_requirement' => false, + ), + 'league/plates' => array( + 'pretty_version' => 'v3.4.0', + 'version' => '3.4.0.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../league/plates', + 'aliases' => array(), + 'reference' => '6d3ee31199b536a4e003b34a356ca20f6f75496a', + 'dev_requirement' => false, + ), + 'odan/session' => array( + 'pretty_version' => '5.1.0', + 'version' => '5.1.0.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../odan/session', + 'aliases' => array(), + 'reference' => 'df95aeee04dec466172d4c4e0e3ac9245e8182b0', + 'dev_requirement' => false, + ), + 'phpmailer/phpmailer' => array( + 'pretty_version' => 'v6.5.1', + 'version' => '6.5.1.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../phpmailer/phpmailer', + 'aliases' => array(), + 'reference' => 'dd803df5ad7492e1b40637f7ebd258fee5ca7355', + 'dev_requirement' => false, + ), + 'phpoption/phpoption' => array( + 'pretty_version' => '1.8.0', + 'version' => '1.8.0.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../phpoption/phpoption', + 'aliases' => array(), + 'reference' => '5455cb38aed4523f99977c4a12ef19da4bfe2a28', + 'dev_requirement' => false, + ), + 'psr/http-message' => array( + 'pretty_version' => '1.0.1', + 'version' => '1.0.1.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../psr/http-message', + 'aliases' => array(), + 'reference' => 'f6561bf28d520154e4b0ec72be95418abe6d9363', + 'dev_requirement' => false, + ), + 'psr/http-server-handler' => array( + 'pretty_version' => '1.0.1', + 'version' => '1.0.1.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../psr/http-server-handler', + 'aliases' => array(), + 'reference' => 'aff2f80e33b7f026ec96bb42f63242dc50ffcae7', + 'dev_requirement' => false, + ), + 'psr/http-server-middleware' => array( + 'pretty_version' => '1.0.1', + 'version' => '1.0.1.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../psr/http-server-middleware', + 'aliases' => array(), + 'reference' => '2296f45510945530b9dceb8bcedb5cb84d40c5f5', + 'dev_requirement' => false, + ), + 'respect/stringifier' => array( + 'pretty_version' => '0.2.0', + 'version' => '0.2.0.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../respect/stringifier', + 'aliases' => array(), + 'reference' => 'e55af3c8aeaeaa2abb5fa47a58a8e9688cc23b59', + 'dev_requirement' => false, + ), + 'respect/validation' => array( + 'pretty_version' => '2.2.3', + 'version' => '2.2.3.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../respect/validation', + 'aliases' => array(), + 'reference' => '4c21a7ffc9a4915673cb2c2843963919e664e627', + 'dev_requirement' => false, + ), + 'symfony/deprecation-contracts' => array( + 'pretty_version' => 'v2.4.0', + 'version' => '2.4.0.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/deprecation-contracts', + 'aliases' => array(), + 'reference' => '5f38c8804a9e97d23e0c8d63341088cd8a22d627', + 'dev_requirement' => false, + ), + 'symfony/http-foundation' => array( + 'pretty_version' => 'v5.3.7', + 'version' => '5.3.7.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/http-foundation', + 'aliases' => array(), + 'reference' => 'e36c8e5502b4f3f0190c675f1c1f1248a64f04e5', + 'dev_requirement' => false, + ), + 'symfony/polyfill-ctype' => array( + 'pretty_version' => 'v1.23.0', + 'version' => '1.23.0.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/polyfill-ctype', + 'aliases' => array(), + 'reference' => '46cd95797e9df938fdd2b03693b5fca5e64b01ce', + 'dev_requirement' => false, + ), + 'symfony/polyfill-mbstring' => array( + 'pretty_version' => 'v1.23.1', + 'version' => '1.23.1.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/polyfill-mbstring', + 'aliases' => array(), + 'reference' => '9174a3d80210dca8daa7f31fec659150bbeabfc6', + 'dev_requirement' => false, + ), + 'symfony/polyfill-php80' => array( + 'pretty_version' => 'v1.23.1', + 'version' => '1.23.1.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/polyfill-php80', + 'aliases' => array(), + 'reference' => '1100343ed1a92e3a38f9ae122fc0eb21602547be', + 'dev_requirement' => false, + ), + 'tracy/tracy' => array( + 'pretty_version' => 'v2.8.7', + 'version' => '2.8.7.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../tracy/tracy', + 'aliases' => array(), + 'reference' => '8e708de7c611f626c8792d43f1c78812ea24e6f6', + 'dev_requirement' => false, + ), + 'verot/class.upload.php' => array( + 'pretty_version' => '2.1.0', + 'version' => '2.1.0.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../verot/class.upload.php', + 'aliases' => array(), + 'reference' => '4d9aae875245948d21e42ade332fb45f897f28bb', + 'dev_requirement' => false, + ), + 'vlucas/phpdotenv' => array( + 'pretty_version' => 'v5.3.0', + 'version' => '5.3.0.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../vlucas/phpdotenv', + 'aliases' => array(), + 'reference' => 'b3eac5c7ac896e52deab4a99068e3f4ab12d9e56', + 'dev_requirement' => false, + ), + ), +); diff --git a/vendor/composer/platform_check.php b/vendor/composer/platform_check.php new file mode 100644 index 0000000..adfb472 --- /dev/null +++ b/vendor/composer/platform_check.php @@ -0,0 +1,26 @@ += 80000)) { + $issues[] = 'Your Composer dependencies require a PHP version ">= 8.0.0". You are running ' . PHP_VERSION . '.'; +} + +if ($issues) { + if (!headers_sent()) { + header('HTTP/1.1 500 Internal Server Error'); + } + if (!ini_get('display_errors')) { + if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { + fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL); + } elseif (!headers_sent()) { + echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL; + } + } + trigger_error( + 'Composer detected issues in your platform: ' . implode(' ', $issues), + E_USER_ERROR + ); +} diff --git a/vendor/graham-campbell/result-type/LICENSE b/vendor/graham-campbell/result-type/LICENSE new file mode 100644 index 0000000..b99eca4 --- /dev/null +++ b/vendor/graham-campbell/result-type/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2020 Graham Campbell + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/vendor/graham-campbell/result-type/composer.json b/vendor/graham-campbell/result-type/composer.json new file mode 100644 index 0000000..bd1b67e --- /dev/null +++ b/vendor/graham-campbell/result-type/composer.json @@ -0,0 +1,32 @@ +{ + "name": "graham-campbell/result-type", + "description": "An Implementation Of The Result Type", + "keywords": ["result", "result-type", "Result", "Result Type", "Result-Type", "Graham Campbell", "GrahamCampbell"], + "license": "MIT", + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk" + } + ], + "require": { + "php": "^7.0 || ^8.0", + "phpoption/phpoption": "^1.8" + }, + "require-dev": { + "phpunit/phpunit": "^6.5.14 || ^7.5.20 || ^8.5.19 || ^9.5.8" + }, + "autoload": { + "psr-4": { + "GrahamCampbell\\ResultType\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "GrahamCampbell\\Tests\\ResultType\\": "tests/" + } + }, + "config": { + "preferred-install": "dist" + } +} diff --git a/vendor/graham-campbell/result-type/src/Error.php b/vendor/graham-campbell/result-type/src/Error.php new file mode 100644 index 0000000..dba6d79 --- /dev/null +++ b/vendor/graham-campbell/result-type/src/Error.php @@ -0,0 +1,120 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace GrahamCampbell\ResultType; + +use PhpOption\None; +use PhpOption\Some; + +/** + * @template T + * @template E + * @extends \GrahamCampbell\ResultType\Result + */ +final class Error extends Result +{ + /** + * @var E + */ + private $value; + + /** + * Internal constructor for an error value. + * + * @param E $value + * + * @return void + */ + private function __construct($value) + { + $this->value = $value; + } + + /** + * Create a new error value. + * + * @template F + * + * @param F $value + * + * @return \GrahamCampbell\ResultType\Result + */ + public static function create($value) + { + return new self($value); + } + + /** + * Get the success option value. + * + * @return \PhpOption\Option + */ + public function success() + { + return None::create(); + } + + /** + * Map over the success value. + * + * @template S + * + * @param callable(T):S $f + * + * @return \GrahamCampbell\ResultType\Result + */ + public function map(callable $f) + { + return self::create($this->value); + } + + /** + * Flat map over the success value. + * + * @template S + * @template F + * + * @param callable(T):\GrahamCampbell\ResultType\Result $f + * + * @return \GrahamCampbell\ResultType\Result + */ + public function flatMap(callable $f) + { + /** @var \GrahamCampbell\ResultType\Result */ + return self::create($this->value); + } + + /** + * Get the error option value. + * + * @return \PhpOption\Option + */ + public function error() + { + return Some::create($this->value); + } + + /** + * Map over the error value. + * + * @template F + * + * @param callable(E):F $f + * + * @return \GrahamCampbell\ResultType\Result + */ + public function mapError(callable $f) + { + return self::create($f($this->value)); + } +} diff --git a/vendor/graham-campbell/result-type/src/Result.php b/vendor/graham-campbell/result-type/src/Result.php new file mode 100644 index 0000000..485fa08 --- /dev/null +++ b/vendor/graham-campbell/result-type/src/Result.php @@ -0,0 +1,69 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace GrahamCampbell\ResultType; + +/** + * @template T + * @template E + */ +abstract class Result +{ + /** + * Get the success option value. + * + * @return \PhpOption\Option + */ + abstract public function success(); + + /** + * Map over the success value. + * + * @template S + * + * @param callable(T):S $f + * + * @return \GrahamCampbell\ResultType\Result + */ + abstract public function map(callable $f); + + /** + * Flat map over the success value. + * + * @template S + * @template F + * + * @param callable(T):\GrahamCampbell\ResultType\Result $f + * + * @return \GrahamCampbell\ResultType\Result + */ + abstract public function flatMap(callable $f); + + /** + * Get the error option value. + * + * @return \PhpOption\Option + */ + abstract public function error(); + + /** + * Map over the error value. + * + * @template F + * + * @param callable(E):F $f + * + * @return \GrahamCampbell\ResultType\Result + */ + abstract public function mapError(callable $f); +} diff --git a/vendor/graham-campbell/result-type/src/Success.php b/vendor/graham-campbell/result-type/src/Success.php new file mode 100644 index 0000000..1cb0866 --- /dev/null +++ b/vendor/graham-campbell/result-type/src/Success.php @@ -0,0 +1,119 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace GrahamCampbell\ResultType; + +use PhpOption\None; +use PhpOption\Some; + +/** + * @template T + * @template E + * @extends \GrahamCampbell\ResultType\Result + */ +final class Success extends Result +{ + /** + * @var T + */ + private $value; + + /** + * Internal constructor for a success value. + * + * @param T $value + * + * @return void + */ + private function __construct($value) + { + $this->value = $value; + } + + /** + * Create a new error value. + * + * @template S + * + * @param S $value + * + * @return \GrahamCampbell\ResultType\Result + */ + public static function create($value) + { + return new self($value); + } + + /** + * Get the success option value. + * + * @return \PhpOption\Option + */ + public function success() + { + return Some::create($this->value); + } + + /** + * Map over the success value. + * + * @template S + * + * @param callable(T):S $f + * + * @return \GrahamCampbell\ResultType\Result + */ + public function map(callable $f) + { + return self::create($f($this->value)); + } + + /** + * Flat map over the success value. + * + * @template S + * @template F + * + * @param callable(T):\GrahamCampbell\ResultType\Result $f + * + * @return \GrahamCampbell\ResultType\Result + */ + public function flatMap(callable $f) + { + return $f($this->value); + } + + /** + * Get the error option value. + * + * @return \PhpOption\Option + */ + public function error() + { + return None::create(); + } + + /** + * Map over the error value. + * + * @template F + * + * @param callable(E):F $f + * + * @return \GrahamCampbell\ResultType\Result + */ + public function mapError(callable $f) + { + return self::create($this->value); + } +} diff --git a/vendor/izniburak/router/.gitignore b/vendor/izniburak/router/.gitignore new file mode 100644 index 0000000..ed19770 --- /dev/null +++ b/vendor/izniburak/router/.gitignore @@ -0,0 +1,8 @@ +/.git/ +/.DS_Store +/composer.lock +/vendor/ +/index.php +/.htaccess +.idea + diff --git a/vendor/izniburak/router/.travis.yml b/vendor/izniburak/router/.travis.yml new file mode 100644 index 0000000..d4982af --- /dev/null +++ b/vendor/izniburak/router/.travis.yml @@ -0,0 +1,36 @@ +language: php + +matrix: + include: + - php: 5.5 + dist: trusty + - php: 5.6 + - php: 7.0 + - php: 7.1 + - php: 7.2 + - php: 7.3 + - php: 7.4 + +sudo: required + +install: + - composer install + +before_script: + - sudo apt-get update + - sudo apt-get install -y apache2 libapache2-mod-fastcgi + # enable php-fpm + - if [[ ${TRAVIS_PHP_VERSION:0:1} == "7" ]]; then sudo cp tests/fixtures/www.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf; fi + - if [[ ${TRAVIS_PHP_VERSION:0:1} == "5" ]]; then sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf; fi + - sudo a2enmod rewrite actions fastcgi alias + - echo "cgi.fix_pathinfo = 1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini + - sudo sed -i -e "s,www-data,travis,g" /etc/apache2/envvars + - sudo chown -R travis:travis /var/lib/apache2/fastcgi + - ~/.phpenv/versions/$(phpenv version-name)/sbin/php-fpm + # configure apache virtual hosts + - sudo cp -f tests/fixtures/travis-ci-apache /etc/apache2/sites-available/000-default.conf + - sudo sed -e "s?%TRAVIS_BUILD_DIR%?$(pwd)?g" --in-place /etc/apache2/sites-available/000-default.conf + - sudo service apache2 restart + +script: + - vendor/bin/phpunit diff --git a/vendor/izniburak/router/LICENCE.md b/vendor/izniburak/router/LICENCE.md new file mode 100644 index 0000000..bb6ae43 --- /dev/null +++ b/vendor/izniburak/router/LICENCE.md @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016, İzni Burak Demirtaş + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/vendor/izniburak/router/README.md b/vendor/izniburak/router/README.md new file mode 100644 index 0000000..ac2398a --- /dev/null +++ b/vendor/izniburak/router/README.md @@ -0,0 +1,110 @@ +## Router +``` + _____ _ _ _____ _____ _ + | __ \| | | | __ \ | __ \ | | + | |__) | |__| | |__) | ______ | |__) |___ _ _| |_ ___ _ __ + | ___/| __ | ___/ |______| | _ // _ \| | | | __/ _ \ '__| + | | | | | | | | | \ \ (_) | |_| | || __/ | + |_| |_| |_|_| |_| \_\___/ \__,_|\__\___|_| + +``` +simple Router class for PHP. with the support of Controllers and Middlewares. + +[![Total Downloads](https://poser.pugx.org/izniburak/router/d/total.svg)](https://packagist.org/packages/izniburak/router) +[![Latest Stable Version](https://poser.pugx.org/izniburak/router/v/stable.svg)](https://packagist.org/packages/izniburak/router) +[![Latest Unstable Version](https://poser.pugx.org/izniburak/router/v/unstable.svg)](https://packagist.org/packages/izniburak/router) +[![License](https://poser.pugx.org/izniburak/router/license.svg)](https://packagist.org/packages/izniburak/router) + +### Features +- Supports GET, POST, PUT, DELETE, OPTIONS, PATCH, HEAD, AJAX and ANY request methods +- Easy access and manage Request and Response via `symfony/http-foundation` package. +- Controllers support (Example: HomeController@about) +- Before and after Route Middlewares support +- Static Route Patterns +- Dynamic Route Patterns +- Easy-to-use patterns +- Adding a new pattern supports. (with RegExp) +- Namespaces supports. +- Group Routing +- Custom 404 handling +- Debug mode (Error message open/close) + +## Install + +composer.json file: +```json +{ + "require": { + "izniburak/router": "^2.0" + } +} +``` +after run the install command. +``` +$ composer install +``` + +OR run the following command directly. + +``` +$ composer require izniburak/router +``` + +## Example Usage +```php +require 'vendor/autoload.php'; + +use Buki\Router\Router; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; + +$router = new Router; + +// For basic GET URI +$router->get('/', function(Request $request, Response $response) { + $response->setContent('Hello World'); + return $response; + + # OR + # return 'Hello World!'; +}); + +// For basic GET URI by using a Controller class. +$router->get('/test', 'TestController@main'); + +// For auto discovering all methods and URIs +$router->controller('/users', 'UserController'); + +$router->run(); +``` + +## Docs +Documentation page: [Buki\Router Docs][doc-url] + +Changelogs: [Buki\Router Changelogs][changelog-url] + +## Support +[izniburak's homepage][author-url] + +[izniburak's twitter][twitter-url] + +## Licence +[MIT Licence][mit-url] + +## Contributing + +1. Fork it ( https://github.com/izniburak/php-router/fork ) +2. Create your feature branch (git checkout -b my-new-feature) +3. Commit your changes (git commit -am 'Add some feature') +4. Push to the branch (git push origin my-new-feature) +5. Create a new Pull Request + +## Contributors + +- [izniburak](https://github.com/izniburak) İzni Burak Demirtaş - creator, maintainer + +[mit-url]: http://opensource.org/licenses/MIT +[doc-url]: https://github.com/izniburak/php-router/wiki +[changelog-url]: https://github.com/izniburak/php-router/wiki/Changelogs +[author-url]: http://burakdemirtas.org +[twitter-url]: https://twitter.com/izniburak diff --git a/vendor/izniburak/router/composer.json b/vendor/izniburak/router/composer.json new file mode 100644 index 0000000..ff50399 --- /dev/null +++ b/vendor/izniburak/router/composer.json @@ -0,0 +1,40 @@ +{ + "name": "izniburak/router", + "type": "library", + "description": "simple router class for php", + "keywords": [ + "router", + "route", + "routing" + ], + "homepage": "https://github.com/izniburak/php-router", + "license": "MIT", + "authors": [ + { + "name": "İzni Burak Demirtaş", + "email": "info@burakdemirtas.org", + "homepage": "https://burakdemirtas.org" + } + ], + "require": { + "php": ">=7.2.5", + "ext-json": "*", + "symfony/http-foundation": "^5.1" + }, + "require-dev": { + "phpunit/phpunit": "^8.5 || ^9.4", + "guzzlehttp/guzzle": "^7.2" + }, + "autoload": { + "psr-4": { + "Buki\\Router\\": "src" + } + }, + "autoload-dev": { + "psr-4": { + "Buki\\Tests\\": "tests/" + } + }, + "minimum-stability": "dev", + "prefer-stable": true +} diff --git a/vendor/izniburak/router/phpunit.xml.dist b/vendor/izniburak/router/phpunit.xml.dist new file mode 100644 index 0000000..a09f7f0 --- /dev/null +++ b/vendor/izniburak/router/phpunit.xml.dist @@ -0,0 +1,26 @@ + + + + + + + tests/ + + + + + + src/ + + + + diff --git a/vendor/izniburak/router/src/Http/Controller.php b/vendor/izniburak/router/src/Http/Controller.php new file mode 100644 index 0000000..5a88f92 --- /dev/null +++ b/vendor/izniburak/router/src/Http/Controller.php @@ -0,0 +1,16 @@ + + * @Web : https://burakdemirtas.org + * @URL : https://github.com/izniburak/php-router + * @Licence: The MIT License (MIT) - Copyright (c) - http://opensource.org/licenses/MIT + */ + +namespace Buki\Router; + +use Closure; +use Exception; +use ReflectionMethod; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; + +/** + * Class Router + * + * @method $this any($route, $callback, array $options = []) + * @method $this get($route, $callback, array $options = []) + * @method $this post($route, $callback, array $options = []) + * @method $this put($route, $callback, array $options = []) + * @method $this delete($route, $callback, array $options = []) + * @method $this patch($route, $callback, array $options = []) + * @method $this head($route, $callback, array $options = []) + * @method $this options($route, $callback, array $options = []) + * @method $this ajax($route, $callback, array $options = []) + * @method $this xpost($route, $callback, array $options = []) + * @method $this xput($route, $callback, array $options = []) + * @method $this xdelete($route, $callback, array $options = []) + * @method $this xpatch($route, $callback, array $options = []) + * + * @package Buki + */ +class Router +{ + /** + * Router Version + */ + const VERSION = '2.3.0'; + + /** + * @var string $baseFolder Pattern definitions for parameters of Route + */ + protected $baseFolder; + + /** + * @var array $routes Routes list + */ + protected $routes = []; + + /** + * @var array $groups List of group routes + */ + protected $groups = []; + + /** + * @var array $patterns Pattern definitions for parameters of Route + */ + protected $patterns = [ + ':all' => '(.*)', + ':any' => '([^/]+)', + ':id' => '(\d+)', + ':int' => '(\d+)', + ':number' => '([+-]?([0-9]*[.])?[0-9]+)', + ':float' => '([+-]?([0-9]*[.])?[0-9]+)', + ':bool' => '(true|false|1|0)', + ':string' => '([\w\-_]+)', + ':slug' => '([\w\-_]+)', + ':uuid' => '([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})', + ':date' => '([0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1]))', + ]; + + /** + * @var array $namespaces Namespaces of Controllers and Middlewares files + */ + protected $namespaces = [ + 'middlewares' => '', + 'controllers' => '', + ]; + + /** + * @var array $path Paths of Controllers and Middlewares files + */ + protected $paths = [ + 'controllers' => 'Controllers', + 'middlewares' => 'Middlewares', + ]; + + /** + * @var string $mainMethod Main method for controller + */ + protected $mainMethod = 'main'; + + /** + * @var string $cacheFile Cache file + */ + protected $cacheFile = null; + + /** + * @var bool $cacheLoaded Cache is loaded? + */ + protected $cacheLoaded = false; + + /** + * @var Closure $errorCallback Route error callback function + */ + protected $errorCallback; + + /** + * @var array $middlewares General middlewares for per request + */ + protected $middlewares = []; + + /** + * @var array $routeMiddlewares Route middlewares + */ + protected $routeMiddlewares = []; + + /** + * @var array $middlewareGroups Middleware Groups + */ + protected $middlewareGroups = []; + + /** + * @var RouterRequest + */ + private $request; + + /** + * Router constructor method. + * + * @param array $params + * @param Request|null $request + * @param Response|null $response + */ + public function __construct(array $params = [], Request $request = null, Response $response = null) + { + $this->baseFolder = realpath(getcwd()); + + if (isset($params['debug']) && is_bool($params['debug'])) { + RouterException::$debug = $params['debug']; + } + + // RouterRequest + $request = $request ?? Request::createFromGlobals(); + $response = $response ?? new Response('', Response::HTTP_OK, ['content-type' => 'text/html']); + $this->request = new RouterRequest($request, $response); + + $this->setPaths($params); + $this->loadCache(); + } + + /** + * Add route method; + * Get, Post, Put, Delete, Patch, Any, Ajax... + * + * @param $method + * @param $params + * + * @return mixed + * @throws + */ + public function __call($method, $params) + { + if ($this->cacheLoaded) { + return true; + } + + if (is_null($params)) { + return false; + } + + if (!in_array(strtoupper($method), explode('|', $this->request->validMethods()))) { + return $this->exception("Method is not valid. [{$method}]"); + } + + [$route, $callback] = $params; + $options = $params[2] ?? null; + if (strstr($route, ':')) { + $route1 = $route2 = ''; + foreach (explode('/', $route) as $key => $value) { + if ($value != '') { + if (!strpos($value, '?')) { + $route1 .= '/' . $value; + } else { + if ($route2 == '') { + $this->addRoute($route1, $method, $callback, $options); + } + + $route2 = $route1 . '/' . str_replace('?', '', $value); + $this->addRoute($route2, $method, $callback, $options); + $route1 = $route2; + } + } + } + + if ($route2 == '') { + $this->addRoute($route1, $method, $callback, $options); + } + } else { + $this->addRoute($route, $method, $callback, $options); + } + + return $this; + } + + /** + * Add new route method one or more http methods. + * + * @param string $methods + * @param string $route + * @param string|closure $callback + * @param array $options + * + * @return bool + */ + public function add(string $methods, string $route, $callback, array $options = []) + { + if ($this->cacheLoaded) { + return true; + } + + if (strstr($methods, '|')) { + foreach (array_unique(explode('|', $methods)) as $method) { + if (!empty($method)) { + $this->addRoute($route, $method, $callback, $options); + } + } + } else { + $this->addRoute($route, $methods, $callback, $options); + } + + return true; + } + + /** + * Add new route rules pattern; String or Array + * + * @param string|array $pattern + * @param null|string $attr + * + * @return mixed + * @throws + */ + public function pattern($pattern, $attr = null) + { + if (is_array($pattern)) { + foreach ($pattern as $key => $value) { + if (in_array($key, array_keys($this->patterns))) { + return $this->exception($key . ' pattern cannot be changed.'); + } + $this->patterns[$key] = '(' . $value . ')'; + } + } else { + if (in_array($pattern, array_keys($this->patterns))) { + return $this->exception($pattern . ' pattern cannot be changed.'); + } + $this->patterns[$pattern] = '(' . $attr . ')'; + } + + return true; + } + + /** + * Run Routes + * + * @return void + * @throws + */ + public function run(): void + { + $uri = $this->getRequestUri(); + $method = $this->request->getMethod(); + $searches = array_keys($this->patterns); + $replaces = array_values($this->patterns); + $foundRoute = false; + + foreach ($this->routes as $data) { + $route = $data['route']; + if (!$this->request->validMethod($data['method'], $method)) { + continue; + } + + // Direct Route Match + if ($route === $uri) { + $foundRoute = true; + $this->runRouteMiddleware($data, 'before'); + $this->runRouteCommand($data['callback']); + $this->runRouteMiddleware($data, 'after'); + break; + + // Parameter Route Match + } elseif (strstr($route, ':') !== false) { + $route = str_replace($searches, $replaces, $route); + if (preg_match('#^' . $route . '$#', $uri, $matched)) { + $foundRoute = true; + $this->runRouteMiddleware($data, 'before'); + array_shift($matched); + $matched = array_map(function ($value) { + return trim(urldecode($value)); + }, $matched); + $this->runRouteCommand($data['callback'], $matched); + $this->runRouteMiddleware($data, 'after'); + break; + } + } + } + + // If it originally was a HEAD request, clean up after ourselves by emptying the output buffer + if ($this->request()->isMethod('HEAD')) { + ob_end_clean(); + } + + if ($foundRoute === false) { + if (!$this->errorCallback) { + $this->errorCallback = function () { + $this->response() + ->setStatusCode(Response::HTTP_NOT_FOUND) + ->sendHeaders(); + return $this->exception('Looks like page not found or something went wrong. Please try again.'); + }; + } + call_user_func($this->errorCallback); + } + } + + /** + * Routes Group + * + * @param string $prefix + * @param closure $callback + * @param array $options + * + * @return bool + */ + public function group(string $prefix, Closure $callback, array $options = []): bool + { + if ($this->cacheLoaded) { + return true; + } + + $group = []; + $group['route'] = $this->clearRouteName($prefix); + $group['before'] = $this->calculateMiddleware($options['before'] ?? []); + $group['after'] = $this->calculateMiddleware($options['after'] ?? []); + + array_push($this->groups, $group); + + if (is_object($callback)) { + call_user_func_array($callback, [$this]); + } + + $this->endGroup(); + + return true; + } + + /** + * Added route from methods of Controller file. + * + * @param string $route + * @param string $controller + * @param array $options + * + * @return mixed + * @throws + */ + public function controller(string $route, string $controller, array $options = []) + { + if ($this->cacheLoaded) { + return true; + } + + $only = $options['only'] ?? []; + $except = $options['except'] ?? []; + $controller = $this->resolveClassName($controller); + $classMethods = get_class_methods($controller); + if ($classMethods) { + foreach ($classMethods as $methodName) { + if (!strstr($methodName, '__')) { + $method = 'any'; + foreach (explode('|', $this->request->validMethods()) as $m) { + if (stripos($methodName, $m = strtolower($m), 0) === 0) { + $method = $m; + break; + } + } + + $methodVar = lcfirst( + preg_replace('/' . $method . '_?/i', '', $methodName, 1) + ); + $methodVar = strtolower(preg_replace('%([a-z]|[0-9])([A-Z])%', '\1-\2', $methodVar)); + + if ((!empty($only) && !in_array($methodVar, $only)) + || (!empty($except) && in_array($methodVar, $except))) { + continue; + } + + $ref = new ReflectionMethod($controller, $methodName); + $endpoints = []; + foreach ($ref->getParameters() as $param) { + $typeHint = $param->hasType() ? $param->getType()->getName() : null; + if (!in_array($typeHint, ['int', 'float', 'string', 'bool']) && $typeHint !== null) { + continue; + } + $pattern = isset($this->patterns[":{$typeHint}"]) ? ":{$typeHint}" : ":any"; + $endpoints[] = $param->isOptional() ? "{$pattern}?" : $pattern; + } + + $value = ($methodVar === $this->mainMethod ? $route : $route . '/' . $methodVar); + $this->{$method}( + ($value . '/' . implode('/', $endpoints)), + ($controller . '@' . $methodName), + $options + ); + } + } + unset($ref); + } + + return true; + } + + /** + * Routes error function. + * + * @param Closure $callback + * + * @return void + */ + public function error(Closure $callback): void + { + $this->errorCallback = $callback; + } + + /** + * Display all Routes. + * + * @return void + */ + public function getList(): void + { + $routes = var_export($this->getRoutes(), true); + die("
{$routes}
"); + } + + /** + * Get all Routes + * + * @return array + */ + public function getRoutes(): array + { + return $this->routes; + } + + /** + * Cache all routes + * + * @return bool + * + * @throws Exception + */ + public function cache(): bool + { + foreach ($this->getRoutes() as $key => $route) { + if (!is_string($route['callback'])) { + throw new Exception(sprintf('Routes cannot contain a Closure/Function callback while caching.')); + } + } + + $cacheContent = 'getRoutes(), true) . ';' . PHP_EOL; + if (false === file_put_contents($this->cacheFile, $cacheContent)) { + throw new Exception(sprintf('Routes cache file could not be written.')); + } + + return true; + } + + /** + * Set general middlewares + * + * @param array $middlewares + * + * @return void + */ + public function setMiddleware(array $middlewares): void + { + $this->middlewares = $middlewares; + } + + /** + * Set Route middlewares + * + * @param array $middlewares + * + * @return void + */ + public function setRouteMiddleware(array $middlewares): void + { + $this->routeMiddlewares = $middlewares; + } + + /** + * Set middleware groups + * + * @param array $middlewareGroup + * + * @return void + */ + public function setMiddlewareGroup(array $middlewareGroup): void + { + $this->middlewareGroups = $middlewareGroup; + } + + /** + * Get All Middlewares + * + * @return array + */ + public function getMiddlewares(): array + { + return [ + 'middlewares' => $this->middlewares, + 'routeMiddlewares' => $this->routeMiddlewares, + 'middlewareGroups' => $this->middlewareGroups, + ]; + } + + /** + * Detect Routes Middleware; before or after + * + * @param array $middleware + * @param string $type + * + * @return void + */ + protected function runRouteMiddleware(array $middleware, string $type): void + { + $this->routerCommand()->beforeAfter($middleware[$type]); + } + + /** + * @return Request + */ + protected function request(): Request + { + return $this->request->symfonyRequest(); + } + + /** + * @return Response + */ + protected function response(): Response + { + return $this->request->symfonyResponse(); + } + + /** + * Throw new Exception for Router Error + * + * @param string $message + * @param int $statusCode + * + * @return RouterException + * @throws Exception + */ + protected function exception($message = '', int $statusCode = 500): RouterException + { + return new RouterException($message, $statusCode); + } + + /** + * RouterCommand class + * + * @return RouterCommand + */ + protected function routerCommand(): RouterCommand + { + return RouterCommand::getInstance( + $this->baseFolder, $this->paths, $this->namespaces, + $this->request(), $this->response(), + $this->getMiddlewares() + ); + } + + /** + * Set paths and namespaces for Controllers and Middlewares. + * + * @param array $params + * + * @return void + */ + protected function setPaths(array $params): void + { + if (empty($params)) { + return; + } + + if (isset($params['paths']) && $paths = $params['paths']) { + $this->paths['controllers'] = isset($paths['controllers']) + ? trim($paths['controllers'], '/') + : $this->paths['controllers']; + + $this->paths['middlewares'] = isset($paths['middlewares']) + ? trim($paths['middlewares'], '/') + : $this->paths['middlewares']; + } + + if (isset($params['namespaces']) && $namespaces = $params['namespaces']) { + $this->namespaces['controllers'] = isset($namespaces['controllers']) + ? trim($namespaces['controllers'], '\\') . '\\' + : ''; + + $this->namespaces['middlewares'] = isset($namespaces['middlewares']) + ? trim($namespaces['middlewares'], '\\') . '\\' + : ''; + } + + if (isset($params['base_folder'])) { + $this->baseFolder = rtrim($params['base_folder'], '/'); + } + + if (isset($params['main_method'])) { + $this->mainMethod = $params['main_method']; + } + + $this->cacheFile = isset($params['cache']) ? $params['cache'] : realpath(__DIR__ . '/../cache.php'); + } + + /** + * @param string $controller + * + * @return RouterException|string + */ + protected function resolveClassName(string $controller) + { + $controller = str_replace([$this->namespaces['controllers'], '\\', '.'], ['', '/', '/'], $controller); + $controller = trim( + preg_replace( + '/' . str_replace('/', '\\/', $this->paths['controllers']) . '/i', + '', + $controller, + 1 + ), + '/' + ); + + $file = realpath("{$this->paths['controllers']}/{$controller}.php"); + if (!file_exists($file)) { + return $this->exception("{$controller} class is not found! Please check the file."); + } + + $controller = $this->namespaces['controllers'] . str_replace('/', '\\', $controller); + if (!class_exists($controller)) { + require_once $file; + } + + return $controller; + } + + /** + * Load Cache file + * + * @return bool + */ + protected function loadCache(): bool + { + if (file_exists($this->cacheFile)) { + $this->routes = require_once $this->cacheFile; + $this->cacheLoaded = true; + return true; + } + + return false; + } + + /** + * Add new Route and it's settings + * + * @param string $uri + * @param string $method + * @param $callback + * @param array $options + * + * @return void + */ + protected function addRoute(string $uri, string $method, $callback, $options = []) + { + $groupUri = ''; + $beforeMiddlewares = []; + $afterMiddlewares = []; + if (!empty($this->groups)) { + foreach ($this->groups as $key => $value) { + $groupUri .= $value['route']; + $beforeMiddlewares = array_merge($beforeMiddlewares, $value['before']); + $afterMiddlewares = array_merge($afterMiddlewares, $value['after']); + } + } + + $beforeMiddlewares = array_merge($beforeMiddlewares, $this->calculateMiddleware($options['before'] ?? [])); + $afterMiddlewares = array_merge($afterMiddlewares, $this->calculateMiddleware($options['after'] ?? [])); + + $callback = is_array($callback) ? implode('@', $callback) : $callback; + $routeName = is_string($callback) + ? strtolower(preg_replace( + '/[^\w]/i', '.', str_replace($this->namespaces['controllers'], '', $callback) + )) + : null; + $data = [ + 'route' => $this->clearRouteName("{$groupUri}/{$uri}"), + 'method' => strtoupper($method), + 'callback' => $callback, + 'name' => $options['name'] ?? $routeName, + 'before' => $beforeMiddlewares, + 'after' => $afterMiddlewares, + ]; + array_unshift($this->routes, $data); + } + + /** + * @param array|string $middleware + * + * @return array + */ + protected function calculateMiddleware($middleware): array + { + if (is_null($middleware)) { + return []; + } + + return is_array($middleware) ? $middleware : [$middleware]; + } + + /** + * Run Route Command; Controller or Closure + * + * @param $command + * @param $params + * + * @return void + */ + protected function runRouteCommand($command, $params = []) + { + $this->routerCommand()->runRoute($command, $params); + } + + /** + * Routes Group endpoint + * + * @return void + */ + protected function endGroup(): void + { + array_pop($this->groups); + } + + /** + * @param string $route + * + * @return string + */ + protected function clearRouteName(string $route = ''): string + { + $route = trim(preg_replace('~/{2,}~', '/', $route), '/'); + return $route === '' ? '/' : "/{$route}"; + } + + /** + * @return string + */ + protected function getRequestUri(): string + { + $script = $this->request()->server->get('SCRIPT_NAME'); + $dirname = dirname($script); + $dirname = $dirname === '/' ? '' : $dirname; + $basename = basename($script); + $uri = str_replace([$dirname, $basename], null, $this->request()->server->get('REQUEST_URI')); + return $this->clearRouteName(explode('?', $uri)[0]); + } +} diff --git a/vendor/izniburak/router/src/RouterCommand.php b/vendor/izniburak/router/src/RouterCommand.php new file mode 100644 index 0000000..2d36354 --- /dev/null +++ b/vendor/izniburak/router/src/RouterCommand.php @@ -0,0 +1,389 @@ +baseFolder = $baseFolder; + $this->paths = $paths; + $this->namespaces = $namespaces; + $this->request = $request; + $this->response = $response; + $this->middlewares = $middlewares; + + // Execute general Middlewares + foreach ($this->middlewares['middlewares'] as $middleware) { + $this->beforeAfter($middleware); + } + + } + + /** + * @return array + */ + public function getMiddlewareInfo(): array + { + return [ + 'path' => "{$this->baseFolder}/{$this->paths['middlewares']}", + 'namespace' => $this->namespaces['middlewares'], + ]; + } + + /** + * @return array + */ + public function getControllerInfo(): array + { + return [ + 'path' => "{$this->baseFolder}/{$this->paths['controllers']}", + 'namespace' => $this->namespaces['controllers'], + ]; + } + + /** + * @param string $baseFolder + * @param array $paths + * @param array $namespaces + * @param Request $request + * @param Response $response + * @param array $middlewares + * + * @return RouterCommand + */ + public static function getInstance( + string $baseFolder, + array $paths, + array $namespaces, + Request $request, + Response $response, + array $middlewares + ) { + if (null === self::$instance) { + self::$instance = new static( + $baseFolder, $paths, $namespaces, + $request, $response, $middlewares + ); + } + + return self::$instance; + } + + /** + * Run Route Middlewares + * + * @param $command + * + * @return mixed|void + * @throws + */ + public function beforeAfter($command) + { + if (empty($command)) { + return; + } + + $info = $this->getMiddlewareInfo(); + if (is_array($command)) { + foreach ($command as $value) { + $this->beforeAfter($value); + } + } elseif (is_string($command)) { + $middleware = explode(':', $command); + $params = []; + if (count($middleware) > 1) { + $params = explode(',', $middleware[1]); + } + + $resolvedMiddleware = $this->resolveMiddleware($middleware[0]); + $response = false; + if (is_array($resolvedMiddleware)) { + foreach ($resolvedMiddleware as $middleware) { + $response = $this->runMiddleware( + $command, + $this->resolveMiddleware($middleware), + $params, + $info + ); + } + return $response; + } + + return $this->runMiddleware($command, $resolvedMiddleware, $params, $info); + } + + return; + } + + /** + * Run Route Command; Controller or Closure + * + * @param $command + * @param $params + * + * @return mixed|void + * @throws + */ + public function runRoute($command, $params = []) + { + $info = $this->getControllerInfo(); + if (!is_object($command)) { + [$class, $method] = explode('@', $command); + $class = str_replace([$info['namespace'], '\\', '.'], ['', '/', '/'], $class); + + $controller = $this->resolveClass($class, $info['path'], $info['namespace']); + if (!method_exists($controller, $method)) { + return $this->exception("{$method} method is not found in {$class} class."); + } + + if (property_exists($controller, 'middlewareBefore') && is_array($controller->middlewareBefore)) { + foreach ($controller->middlewareBefore as $middleware) { + $this->beforeAfter($middleware); + } + } + + $response = $this->runMethodWithParams([$controller, $method], $params); + + if (property_exists($controller, 'middlewareAfter') && is_array($controller->middlewareAfter)) { + foreach ($controller->middlewareAfter as $middleware) { + $this->beforeAfter($middleware); + } + } + + return $response; + } + + return $this->runMethodWithParams($command, $params); + } + + /** + * Resolve Controller or Middleware class. + * + * @param string $class + * @param string $path + * @param string $namespace + * + * @return object + * @throws + */ + protected function resolveClass(string $class, string $path, string $namespace) + { + $class = str_replace([$namespace, '\\'], ['', '/'], $class); + $file = realpath("{$path}/{$class}.php"); + if (!file_exists($file)) { + return $this->exception("{$class} class is not found. Please check the file."); + } + + $class = $namespace . str_replace('/', '\\', $class); + if (!class_exists($class)) { + require_once($file); + } + + return new $class(); + } + + /** + * @param array|Closure $function + * @param array $params + * + * @return Response|mixed + * @throws ReflectionException + */ + protected function runMethodWithParams($function, array $params) + { + $reflection = is_array($function) + ? new ReflectionMethod($function[0], $function[1]) + : new ReflectionFunction($function); + $parameters = $this->resolveCallbackParameters($reflection, $params); + $response = call_user_func_array($function, $parameters); + return $this->sendResponse($response); + } + + /** + * @param Reflector $reflection + * @param array $uriParams + * + * @return array + * @throws + */ + protected function resolveCallbackParameters(Reflector $reflection, array $uriParams): array + { + $parameters = []; + foreach ($reflection->getParameters() as $key => $param) { + $class = $param->getType() && !$param->getType()->isBuiltin() + ? new ReflectionClass($param->getType()->getName()) + : null; + if (!is_null($class) && $class->isInstance($this->request)) { + $parameters[] = $this->request; + } elseif (!is_null($class) && $class->isInstance($this->response)) { + $parameters[] = $this->response; + } elseif (!is_null($class)) { + $parameters[] = null; + } else { + if (empty($uriParams)) { + continue; + } + $uriParams = array_reverse($uriParams); + $parameters[] = array_pop($uriParams); + $uriParams = array_reverse($uriParams); + } + } + + return $parameters; + } + + /** + * @param $command + * @param $middleware + * @param $params + * @param $info + * + * @return bool|RouterException + * @throws ReflectionException + */ + protected function runMiddleware(string $command, string $middleware, array $params, array $info) + { + $middlewareMethod = 'handle'; // For now, it's constant. + $controller = $this->resolveClass($middleware, $info['path'], $info['namespace']); + + if (in_array($className = get_class($controller), $this->markedMiddlewares)) { + return true; + } + array_push($this->markedMiddlewares, $className); + + if (!method_exists($controller, $middlewareMethod)) { + return $this->exception("{$middlewareMethod}() method is not found in {$middleware} class."); + } + + $parameters = $this->resolveCallbackParameters(new ReflectionMethod($controller, $middlewareMethod), $params); + $response = call_user_func_array([$controller, $middlewareMethod], $parameters); + if ($response !== true) { + $this->sendResponse($response); + exit; + } + + return $response; + } + + /** + * @param string $middleware + * + * @return array|string + */ + protected function resolveMiddleware(string $middleware) + { + $middlewares = $this->middlewares; + if (isset($middlewares['middlewareGroups'][$middleware])) { + return $middlewares['middlewareGroups'][$middleware]; + } + + $name = explode(':', $middleware)[0]; + if (isset($middlewares['routeMiddlewares'][$name])) { + return $middlewares['routeMiddlewares'][$name]; + } + + return $middleware; + } + + /** + * @param $response + * + * @return Response|mixed + */ + protected function sendResponse($response) + { + if (is_array($response)) { + $this->response->headers->set('Content-Type', 'application/json'); + return $this->response + ->setContent(json_encode($response)) + ->send(); + } + + if (!is_string($response)) { + return $response instanceof Response ? $response->send() : print($response); + } + + return $this->response->setContent($response)->send(); + } + + /** + * Throw new Exception for Router Error + * + * @param string $message + * @param int $statusCode + * + * @return RouterException + * @throws Exception + */ + protected function exception($message = '', $statusCode = 500) + { + return new RouterException($message, $statusCode); + } +} diff --git a/vendor/izniburak/router/src/RouterException.php b/vendor/izniburak/router/src/RouterException.php new file mode 100644 index 0000000..a029825 --- /dev/null +++ b/vendor/izniburak/router/src/RouterException.php @@ -0,0 +1,31 @@ +Opps! An error occurred. {$message}"); + } +} diff --git a/vendor/izniburak/router/src/RouterRequest.php b/vendor/izniburak/router/src/RouterRequest.php new file mode 100644 index 0000000..d092551 --- /dev/null +++ b/vendor/izniburak/router/src/RouterRequest.php @@ -0,0 +1,127 @@ +request = $request; + $this->response = $response; + } + + /** + * @return Request + */ + public function symfonyRequest(): Request + { + return $this->request; + } + + /** + * @return Response + */ + public function symfonyResponse(): Response + { + return $this->response; + } + + /** + * @return string + */ + public function validMethods(): string + { + return $this->validMethods; + } + + /** + * Request method validation + * + * @param string $data + * @param string $method + * + * @return bool + */ + public function validMethod(string $data, string $method): bool + { + $valid = false; + if (strstr($data, '|')) { + foreach (explode('|', $data) as $value) { + $valid = $this->checkMethods($value, $method); + if ($valid) { + break; + } + } + } else { + $valid = $this->checkMethods($data, $method); + } + + return $valid; + } + + /** + * Get the request method used, taking overrides into account + * + * @return string + */ + public function getMethod(): string + { + $method = $this->request->getMethod(); + $formMethod = $this->request->request->get('_method'); + if (!empty($formMethod)) { + $method = strtoupper($formMethod); + } + + return $method; + } + + /** + * check method valid + * + * @param string $value + * @param string $method + * + * @return bool + */ + protected function checkMethods(string $value, string $method): bool + { + if (in_array($value, explode('|', $this->validMethods))) { + if ($this->request->isXmlHttpRequest() && $value === 'AJAX') { + return true; + } + + if ($this->request->isXmlHttpRequest() && strpos($value, 'X') === 0 + && $method === ltrim($value, 'X')) { + return true; + } + + if (in_array($value, [$method, 'ANY'])) { + return true; + } + } + + return false; + } +} diff --git a/vendor/izniburak/router/tests/RouterTest.php b/vendor/izniburak/router/tests/RouterTest.php new file mode 100644 index 0000000..d3c753d --- /dev/null +++ b/vendor/izniburak/router/tests/RouterTest.php @@ -0,0 +1,94 @@ +router = new Router(); + + $this->client = new Client(); + + // Clear SCRIPT_NAME because bramus/router tries to guess the subfolder the script is run in + $_SERVER['SCRIPT_NAME'] = '/index.php'; + + // Default request method to GET + $_SERVER['REQUEST_METHOD'] = 'GET'; + + // Default SERVER_PROTOCOL method to HTTP/1.1 + $_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1'; + } + + protected function tearDown() + { + // nothing + } + + public function testGetIndexRoute() + { + $request = $this->client->createRequest('GET', 'http://localhost/tests/fixtures/'); + $response = $this->client->send($request); + + $this->assertSame('Hello World!', (string) $response->getBody()); + } + + /** + * @expectedException GuzzleHttp\Exception\ClientException + */ + public function testGetNotFoundRoute() + { + $request = $this->client->createRequest('GET', 'http://localhost/tests/fixtures/not/found'); + $response = $this->client->send($request); + } + + public function testGetControllerRoute() + { + $request = $this->client->createRequest('GET', 'http://localhost/tests/fixtures/controller'); + $response = $this->client->send($request); + + $this->assertSame('controller route', (string) $response->getBody()); + } + + public function testInit() + { + $this->assertInstanceOf('\\Buki\\Router', new Router()); + } + + public function testGetRoutes() + { + $params = [ + 'paths' => [ + 'controllers' => 'controllers/', + ], + 'namespaces' => [ + 'controllers' => 'Controllers\\', + ], + 'base_folder' => __DIR__, + 'main_method' => 'main', + ]; + $router = new Router($params); + + $router->get('/', function() { + return 'Hello World!'; + }); + + $router->get('/controllers', 'TestController@main'); + + $routes = $router->getRoutes(); + + $this->assertCount(2, $routes); + $this->assertInstanceOf('\\Closure', $routes[0]['callback']); + $this->assertSame('TestController@main', $routes[1]['callback']); + $this->assertSame('GET', $routes[0]['method']); + $this->assertSame('GET', $routes[1]['method']); + } +} diff --git a/vendor/izniburak/router/tests/fixtures/.htaccess b/vendor/izniburak/router/tests/fixtures/.htaccess new file mode 100644 index 0000000..e649a1e --- /dev/null +++ b/vendor/izniburak/router/tests/fixtures/.htaccess @@ -0,0 +1,5 @@ +RewriteEngine On +RewriteBase /tests/fixtures +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +RewriteRule ^ index.php [QSA,L] diff --git a/vendor/izniburak/router/tests/fixtures/TestController.php b/vendor/izniburak/router/tests/fixtures/TestController.php new file mode 100644 index 0000000..077a30d --- /dev/null +++ b/vendor/izniburak/router/tests/fixtures/TestController.php @@ -0,0 +1,9 @@ + [ + 'controllers' => 'controllers/', + ], + 'namespaces' => [ + 'controllers' => 'Controllers\\', + ], + 'base_folder' => __DIR__, + 'main_method' => 'main', +]; + +$router = new Router($params); + +$router->get('/', function() { + return 'Hello World!'; +}); + +$router->get('/controller', 'TestController@main'); + +$router->run(); diff --git a/vendor/izniburak/router/tests/fixtures/travis-ci-apache b/vendor/izniburak/router/tests/fixtures/travis-ci-apache new file mode 100644 index 0000000..16dc7d0 --- /dev/null +++ b/vendor/izniburak/router/tests/fixtures/travis-ci-apache @@ -0,0 +1,21 @@ + + DocumentRoot %TRAVIS_BUILD_DIR% + + + Options FollowSymLinks MultiViews ExecCGI + AllowOverride All + Require all granted + + + # Wire up Apache to use Travis CI's php-fpm. + + AddHandler php-fcgi .php + Action php-fcgi /php-fcgi + Alias /php-fcgi /usr/lib/cgi-bin/php-fcgi + FastCgiExternalServer /usr/lib/cgi-bin/php-fcgi -host 127.0.0.1:9000 -pass-header Authorization + + + Require all granted + + + diff --git a/vendor/izniburak/router/tests/fixtures/www.conf.default b/vendor/izniburak/router/tests/fixtures/www.conf.default new file mode 100644 index 0000000..7df4d41 --- /dev/null +++ b/vendor/izniburak/router/tests/fixtures/www.conf.default @@ -0,0 +1,384 @@ +; Start a new pool named 'www'. +; the variable $pool can we used in any directive and will be replaced by the +; pool name ('www' here) +[www] + +; Per pool prefix +; It only applies on the following directives: +; - 'slowlog' +; - 'listen' (unixsocket) +; - 'chroot' +; - 'chdir' +; - 'php_values' +; - 'php_admin_values' +; When not set, the global prefix (or /usr) applies instead. +; Note: This directive can also be relative to the global prefix. +; Default Value: none +;prefix = /path/to/pools/$pool + +; Unix user/group of processes +; Note: The user is mandatory. If the group is not set, the default user's group +; will be used. +user = www-data +group = www-data + +; The address on which to accept FastCGI requests. +; Valid syntaxes are: +; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on +; a specific port; +; 'port' - to listen on a TCP socket to all addresses on a +; specific port; +; '/path/to/unix/socket' - to listen on a unix socket. +; Note: This value is mandatory. +listen = 127.0.0.1:9000 + +; Set listen(2) backlog. A value of '-1' means unlimited. +; Default Value: 128 (-1 on FreeBSD and OpenBSD) +;listen.backlog = -1 + +; Set permissions for unix socket, if one is used. In Linux, read/write +; permissions must be set in order to allow connections from a web server. Many +; BSD-derived systems allow connections regardless of permissions. +; Default Values: user and group are set as the running user +; mode is set to 0666 +;listen.owner = www-data +;listen.group = www-data +;listen.mode = 0666 + +; List of ipv4 addresses of FastCGI clients which are allowed to connect. +; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original +; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address +; must be separated by a comma. If this value is left blank, connections will be +; accepted from any ip address. +; Default Value: any +;listen.allowed_clients = 127.0.0.1 + +; Choose how the process manager will control the number of child processes. +; Possible Values: +; static - a fixed number (pm.max_children) of child processes; +; dynamic - the number of child processes are set dynamically based on the +; following directives. With this process management, there will be +; always at least 1 children. +; pm.max_children - the maximum number of children that can +; be alive at the same time. +; pm.start_servers - the number of children created on startup. +; pm.min_spare_servers - the minimum number of children in 'idle' +; state (waiting to process). If the number +; of 'idle' processes is less than this +; number then some children will be created. +; pm.max_spare_servers - the maximum number of children in 'idle' +; state (waiting to process). If the number +; of 'idle' processes is greater than this +; number then some children will be killed. +; ondemand - no children are created at startup. Children will be forked when +; new requests will connect. The following parameter are used: +; pm.max_children - the maximum number of children that +; can be alive at the same time. +; pm.process_idle_timeout - The number of seconds after which +; an idle process will be killed. +; Note: This value is mandatory. +pm = dynamic + +; The number of child processes to be created when pm is set to 'static' and the +; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'. +; This value sets the limit on the number of simultaneous requests that will be +; served. Equivalent to the ApacheMaxClients directive with mpm_prefork. +; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP +; CGI. The below defaults are based on a server without much resources. Don't +; forget to tweak pm.* to fit your needs. +; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand' +; Note: This value is mandatory. +pm.max_children = 10 + +; The number of child processes created on startup. +; Note: Used only when pm is set to 'dynamic' +; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2 +pm.start_servers = 4 + +; The desired minimum number of idle server processes. +; Note: Used only when pm is set to 'dynamic' +; Note: Mandatory when pm is set to 'dynamic' +pm.min_spare_servers = 2 + +; The desired maximum number of idle server processes. +; Note: Used only when pm is set to 'dynamic' +; Note: Mandatory when pm is set to 'dynamic' +pm.max_spare_servers = 6 + +; The number of seconds after which an idle process will be killed. +; Note: Used only when pm is set to 'ondemand' +; Default Value: 10s +;pm.process_idle_timeout = 10s; + +; The number of requests each child process should execute before respawning. +; This can be useful to work around memory leaks in 3rd party libraries. For +; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS. +; Default Value: 0 +;pm.max_requests = 500 + +; The URI to view the FPM status page. If this value is not set, no URI will be +; recognized as a status page. It shows the following informations: +; pool - the name of the pool; +; process manager - static, dynamic or ondemand; +; start time - the date and time FPM has started; +; start since - number of seconds since FPM has started; +; accepted conn - the number of request accepted by the pool; +; listen queue - the number of request in the queue of pending +; connections (see backlog in listen(2)); +; max listen queue - the maximum number of requests in the queue +; of pending connections since FPM has started; +; listen queue len - the size of the socket queue of pending connections; +; idle processes - the number of idle processes; +; active processes - the number of active processes; +; total processes - the number of idle + active processes; +; max active processes - the maximum number of active processes since FPM +; has started; +; max children reached - number of times, the process limit has been reached, +; when pm tries to start more children (works only for +; pm 'dynamic' and 'ondemand'); +; Value are updated in real time. +; Example output: +; pool: www +; process manager: static +; start time: 01/Jul/2011:17:53:49 +0200 +; start since: 62636 +; accepted conn: 190460 +; listen queue: 0 +; max listen queue: 1 +; listen queue len: 42 +; idle processes: 4 +; active processes: 11 +; total processes: 15 +; max active processes: 12 +; max children reached: 0 +; +; By default the status page output is formatted as text/plain. Passing either +; 'html', 'xml' or 'json' in the query string will return the corresponding +; output syntax. Example: +; http://www.foo.bar/status +; http://www.foo.bar/status?json +; http://www.foo.bar/status?html +; http://www.foo.bar/status?xml +; +; By default the status page only outputs short status. Passing 'full' in the +; query string will also return status for each pool process. +; Example: +; http://www.foo.bar/status?full +; http://www.foo.bar/status?json&full +; http://www.foo.bar/status?html&full +; http://www.foo.bar/status?xml&full +; The Full status returns for each process: +; pid - the PID of the process; +; state - the state of the process (Idle, Running, ...); +; start time - the date and time the process has started; +; start since - the number of seconds since the process has started; +; requests - the number of requests the process has served; +; request duration - the duration in µs of the requests; +; request method - the request method (GET, POST, ...); +; request URI - the request URI with the query string; +; content length - the content length of the request (only with POST); +; user - the user (PHP_AUTH_USER) (or '-' if not set); +; script - the main script called (or '-' if not set); +; last request cpu - the %cpu the last request consumed +; it's always 0 if the process is not in Idle state +; because CPU calculation is done when the request +; processing has terminated; +; last request memory - the max amount of memory the last request consumed +; it's always 0 if the process is not in Idle state +; because memory calculation is done when the request +; processing has terminated; +; If the process is in Idle state, then informations are related to the +; last request the process has served. Otherwise informations are related to +; the current request being served. +; Example output: +; ************************ +; pid: 31330 +; state: Running +; start time: 01/Jul/2011:17:53:49 +0200 +; start since: 63087 +; requests: 12808 +; request duration: 1250261 +; request method: GET +; request URI: /test_mem.php?N=10000 +; content length: 0 +; user: - +; script: /home/fat/web/docs/php/test_mem.php +; last request cpu: 0.00 +; last request memory: 0 +; +; Note: There is a real-time FPM status monitoring sample web page available +; It's available in: ${prefix}/share/fpm/status.html +; +; Note: The value must start with a leading slash (/). The value can be +; anything, but it may not be a good idea to use the .php extension or it +; may conflict with a real PHP file. +; Default Value: not set +;pm.status_path = /status + +; The ping URI to call the monitoring page of FPM. If this value is not set, no +; URI will be recognized as a ping page. This could be used to test from outside +; that FPM is alive and responding, or to +; - create a graph of FPM availability (rrd or such); +; - remove a server from a group if it is not responding (load balancing); +; - trigger alerts for the operating team (24/7). +; Note: The value must start with a leading slash (/). The value can be +; anything, but it may not be a good idea to use the .php extension or it +; may conflict with a real PHP file. +; Default Value: not set +;ping.path = /ping + +; This directive may be used to customize the response of a ping request. The +; response is formatted as text/plain with a 200 response code. +; Default Value: pong +;ping.response = pong + +; The access log file +; Default: not set +;access.log = log/$pool.access.log + +; The access log format. +; The following syntax is allowed +; %%: the '%' character +; %C: %CPU used by the request +; it can accept the following format: +; - %{user}C for user CPU only +; - %{system}C for system CPU only +; - %{total}C for user + system CPU (default) +; %d: time taken to serve the request +; it can accept the following format: +; - %{seconds}d (default) +; - %{miliseconds}d +; - %{mili}d +; - %{microseconds}d +; - %{micro}d +; %e: an environment variable (same as $_ENV or $_SERVER) +; it must be associated with embraces to specify the name of the env +; variable. Some exemples: +; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e +; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e +; %f: script filename +; %l: content-length of the request (for POST request only) +; %m: request method +; %M: peak of memory allocated by PHP +; it can accept the following format: +; - %{bytes}M (default) +; - %{kilobytes}M +; - %{kilo}M +; - %{megabytes}M +; - %{mega}M +; %n: pool name +; %o: ouput header +; it must be associated with embraces to specify the name of the header: +; - %{Content-Type}o +; - %{X-Powered-By}o +; - %{Transfert-Encoding}o +; - .... +; %p: PID of the child that serviced the request +; %P: PID of the parent of the child that serviced the request +; %q: the query string +; %Q: the '?' character if query string exists +; %r: the request URI (without the query string, see %q and %Q) +; %R: remote IP address +; %s: status (response code) +; %t: server time the request was received +; it can accept a strftime(3) format: +; %d/%b/%Y:%H:%M:%S %z (default) +; %T: time the log has been written (the request has finished) +; it can accept a strftime(3) format: +; %d/%b/%Y:%H:%M:%S %z (default) +; %u: remote user +; +; Default: "%R - %u %t \"%m %r\" %s" +;access.format = %R - %u %t "%m %r%Q%q" %s %f %{mili}d %{kilo}M %C%% + +; The log file for slow requests +; Default Value: not set +; Note: slowlog is mandatory if request_slowlog_timeout is set +;slowlog = log/$pool.log.slow + +; The timeout for serving a single request after which a PHP backtrace will be +; dumped to the 'slowlog' file. A value of '0s' means 'off'. +; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) +; Default Value: 0 +;request_slowlog_timeout = 0 + +; The timeout for serving a single request after which the worker process will +; be killed. This option should be used when the 'max_execution_time' ini option +; does not stop script execution for some reason. A value of '0' means 'off'. +; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) +; Default Value: 0 +;request_terminate_timeout = 0 + +; Set open file descriptor rlimit. +; Default Value: system defined value +;rlimit_files = 1024 + +; Set max core size rlimit. +; Possible Values: 'unlimited' or an integer greater or equal to 0 +; Default Value: system defined value +;rlimit_core = 0 + +; Chroot to this directory at the start. This value must be defined as an +; absolute path. When this value is not set, chroot is not used. +; Note: you can prefix with '$prefix' to chroot to the pool prefix or one +; of its subdirectories. If the pool prefix is not set, the global prefix +; will be used instead. +; Note: chrooting is a great security feature and should be used whenever +; possible. However, all PHP paths will be relative to the chroot +; (error_log, sessions.save_path, ...). +; Default Value: not set +;chroot = + +; Chdir to this directory at the start. +; Note: relative path can be used. +; Default Value: current directory or / when chroot +chdir = / + +; Redirect worker stdout and stderr into main error log. If not set, stdout and +; stderr will be redirected to /dev/null according to FastCGI specs. +; Note: on highloaded environement, this can cause some delay in the page +; process time (several ms). +; Default Value: no +;catch_workers_output = yes + +; Limits the extensions of the main script FPM will allow to parse. This can +; prevent configuration mistakes on the web server side. You should only limit +; FPM to .php extensions to prevent malicious users to use other extensions to +; exectute php code. +; Note: set an empty value to allow all extensions. +; Default Value: .php +;security.limit_extensions = .php .php3 .php4 .php5 + +; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from +; the current environment. +; Default Value: clean env +;env[HOSTNAME] = $HOSTNAME +;env[PATH] = /usr/local/bin:/usr/bin:/bin +;env[TMP] = /tmp +;env[TMPDIR] = /tmp +;env[TEMP] = /tmp + +; Additional php.ini defines, specific to this pool of workers. These settings +; overwrite the values previously defined in the php.ini. The directives are the +; same as the PHP SAPI: +; php_value/php_flag - you can set classic ini defines which can +; be overwritten from PHP call 'ini_set'. +; php_admin_value/php_admin_flag - these directives won't be overwritten by +; PHP call 'ini_set' +; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no. + +; Defining 'extension' will load the corresponding shared extension from +; extension_dir. Defining 'disable_functions' or 'disable_classes' will not +; overwrite previously defined php.ini values, but will append the new value +; instead. + +; Note: path INI options can be relative and will be expanded with the prefix +; (pool, global or /usr) + +; Default Value: nothing is defined by default except the values in php.ini and +; specified at startup with the -d argument +;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com +;php_flag[display_errors] = off +;php_admin_value[error_log] = /var/log/fpm-php.www.log +;php_admin_flag[log_errors] = on +;php_admin_value[memory_limit] = 32M diff --git a/vendor/league/plates/.github/workflows/docs.yml b/vendor/league/plates/.github/workflows/docs.yml new file mode 100644 index 0000000..b58513b --- /dev/null +++ b/vendor/league/plates/.github/workflows/docs.yml @@ -0,0 +1,26 @@ +name: docs + +on: + push: + branches: + - v3 + +jobs: + deploy: + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v2 + + - name: Setup Hugo + uses: peaceiris/actions-hugo@v2 + with: + hugo-version: '0.79.1' + + - name: Build + run: hugo --minify -s doc + + - name: Deploy + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./doc/public \ No newline at end of file diff --git a/vendor/league/plates/.github/workflows/php.yml b/vendor/league/plates/.github/workflows/php.yml new file mode 100644 index 0000000..40288ee --- /dev/null +++ b/vendor/league/plates/.github/workflows/php.yml @@ -0,0 +1,35 @@ +name: PHP + +on: [push] + +jobs: + run: + runs-on: 'ubuntu-latest' + strategy: + matrix: + php-versions: ['7.3', '7.4', '8.0'] + phpunit-versions: ['9.5'] + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + extensions: mbstring, intl + ini-values: post_max_size=256M, max_execution_time=180 + coverage: xdebug + tools: php-cs-fixer, phpunit:${{ matrix.phpunit-versions }} + + - name: Validate Composer + run: composer validate + - name: Install Composer Deps + run: composer install + - name: Run Tests + run: phpunit --testdox --coverage-text --coverage-clover=coverage.clover + - name: Upload Scrutinzer + continue-on-error: true + run: | + wget https://scrutinizer-ci.com/ocular.phar + php ocular.phar code-coverage:upload --format=php-clover coverage.clover \ No newline at end of file diff --git a/vendor/league/plates/CONTRIBUTING.md b/vendor/league/plates/CONTRIBUTING.md new file mode 100644 index 0000000..c2cc4f6 --- /dev/null +++ b/vendor/league/plates/CONTRIBUTING.md @@ -0,0 +1,29 @@ +# Contributing + +Contributions are **welcome** and will be fully **credited**. + +We accept contributions via Pull Requests on [Github](https://github.com/thephpleague/plates). + +## Pull Requests + +- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer). +- **Add tests!** - Your patch won't be accepted if it doesn't have tests. +- **Document any change in behaviour** - Make sure the README and any other relevant documentation are kept up-to-date. +- **Consider our release cycle** - We try to follow semver. Randomly breaking public APIs is not an option. +- **Create topic branches** - Don't ask us to pull from your master branch. +- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. +- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please squash them before submitting. + +## Running Tests + +``` bash +$ phpunit +``` + +## Docs + +Docs are served with hugo running on version 0.79 or later. + +You can view the docs locally with `hugo -s doc server` + +**Happy coding**! \ No newline at end of file diff --git a/vendor/league/plates/LICENSE b/vendor/league/plates/LICENSE new file mode 100644 index 0000000..26357d4 --- /dev/null +++ b/vendor/league/plates/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2013 The League of Extraordinary Packages + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/vendor/league/plates/README.md b/vendor/league/plates/README.md new file mode 100644 index 0000000..1f76fd2 --- /dev/null +++ b/vendor/league/plates/README.md @@ -0,0 +1,64 @@ +Plates +====== + +[![Maintainer](http://img.shields.io/badge/maintainer-@ragboyjr-blue.svg?style=flat-square)](https://twitter.com/ragboyjr) +[![Source Code](http://img.shields.io/badge/source-league/plates-blue.svg?style=flat-square)](https://github.com/thephpleague/plates) +[![Latest Version](https://img.shields.io/github/release/thephpleague/plates.svg?style=flat-square)](https://github.com/thephpleague/plates/releases) +[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE) +[![Build Status](https://img.shields.io/github/workflow/status/thephpleague/plates/PHP/v3?style=flat-square)](https://github.com/thephpleague/plates/actions?query=workflow%3APHP+branch%3Av3) +[![Coverage Status](https://img.shields.io/scrutinizer/coverage/g/thephpleague/plates.svg?style=flat-square)](https://scrutinizer-ci.com/g/thephpleague/plates/code-structure) +[![Quality Score](https://img.shields.io/scrutinizer/g/thephpleague/plates.svg?style=flat-square)](https://scrutinizer-ci.com/g/thephpleague/plates) +[![Total Downloads](https://img.shields.io/packagist/dt/league/plates.svg?style=flat-square)](https://packagist.org/packages/league/plates) + +Plates is a native PHP template system that's fast, easy to use and easy to extend. It's inspired by the excellent [Twig](http://twig.sensiolabs.org/) template engine and strives to bring modern template language functionality to native PHP templates. Plates is designed for developers who prefer to use native PHP templates over compiled template languages, such as Twig or Smarty. + +### Highlights + +- Native PHP templates, no new [syntax](https://platesphp.com/templates/syntax/) to learn +- Plates is a template system, not a template language +- Plates encourages the use of existing PHP functions +- Increase code reuse with template [layouts](https://platesphp.com/templates/layouts/) and [inheritance](https://platesphp.com/templates/inheritance/) +- Template [folders](https://platesphp.com/engine/folders/) for grouping templates into namespaces +- [Data](https://platesphp.com/templates/data/#preassigned-and-shared-data) sharing across templates +- Preassign [data](https://platesphp.com/templates/data/#preassigned-and-shared-data) to specific templates +- Built-in [escaping](https://platesphp.com/templates/escaping/) helpers +- Easy to extend using [functions](https://platesphp.com/engine/functions/) and [extensions](https://platesphp.com/engine/extensions/) +- Framework-agnostic, will work with any project +- Decoupled design makes templates easy to test +- Composer ready and PSR-2 compliant + +## Installation + +Plates is available via Composer: + +``` +composer require league/plates +``` + +## Documentation + +Full documentation can be found at [platesphp.com](https://platesphp.com/). + +## Testing + +```bash +phpunit +``` + +## Contributing + +Please see [CONTRIBUTING](https://github.com/thephpleague/plates/blob/master/CONTRIBUTING.md) for details. + +## Security + +If you discover any security related issues, please email ragboyjr@icloud.com instead of using the issue tracker. + +## Credits + +- [RJ Garcia](https://github.com/ragboyjr) (Current Maintainer) +- [Jonathan Reinink](https://github.com/reinink) (Original Author) +- [All Contributors](https://github.com/thephpleague/plates/contributors) + +## License + +The MIT License (MIT). Please see [License File](https://github.com/thephpleague/plates/blob/master/LICENSE) for more information. diff --git a/vendor/league/plates/composer.json b/vendor/league/plates/composer.json new file mode 100644 index 0000000..de9f1f7 --- /dev/null +++ b/vendor/league/plates/composer.json @@ -0,0 +1,52 @@ +{ + "name": "league/plates", + "description": "Plates, the native PHP template system that's fast, easy to use and easy to extend.", + "keywords": [ + "league", + "package", + "templating", + "templates", + "views" + ], + "homepage": "https://platesphp.com", + "license": "MIT", + "authors" : [ + { + "name": "Jonathan Reinink", + "email": "jonathan@reinink.ca", + "role": "Developer" + }, + { + "name": "RJ Garcia", + "email": "ragboyjr@icloud.com", + "role": "Developer" + } + ], + "require" : { + "php": "^7.0|^8.0" + }, + "require-dev": { + "mikey179/vfsstream": "^1.6", + "phpunit/phpunit": "^9.5", + "squizlabs/php_codesniffer": "^3.5" + }, + "autoload": { + "psr-4": { + "League\\Plates\\": "src" + } + }, + "autoload-dev": { + "psr-4": { + "League\\Plates\\Tests\\": "tests" + } + }, + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "scripts": { + "test": "phpunit --testdox", + "docs": "hugo -s doc server" + } +} diff --git a/vendor/league/plates/doc/config.toml b/vendor/league/plates/doc/config.toml new file mode 100644 index 0000000..8b7c107 --- /dev/null +++ b/vendor/league/plates/doc/config.toml @@ -0,0 +1,15 @@ +baseURL = "https://platesphp.com/" +languageCode = "en-us" +title = "Plates" + +pygmentsUseClasses = true + +googleAnalytics = "UA-46050814-2" + +[params] + tagline = "Native PHP Templates" + description = "Plates is a Twig inspired, native PHP template system that brings modern template language functionality to native PHP templates." + [params.images] + favicon = "favicon/favicon.ico" + appleTouch = "favicon/apple-touch-icon-precomposed.png" + logo = "images/logo.png" \ No newline at end of file diff --git a/vendor/league/plates/doc/content/_index.md b/vendor/league/plates/doc/content/_index.md new file mode 100644 index 0000000..b132422 --- /dev/null +++ b/vendor/league/plates/doc/content/_index.md @@ -0,0 +1,39 @@ ++++ +title = "Introduction" +[menu.main] +parent = "getting-started" +weight = 1 ++++ + +[![Maintainer](http://img.shields.io/badge/maintainer-@ragboyjr-blue.svg?style=flat-square)](https://twitter.com/reinink) +[![Source Code](http://img.shields.io/badge/source-league/plates-blue.svg?style=flat-square)](https://github.com/thephpleague/plates) +[![Latest Version](https://img.shields.io/github/release/thephpleague/plates.svg?style=flat-square)](https://github.com/thephpleague/plates/releases) +[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](https://github.com/thephpleague/plates/blob/master/LICENSE) +{{}}
{{}} +[![Build Status](https://img.shields.io/github/workflow/status/thephpleague/plates/PHP/v3?style=flat-square)](https://github.com/thephpleague/plates/actions?query=workflow%3APHP+branch%3Av3) +[![Coverage Status](https://img.shields.io/scrutinizer/coverage/g/thephpleague/plates.svg?style=flat-square)](https://scrutinizer-ci.com/g/thephpleague/plates/code-structure) +[![Quality Score](https://img.shields.io/scrutinizer/g/thephpleague/plates.svg?style=flat-square)](https://scrutinizer-ci.com/g/thephpleague/plates) +[![Total Downloads](https://img.shields.io/packagist/dt/league/plates.svg?style=flat-square)](https://packagist.org/packages/league/plates) + +## About + +Plates is a native PHP template system that's fast, easy to use and easy to extend. It's inspired by the excellent [Twig](http://twig.sensiolabs.org/) template engine and strives to bring modern template language functionality to native PHP templates. Plates is designed for developers who prefer to use native PHP templates over compiled template languages, such as Twig or Smarty. + +## Highlights + +- Native PHP templates, no new [syntax]({{< relref "templates/syntax.md" >}}) to learn +- Plates is a template system, not a template language +- Plates encourages the use of existing PHP functions +- Increase code reuse with template [layouts]({{< relref "templates/layouts.md" >}}) and [inheritance]({{< relref "templates/inheritance.md" >}}) +- Template [folders]({{< relref "engine/folders.md" >}}) for grouping templates into namespaces +- [Data]({{< relref "templates/data.md#preassigned-and-shared-data" >}}) sharing across templates +- Preassign [data]({{< relref "templates/data#preassigned-and-shared-data" >}}) to specific templates +- Built-in [escaping]({{< relref "templates/escaping.md" >}}) helpers +- Easy to extend using [functions]({{< relref "engine/functions.md" >}}) and [extensions]({{< relref "engine/extensions.md" >}}) +- Framework-agnostic, will work with any project +- Decoupled design makes templates easy to test +- Composer ready and PSR-2 compliant + +## Questions? + +Plates is maintained by [RJ Garcia](https://twitter.com/ragboyjr) and originally created by [Jonathan Reinink](https://twitter.com/reinink). Submit issues to [Github](https://github.com/thephpleague/plates/issues). diff --git a/vendor/league/plates/doc/content/engine/_index.md b/vendor/league/plates/doc/content/engine/_index.md new file mode 100644 index 0000000..a6f8de9 --- /dev/null +++ b/vendor/league/plates/doc/content/engine/_index.md @@ -0,0 +1,6 @@ ++++ +title = "The Engine" +[menu.main] +identifier = "engine" +weight = 2 ++++ \ No newline at end of file diff --git a/vendor/league/plates/doc/content/engine/extensions.md b/vendor/league/plates/doc/content/engine/extensions.md new file mode 100644 index 0000000..7d20671 --- /dev/null +++ b/vendor/league/plates/doc/content/engine/extensions.md @@ -0,0 +1,119 @@ ++++ +title = "Extensions" +linkTitle = "Engine Extensions" +[menu.main] +parent = "engine" +weight = 5 ++++ + +Creating extensions couldn't be easier, and can really make Plates sing for your specific project. Start by creating a class that implements `\League\Plates\Extension\ExtensionInterface`. Next, register your template [functions]({{< relref "engine/functions.md" >}}) within a `register()` method. + +## Simple extensions example + +~~~ php +use League\Plates\Engine; +use League\Plates\Extension\ExtensionInterface; + +class ChangeCase implements ExtensionInterface +{ + public function register(Engine $engine) + { + $engine->registerFunction('uppercase', [$this, 'uppercaseString']); + $engine->registerFunction('lowercase', [$this, 'lowercaseString']); + } + + public function uppercaseString($var) + { + return strtoupper($var); + } + + public function lowercaseString($var) + { + return strtolower($var); + } +} +~~~ + +To use this extension in your template, simply call your new functions: + +~~~ php +

Hello, e($this->uppercase($name))?>

+~~~ + +They can also be used in a [batch]({{< relref "templates/functions.md#batch-function-calls" >}}) compatible function: + +~~~ php +

Hello e($name, 'uppercase')

+~~~ + +## Single method extensions + +Alternatively, you may choose to expose the entire extension object to the template using a single function. This can make your templates more legible and also reduce the chance of conflicts with other extensions. + +~~~ php +use League\Plates\Engine; +use League\Plates\Extension\ExtensionInterface; + +class ChangeCase implements ExtensionInterface +{ + public function register(Engine $engine) + { + $engine->registerFunction('case', [$this, 'getObject']); + } + + public function getObject() + { + return $this; + } + + public function upper($var) + { + return strtoupper($var); + } + + public function lower($var) + { + return strtolower($var); + } +} +~~~ + +To use this extension in your template, first call the primary function, then the secondary functions: + +~~~ php +

Hello, e($this->case()->upper($name))?>

+~~~ + +## Loading extensions + +To enable an extension, load it into the [engine]({{< relref "engine/overview.md" >}}) object using the `loadExtension()` method. + +~~~ php +$engine->loadExtension(new ChangeCase()); +~~~ + +## Accessing the engine and template + +It may be desirable to access the `engine` or `template` objects from within your extension. Plates makes both of these objects available to you. The engine is automatically passed to the `register()` method, and the template is assigned as a parameter on each function call. + +~~~ php +use League\Plates\Engine; +use League\Plates\Extension\ExtensionInterface; + +class MyExtension implements ExtensionInterface +{ + protected $engine; + public $template; // must be public + + public function register(Engine $engine) + { + $this->engine = $engine; + + // Access template data: + $data = $this->template->data(); + + // Register functions + // ... + } +} +~~~ diff --git a/vendor/league/plates/doc/content/engine/file-extensions.md b/vendor/league/plates/doc/content/engine/file-extensions.md new file mode 100644 index 0000000..e58023b --- /dev/null +++ b/vendor/league/plates/doc/content/engine/file-extensions.md @@ -0,0 +1,35 @@ ++++ +title = "File Extensions" +linkTitle = "Engine File Extensions" +[menu.main] +parent = "engine" +weight = 2 ++++ + +Plates does not enforce a specific template file extension. By default it assumes `.php`. This file extension is automatically appended to your template names when rendered. You are welcome to change the default extension using one of the following methods. + +## Constructor method + +~~~ php +// Create new engine and set the default file extension to ".tpl" +$template = new League\Plates\Engine('/path/to/templates', 'tpl'); +~~~ + +## Setter method + +~~~ php +// Sets the default file extension to ".tpl" after engine instantiation +$template->setFileExtension('tpl'); +~~~ + +## Manually assign + +If you prefer to manually set the file extension, simply set the default file extension to `null`. + +~~~ php +// Disable automatic file extensions +$template->setFileExtension(null); + +// Render template +echo $templates->render('home.php'); +~~~ \ No newline at end of file diff --git a/vendor/league/plates/doc/content/engine/folders.md b/vendor/league/plates/doc/content/engine/folders.md new file mode 100644 index 0000000..c90bfb0 --- /dev/null +++ b/vendor/league/plates/doc/content/engine/folders.md @@ -0,0 +1,49 @@ ++++ +title = "Folders" +linkTitle = "Engine Folders" +[menu.main] +parent = "engine" +weight = 3 ++++ + +Folders make it really easy to organize and access your templates. Folders allow you to group your templates under different namespaces, each of which having their own file system path. + +## Creating folders + +To create folders, use the `addFolder()` method: + +~~~ php +// Create new Plates instance +$templates = new League\Plates\Engine(); + +// Add folders +$templates->addFolder('admin', '/path/to/admin/templates'); +$templates->addFolder('emails', '/path/to/email/templates'); +~~~ + +## Using folders + +To use the folders you created within your project simply append the folder name with two colons before the template name. For example, to render a welcome email: + +~~~ php +$email = $templates->render('emails::welcome'); +~~~ + +This works with template functions as well, such as layouts or nested templates. For example: + +~~~ php +layout('shared::template') ?> +~~~ + +## Folder fallbacks + +When enabled, if a folder template is missing, Plates will automatically fallback and look for a template with the **same** name in the default folder. This can be helpful when using folders to manage themes. To enable fallbacks, simply pass `true` as the third parameter in the `addFolders()` method. + +~~~ php +// Create new Plates engine +$templates = new \League\Plates\Engine('/path/to/default/theme'); + +// Add themes +$templates->addFolder('theme1', '/path/to/theme/1', true); +$templates->addFolder('theme2', '/path/to/theme/2', true); +~~~ \ No newline at end of file diff --git a/vendor/league/plates/doc/content/engine/functions.md b/vendor/league/plates/doc/content/engine/functions.md new file mode 100644 index 0000000..cb9941b --- /dev/null +++ b/vendor/league/plates/doc/content/engine/functions.md @@ -0,0 +1,33 @@ ++++ +title = "Functions" +linkTitle = "Engine Functions" +[menu.main] +parent = "engine" +weight = 4 ++++ + +While [extensions]({{< relref "engine/extensions.md" >}}) are awesome for adding additional reusable functionality to Plates, sometimes it's easier to just create a one-off function for a specific use case. Plates makes this easy to do. + +## Registering functions + +~~~ php +// Create new Plates engine +$templates = new \League\Plates\Engine('/path/to/templates'); + +// Register a one-off function +$templates->registerFunction('uppercase', function ($string) { + return strtoupper($string); +}); +~~~ + +To use this function in a template, simply call it like any other function: + +~~~ php +

Hello e($this->uppercase($name))

+~~~ + +It can also be used in a [batch]({{< relref "templates/functions#batch-function-calls">}}) compatible function: + +~~~ php +

Hello e($name, 'uppercase')

+~~~ diff --git a/vendor/league/plates/doc/content/engine/overview.md b/vendor/league/plates/doc/content/engine/overview.md new file mode 100644 index 0000000..b7db2ff --- /dev/null +++ b/vendor/league/plates/doc/content/engine/overview.md @@ -0,0 +1,56 @@ ++++ +title = "Overview" +linkTitle = "Engine Overview" +aliases = ["/engine"] +[menu.main] +parent = "engine" +weight = 1 ++++ + +Plates uses a central object called the `Engine`, which is used to store the environment configuration, functions and extensions. It helps decouple your templates from the file system and other dependencies. For example, if you want to change the folder where your templates are stored, you can do so by simply changing the path in one location. + +## Basic usage + +~~~ php +// Create new Plates engine +$templates = new League\Plates\Engine('/path/to/templates'); + +// Add any additional folders +$templates->addFolder('emails', '/path/to/emails'); + +// Load any additional extensions +$templates->loadExtension(new League\Plates\Extension\Asset('/path/to/public')); + +// Create a new template +$template = $templates->make('emails::welcome'); +~~~ + +## Dependency Injection + +Plates is designed to be easily passed around your application and easily injected in your controllers or other application objects. Simply pass an instance of the `Engine` to any consuming objects, and then use either the `make()` method to create a new template, or the `render()` method to render it immediately. For example: + +~~~ php +class Controller +{ + private $templates; + + public function __construct(League\Plates\Engine $templates) + { + $this->templates = $templates; + } + + // Create a template object + public function getIndex() + { + $template = $this->templates->make('home'); + + return $template->render(); + } + + // Render a template directly + public function getIndex() + { + return $this->templates->render('home'); + } +} +~~~ diff --git a/vendor/league/plates/doc/content/extensions/_index.md b/vendor/league/plates/doc/content/extensions/_index.md new file mode 100644 index 0000000..bfe1007 --- /dev/null +++ b/vendor/league/plates/doc/content/extensions/_index.md @@ -0,0 +1,6 @@ ++++ +title = "Extensions" +[menu.main] +identifier = "extensions" +weight = 4 ++++ \ No newline at end of file diff --git a/vendor/league/plates/doc/content/extensions/asset.md b/vendor/league/plates/doc/content/extensions/asset.md new file mode 100644 index 0000000..9d7d05f --- /dev/null +++ b/vendor/league/plates/doc/content/extensions/asset.md @@ -0,0 +1,57 @@ ++++ +title = "Asset" +[menu.main] +parent = "extensions" +weight = 1 ++++ + +The asset extension can be used to quickly create "cache busted" asset URLs in your templates. This is particularly helpful for aggressively cached files that can potentially change in the future, such as CSS files, JavaScript files and images. It works by appending the timestamp of the file's last update to its URL. For example, `/css/all.css` becomes `/css/all.1373577602.css`. As long as the file does not change, the timestamp remains the same and caching occurs. However, if the file is changed, a new URL is automatically generated with a new timestamp, and visitors receive the new file. + +## Installing the asset extension + +The asset extension comes packaged with Plates but is not enabled by default, as it requires extra parameters passed to it at instantiation. + +~~~ php +// Load asset extension +$engine->loadExtension(new League\Plates\Extension\Asset('/path/to/public/assets/', true)); +~~~ + +The first constructor parameter is the file system path of the assets directory. The second is an optional `boolean` parameter that if set to true uses the filename caching method (ie. `file.1373577602.css`) instead of the default query string method (ie. `file.css?v=1373577602`). + +## Filename caching + +To make filename caching work, some URL rewriting is required: + +### Apache example +~~~ php + + RewriteCond %{REQUEST_FILENAME} !-f + RewriteCond %{REQUEST_FILENAME} !-d + RewriteRule ^(.+)\.(\d+)\.(js|css|png|jpg|gif)$ $1.$3 [L] + +~~~ + +### Nginx example + +~~~ php +location ~* (.+)\.(?:\d+)\.(js|css|png|jpg|jpeg|gif)$ { + try_files $uri $1.$2; +} +~~~ + +## Using the asset extension + +~~~ php + + + Asset Extension Example + + + + + + + + + +~~~ \ No newline at end of file diff --git a/vendor/league/plates/doc/content/extensions/community.md b/vendor/league/plates/doc/content/extensions/community.md new file mode 100644 index 0000000..6282d3a --- /dev/null +++ b/vendor/league/plates/doc/content/extensions/community.md @@ -0,0 +1,13 @@ ++++ +title = "Community" +[menu.main] +parent = "extensions" +weight = 3 ++++ + +This is a list of all the known community extensions for the Plates library. Please feel free to submit a [Pull Request](https://github.com/thephpleague/plates) to add your extension to this list. + +- [Laravel Provider](https://github.com/franzliedke/laravel-plates) +- [Attributes Rendering](https://github.com/RobinDev/platesAttributes) - Transforms arrays into html tag attributes. +- [Includer](https://github.com/odahcam/plates-includer) - Include your assets in an expert way. +- [Tapestry](https://github.com/tapestry-cloud/tapestry) - A blog aware, Plates based static site generator. diff --git a/vendor/league/plates/doc/content/extensions/uri.md b/vendor/league/plates/doc/content/extensions/uri.md new file mode 100644 index 0000000..1f3be1a --- /dev/null +++ b/vendor/league/plates/doc/content/extensions/uri.md @@ -0,0 +1,81 @@ ++++ +title = "URI" +[menu.main] +parent = "extensions" +weight = 2 ++++ + +The URI extension is designed to make URI checks within templates easier. The most common use is marking the current page in a menu as "selected". It only has one function, `uri()`, but can do a number of helpful tasks depending on the parameters passed to it. + +## Installing the URI extension + +The URI extension comes packaged with Plates but is not enabled by default, as it requires an extra parameter passed to it at instantiation. + +~~~ php +// Load URI extension using global variable +$engine->loadExtension(new League\Plates\Extension\URI($_SERVER['PATH_INFO'])); + +// Load URI extension using a HttpFoundation's request object +$engine->loadExtension(new League\Plates\Extension\URI($request->getPathInfo())); +~~~ + +## URI example + +~~~ php +
    +
  • uri('/', 'class="selected"')?>>Home
  • +
  • uri('/about', 'class="selected"')?>>About
  • +
  • uri('/products', 'class="selected"')?>>Products
  • +
  • uri('/contact', 'class="selected"')?>>Contact
  • +
+~~~ + +## Using the URI extension + +Get the whole URI. + +~~~ php +uri()?> +~~~ + +Get a specified segment of the URI. + +~~~ php +uri(1)?> +~~~ + +Check if a specific segment of the URI (first parameter) equals a given string (second parameter). Returns `true` on success or `false` on failure. + +~~~ php +uri(1, 'home')): ?> +~~~ + +Check if a specific segment of the URI (first parameter) equals a given string (second parameter). Returns string (third parameter) on success or `false` on failure. + +~~~ php +uri(1, 'home', 'success')?> +~~~ + +Check if a specific segment of the URI (first parameter) equals a given string (second parameter). Returns string (third parameter) on success or string (fourth parameter) on failure. + +~~~ php +uri(1, 'home', 'success', 'fail')?> +~~~ + +Check if a regular expression string matches the current URI. Returns `true` on success or `false` on failure. + +~~~ php +uri('/home')): ?> +~~~ + +Check if a regular expression string (first parameter) matches the current URI. Returns string (second parameter) on success or `false` on failure. + +~~~ php +uri('/home', 'success')?> +~~~ + +Check if a regular expression string (first parameter) matches the current URI. Returns string (second parameter) on success or string (third parameter) on failure. + +~~~ php +uri('/home', 'success', 'fail')?> +~~~ \ No newline at end of file diff --git a/vendor/league/plates/doc/content/getting-started/_index.md b/vendor/league/plates/doc/content/getting-started/_index.md new file mode 100644 index 0000000..19d0b83 --- /dev/null +++ b/vendor/league/plates/doc/content/getting-started/_index.md @@ -0,0 +1,6 @@ ++++ +title = "Getting Started" +[menu.main] +identifier = "getting-started" +weight = 1 ++++ \ No newline at end of file diff --git a/vendor/league/plates/doc/content/getting-started/installation.md b/vendor/league/plates/doc/content/getting-started/installation.md new file mode 100644 index 0000000..0e7c9c6 --- /dev/null +++ b/vendor/league/plates/doc/content/getting-started/installation.md @@ -0,0 +1,33 @@ ++++ +title = "Installation" +[menu.main] +parent = "getting-started" +weight = 3 ++++ + +## Using Composer + +Plates is available on [Packagist](https://packagist.org/packages/league/plates) and can be installed using [Composer](https://getcomposer.org/). This can be done by running the following command or by updating your `composer.json` file. + +~~~ bash +composer require league/plates +~~~ + +{{< code-filename composer.json >}} +~~~ javascript +{ + "require": { + "league/plates": "3.*" + } +} +~~~ + +Be sure to also include your Composer autoload file in your project: + +~~~ php +require 'vendor/autoload.php'; +~~~ + +## Downloading .zip file + +This project is also available for download as a `.zip` file on GitHub. Visit the [releases page](https://github.com/thephpleague/plates/releases), select the version you want, and click the "Source code (zip)" download button. \ No newline at end of file diff --git a/vendor/league/plates/doc/content/getting-started/simple-example.md b/vendor/league/plates/doc/content/getting-started/simple-example.md new file mode 100644 index 0000000..1f17799 --- /dev/null +++ b/vendor/league/plates/doc/content/getting-started/simple-example.md @@ -0,0 +1,50 @@ ++++ +title = "Simple Example" +[menu.main] +parent = "getting-started" +weight = 2 ++++ + +Here is a simple example of how to use Plates. We will assume the following directory stucture: + +~~~ +`-- path + `-- to + `-- templates + |-- template.php + |-- profile.php +~~~ + +## Within your controller + +~~~ php +// Create new Plates instance +$templates = new League\Plates\Engine('/path/to/templates'); + +// Render a template +echo $templates->render('profile', ['name' => 'Jonathan']); +~~~ + +## The page template + +{{< code-filename profile.php >}} +~~~ php +layout('template', ['title' => 'User Profile']) ?> + +

User Profile

+

Hello, e($name)?>

+~~~ + +## The layout template + +{{< code-filename template.php >}} +~~~ php + + + <?=$this->e($title)?> + + + section('content')?> + + +~~~ \ No newline at end of file diff --git a/vendor/league/plates/doc/content/templates/_index.md b/vendor/league/plates/doc/content/templates/_index.md new file mode 100644 index 0000000..19f973f --- /dev/null +++ b/vendor/league/plates/doc/content/templates/_index.md @@ -0,0 +1,6 @@ ++++ +title = "Templates" +[menu.main] +identifier = "templates" +weight = 3 ++++ \ No newline at end of file diff --git a/vendor/league/plates/doc/content/templates/data.md b/vendor/league/plates/doc/content/templates/data.md new file mode 100644 index 0000000..4330eed --- /dev/null +++ b/vendor/league/plates/doc/content/templates/data.md @@ -0,0 +1,60 @@ ++++ +title = "Data" +linkTitle = "Templates Data" +[menu.main] +parent = "templates" +weight = 2 ++++ + +It's very common to share application data (variables) with a template. Data can be whatever you want: strings, arrays, objects, etc. Plates allows you set both template specific data as well as shared template data. + +## Assign data + +Assigning data is done from within your application code, such as a controller. There are a number of ways to assign the data, depending on how you structure your objects. + +~~~ php +// Create new Plates instance +$templates = new League\Plates\Engine('/path/to/templates'); + +// Assign via the engine's render method +echo $templates->render('profile', ['name' => 'Jonathan']); + +// Assign via the engine's make method +$template = $templates->make('profile', ['name' => 'Jonathan']); + +// Assign directly to a template object +$template = $templates->make('profile'); +$template->data(['name' => 'Jonathan']); +~~~ + +## Accessing data + +Template data is available as locally scoped variables at the time of rendering. Continuing with the example above, here is how you would [escape]({{< relref "templates/escaping.md" >}}) and output the "name" value in a template: + +~~~ php +

Hello e($name)?>

+~~~ + +

Prior to Plates 3.0, variables were accessed using the $this pseudo-variable. This is no longer possible. Use the locally scoped variables instead.

+ +## Preassigned and shared data + +If you have data that you want assigned to a specific template each time that template is rendered throughout your application, the `addData()` function can help organize that code in one place. + +~~~ php +$templates->addData(['name' => 'Jonathan'], 'emails::welcome'); +~~~ + +You can pressaign data to more than one template by passing an array of templates: + +~~~ php +$templates->addData(['name' => 'Jonathan'], ['login', 'template']); +~~~ + +To assign data to ALL templates, simply omit the second parameter: + +~~~ php +$templates->addData(['name' => 'Jonathan']); +~~~ + +Keep in mind that shared data is assigned to a template when it's first created, meaning any conflicting data assigned that's afterwards to a specific template will overwrite the shared data. This is generally desired behavior. diff --git a/vendor/league/plates/doc/content/templates/escaping.md b/vendor/league/plates/doc/content/templates/escaping.md new file mode 100644 index 0000000..8cb44b2 --- /dev/null +++ b/vendor/league/plates/doc/content/templates/escaping.md @@ -0,0 +1,49 @@ ++++ +title = "Escaping" +linkTitle = "Templates Escaping" +[menu.main] +parent = "templates" +weight = 8 ++++ + +Escaping is a form of [data filtering](http://www.phptherightway.com/#data_filtering) which sanitizes unsafe, user supplied input prior to outputting it as HTML. Plates provides two shortcuts to the `htmlspecialchars()` function. + +## Escaping example + +~~~ php +

Hello, escape($name)?>

+ + +

Hello, e($name)?>

+~~~ + +## Batch function calls + +The escape functions also support [batch]({{< relref "templates/functions.md#batch-function-calls" >}}) function calls, which allow you to apply multiple functions, including native PHP functions, to a variable at one time. + +~~~ php +

Welcome e($name, 'strip_tags|strtoupper')?>

+~~~ + +## Escaping HTML attributes + +

It's VERY important to always double quote HTML attributes that contain escaped variables, otherwise your template will still be open to injection attacks.

+ +Some [libraries](http://framework.zend.com/manual/2.1/en/modules/zend.escaper.escaping-html-attributes.html) go as far as having a special function for escaping HTML attributes. However, this is somewhat redundant considering that if a developer forgets to properly quote an HTML attribute, they will likely also forget to use this special function. Here is how you properly escape HTML attributes: + +~~~ php + +<?=$this->e($name)?> + + +<?=$this->e($name)?> + + +<?=$this-e($name)?>> +~~~ + +## Automatic escaping + +Probably the biggest drawbacks to native PHP templates is the inability to auto-escape variables properly. Template languages like Twig and Smarty can identify "echoed" variables during a parsing stage and automatically escape them. This cannot be done in native PHP as the language does not offer overloading functionality for it's output functions (ie. `print` and `echo`). + +Don't worry, escaping can still be done safely, it just means you are responsible for manually escaping each variable on output. Consider creating a snippet for one of the above, built-in escaping functions to make this process easier. diff --git a/vendor/league/plates/doc/content/templates/functions.md b/vendor/league/plates/doc/content/templates/functions.md new file mode 100644 index 0000000..ba41bdb --- /dev/null +++ b/vendor/league/plates/doc/content/templates/functions.md @@ -0,0 +1,46 @@ ++++ +title = "Functions" +linkTitle = "Templates Functions" +[menu.main] +parent = "templates" +weight = 3 ++++ + +Template functions in Plates are accessed using the `$this` pseudo-variable. + +~~~ php +

Hello, escape($name)?>

+~~~ + + +## Custom fuctions + +In addition to the functions included with Plates, it's also possible to add [one-off functions]({{< relref "engine/functions.md" >}}), or even groups of functions, known as [extensions]({{< relref "engine/extensions.md" >}}). + +## Batch function calls + +Sometimes you need to apply more than function to a variable in your templates. This can become somewhat illegible. The `batch()` function helps by allowing you to apply multiple functions, including native PHP functions, to a variable at one time. + +~~~ php + +

Welcome escape(strtoupper(strip_tags($name)))?>

+ + +

Welcome batch($name, 'strip_tags|strtoupper|escape')?>

+~~~ + +The [escape]({{< relref "templates/escaping.md" >}}) functions also support batch function calls. + +~~~ php +

Welcome e($name, 'strip_tags|strtoupper')?>

+~~~ + +The batch functions works well for "piped" functions that accept one parameter, modify it, and then return it. It's important to note that they execute functions left to right and will favour extension functions over native PHP functions if there are conflicts. + +~~~ php + +batch('Jonathan', 'escape|strtolower|strtoupper')?> + + +batch('Jonathan', 'escape|strtoupper|strtolower')?> +~~~ diff --git a/vendor/league/plates/doc/content/templates/inheritance.md b/vendor/league/plates/doc/content/templates/inheritance.md new file mode 100644 index 0000000..d0676e8 --- /dev/null +++ b/vendor/league/plates/doc/content/templates/inheritance.md @@ -0,0 +1,63 @@ ++++ +title = "Inheritance" +linkTitle = "Templates Inheritance" +[menu.main] +parent = "templates" +weight = 7 ++++ + +By combining [layouts]({{< relref "templates/layouts.md" >}}) and [sections]({{< relref "templates/sections.md" >}}), Plates allows you to "build up" your pages using predefined sections. This is best understand using an example: + +## Inheritance example + +The following example illustrates a pretty standard website. Start by creating a site template, which includes your header and footer as well as any predefined content [sections]({{< relref "templates/sections.md" >}}). Notice how Plates makes it possible to even set default section content, in the event that a page doesn't define it. + +{{< code-filename template.php >}} + +~~~ php + + + <?=$this->e($title)?> + + + + + +
+ section('page')?> +
+ + + + + +~~~ + +With the template defined, any page can now "implement" this [layout]({{< relref "templates/layouts.md" >}}). Notice how each section of content is defined between the `start()` and `end()` functions. + +{{< code-filename profile.php >}} + +~~~ php +layout('template', ['title' => 'User Profile']) ?> + +start('page') ?> +

Welcome!

+

Hello e($name)?>

+stop() ?> + +start('sidebar') ?> + +stop() ?> +~~~ diff --git a/vendor/league/plates/doc/content/templates/layouts.md b/vendor/league/plates/doc/content/templates/layouts.md new file mode 100644 index 0000000..88a2ad7 --- /dev/null +++ b/vendor/league/plates/doc/content/templates/layouts.md @@ -0,0 +1,104 @@ ++++ +title = "Layouts" +linkTitle = "Templates Layouts" +[menu.main] +parent = "templates" +weight = 5 ++++ + +The `layout()` function allows you to define a layout template that a template will implement. It's like having separate header and footer templates in one file. + +## Define a layout + +The `layout()` function can be called anywhere in a template, since the layout template is actually rendered second. Typically it's placed at the top of the file. + +~~~ php +layout('template') ?> + +

User Profile

+

Hello, e($name)?>

+~~~ + +This function also works with [folders]({{< relref "engine/folders.md" >}}): + +~~~ php +layout('shared::template') ?> +~~~ + +## Assign data + +To assign data (variables) to a layout template, pass them as an array to the `layout()` function. This data will then be available as locally scoped variables within the layout template. + +~~~ php +layout('template', ['title' => 'User Profile']) ?> +~~~ + +## Accessing the content + +To access the rendered template content within the layout, use the `section()` function, passing `'content'` as the section name. This will return all outputted content from the template that hasn't been defined in a [section]({{< relref "templates/sections.md" >}}). + +~~~ php + + + <?=$this->e($title)?> + + + +section('content')?> + + + +~~~ + +## Stacked layouts + +Plates allows stacking of layouts, allowing even further simplification and organization of templates. Instead of just using one main layout, it's possible to break templates into more specific layouts, which themselves implement a main layout. Consider this example: + +### The main site layout + +{{< code-filename template.php >}} + +~~~ php + + + <?=$this->e($title)?> + + + +section('content')?> + + + +~~~ + +### The blog layout + +{{< code-filename blog.php >}} + +~~~ php +layout('template', ['title' => $title]) ?> + +

The Blog

+ +
+
+ section('content')?> +
+ +
+~~~ + +### A blog article + +{{< code-filename blog-article.php >}} + +~~~ php +layout('blog', ['title' => $article->title]) ?> + +

e($article->title)?>

+
+ e($article->content)?> +
+~~~ diff --git a/vendor/league/plates/doc/content/templates/nesting.md b/vendor/league/plates/doc/content/templates/nesting.md new file mode 100644 index 0000000..6243a27 --- /dev/null +++ b/vendor/league/plates/doc/content/templates/nesting.md @@ -0,0 +1,43 @@ ++++ +title = "Nesting" +linkTitle = "Templates Nesting" +[menu.main] +parent = "templates" +weight = 4 ++++ + +Including another template into the current template is done using the `insert()` function: + +~~~ php +insert('partials/header') ?> + +

Your content.

+ +insert('partials/footer') ?> +~~~ + +The `insert()` function also works with [folders]({{< relref "engine/folders.md" >}}): + +~~~ php +insert('partials::header') ?> +~~~ + +## Alternative syntax + +The `insert()` function automatically outputs the rendered template. If you prefer to manually output the response, use the `fetch()` function instead: + +~~~ php +fetch('partials/header')?> +~~~ + +## Assign data + +To assign data (variables) to a nested template, pass them as an array to the `insert()` or `fetch()` functions. This data will then be available as locally scoped variables within the nested template. + +~~~ php +insert('partials/header', ['name' => 'Jonathan']) ?> + +

Your content.

+ +insert('partials/footer') ?> +~~~ diff --git a/vendor/league/plates/doc/content/templates/overview.md b/vendor/league/plates/doc/content/templates/overview.md new file mode 100644 index 0000000..e6c7c02 --- /dev/null +++ b/vendor/league/plates/doc/content/templates/overview.md @@ -0,0 +1,72 @@ ++++ +title = "Overview" +linkTitle = "Templates Overview" +[menu.main] +parent = "templates" +weight = 1 ++++ + +Plates templates are very simple PHP objects. Generally you'll want to create these using the two factory methods, `make()` and `render()`, in the [engine]({{< relref "engine/overview.md" >}}). For example: + +~~~ php +// Create new Plates instance +$templates = new League\Plates\Engine('/path/to/templates'); + +// Render a template in a subdirectory +echo $templates->render('partials/header'); + +// Render a template +echo $templates->render('profile', ['name' => 'Jonathan']); +~~~ + +For more information about how Plates is designed to be easily added to your application, see the section on [dependency injection]({{< relref "engine/overview.md#dependency-injection" >}}). + +## Manually creating templates + +It's also possible to create templates manually. The only dependency they require is an instance of the [engine]({{< relref "engine/overview.md" >}}) object. For example: + +~~~ php +// Create new Plates instance +$templates = new League\Plates\Engine('/path/to/templates'); + +// Create a new template +$template = new League\Plates\Template\Template($templates, 'profile'); + +// Render the template +echo $template->render(['name' => 'Jonathan']); + +// You can also render the template using the toString() magic method +echo $template; +~~~ + +## Check if a template exists + +When dynamically loading templates, you may need to check if they exist. This can be done using the engine's `exists()` method: + +~~~ php +if ($templates->exists('articles::beginners_guide')) { + // It exists! +} +~~~ + +You can also run this check on an existing template: + +~~~ php +if ($template->exists()) { + // It exists! +} +~~~ + +## Get a template path + +To get a template path from its name, use the engine's `path()` method: + +~~~ php +$path = $templates->path('articles::beginners_guide'); +~~~ + +You can also get the path from an existing template: + +~~~ php +$path = $template->path(); +~~~ diff --git a/vendor/league/plates/doc/content/templates/sections.md b/vendor/league/plates/doc/content/templates/sections.md new file mode 100644 index 0000000..06d4151 --- /dev/null +++ b/vendor/league/plates/doc/content/templates/sections.md @@ -0,0 +1,83 @@ ++++ +title = "Sections" +linkTitle = "Templates Sections" +[menu.main] +parent = "templates" +weight = 6 ++++ + +The `start()` and `stop` functions allow you to build sections (or blocks) of content within your template, and instead of them being rendered directly, they are saved for use elsewhere. For example, in your [layout]({{< relref "templates/layouts.md" >}}) template. + +## Creating sections + +You define the name of the section with the `start()` function. To end a section call the `stop()` function. + +~~~ php +start('welcome') ?> + +

Welcome!

+

Hello e($name)?>

+ +stop() ?> +~~~ + +## Stacking section content + +By default, when you render a section its content will overwrite any existing content for that section. However, it's possible to append/prepend (or stack) the content instead using the `push()` or `unshift()` method respectively. This can be useful for specifying any JavaScript libraries or CSS files required by your child views. + +~~~ php +push('scripts') ?> + +end() ?> + +unshift('styles') ?> + +end() ?> +~~~ + +

The end() function is simply an alias of stop(). These functions can be used interchangeably.

+ +## Accessing section content + +Access rendered section content using the name you assigned in the `start()` method. This variable can be accessed from the current template and layout templates using the `section()` function. + +~~~ php +section('welcome')?> +~~~ + +

Prior to Plates 3.0, accessing template content was done using either the content() or child() functions. For consistency with sections, this is no longer possible.

+ +## Default section content + +In situations where a page doesn't implement a particular section, it's helpful to assign default content. There are a couple ways to do this: + +### Defining it inline + +If the default content can be defined in a single line of code, it's best to simply pass it as the second parameter of the `section()` function. + +~~~ php + +~~~ + +### Use an if statement + +If the default content requires more than a single line of code, it's best to use a simple if statement to check if a section exists, and otherwise display the default. + +~~~ php + +~~~ + diff --git a/vendor/league/plates/doc/content/templates/syntax.md b/vendor/league/plates/doc/content/templates/syntax.md new file mode 100644 index 0000000..6edf881 --- /dev/null +++ b/vendor/league/plates/doc/content/templates/syntax.md @@ -0,0 +1,49 @@ ++++ +title = "Syntax" +linkTitle = "Templates Syntax" +[menu.main] +parent = "templates" +weight = 9 ++++ + +While the actual syntax you use in your templates is entirely your choice (it's just PHP after all), we suggest the following syntax guidelines to help keep templates clean and legible. + +## Guidelines + +- Always use HTML with inline PHP. Never use blocks of PHP. +- Always escape potentially dangerous variables prior to outputting using the built-in escape functions. More on escaping [here]({{< relref "templates/escaping.md" >}}). +- Always use the short echo syntax (`layout('template', ['title' => 'User Profile']) ?> + +

Welcome!

+

Hello e($name)?>

+ +

Friends

+ + + +

Invitations

+

You have some friend invites!

+ +~~~ diff --git a/vendor/league/plates/doc/layouts/_default/baseof.html b/vendor/league/plates/doc/layouts/_default/baseof.html new file mode 100644 index 0000000..23003f3 --- /dev/null +++ b/vendor/league/plates/doc/layouts/_default/baseof.html @@ -0,0 +1,114 @@ + + + + + + + {{ if .IsHome }} + {{ .Site.Title }} - {{ .Site.Params.tagline }} + {{ else }} + {{ partial "title" . }} | {{ .Site.Title -}} + {{ end }} + {{ if .Site.Params.description }} + + {{ end }} + {{ if .Site.Params.Images.favicon }} + + {{ else }} + + {{ end }} + {{ if .Site.Params.Images.appleTouch }} + + {{ else }} + + {{ end }} + + + + + + + + Fork me on GitHub + + +
+ + The League of Extraordinary Packages + +

Our Packages:

+
    + +
+
+ +
+ + + Presented by The League of Extraordinary Packages + +
+ + + + +
+ + {{ $currentPage := . }} + {{ range .Site.Menus.main }} +

{{ .Name }}

+ + {{ end }} +
+
+ {{ template "main" . }} +
+
+ + + + + + + + + +{{ if .Site.GoogleAnalytics }} + +{{ end }} + + + \ No newline at end of file diff --git a/vendor/league/plates/doc/layouts/_default/list.html b/vendor/league/plates/doc/layouts/_default/list.html new file mode 100644 index 0000000..bcd5d0b --- /dev/null +++ b/vendor/league/plates/doc/layouts/_default/list.html @@ -0,0 +1,4 @@ +{{ define "main" }} +

{{ .Title }}

+ {{ .Content }} +{{ end }} \ No newline at end of file diff --git a/vendor/league/plates/doc/layouts/_default/single.html b/vendor/league/plates/doc/layouts/_default/single.html new file mode 100644 index 0000000..bcd5d0b --- /dev/null +++ b/vendor/league/plates/doc/layouts/_default/single.html @@ -0,0 +1,4 @@ +{{ define "main" }} +

{{ .Title }}

+ {{ .Content }} +{{ end }} \ No newline at end of file diff --git a/vendor/league/plates/doc/layouts/partials/title.html b/vendor/league/plates/doc/layouts/partials/title.html new file mode 100644 index 0000000..7094d8d --- /dev/null +++ b/vendor/league/plates/doc/layouts/partials/title.html @@ -0,0 +1,11 @@ +{{ $title := "" }} + +{{ if .Title }} + {{ $title = .Title }} +{{ else if and .IsSection .File }} + {{ $title = path.Base .File.Dir | humanize | title }} +{{ else if and .IsPage .File }} + {{ $title = .File.BaseFileName | humanize | title }} +{{ end }} + +{{ return $title }} \ No newline at end of file diff --git a/vendor/league/plates/doc/layouts/shortcodes/code-filename.html b/vendor/league/plates/doc/layouts/shortcodes/code-filename.html new file mode 100644 index 0000000..0c22bc0 --- /dev/null +++ b/vendor/league/plates/doc/layouts/shortcodes/code-filename.html @@ -0,0 +1 @@ +
{{ index .Params 0 }}
\ No newline at end of file diff --git a/vendor/league/plates/doc/layouts/shortcodes/html.html b/vendor/league/plates/doc/layouts/shortcodes/html.html new file mode 100644 index 0000000..1b4165c --- /dev/null +++ b/vendor/league/plates/doc/layouts/shortcodes/html.html @@ -0,0 +1,3 @@ +{{/* ref: https://anaulin.org/blog/hugo-raw-html-shortcode/ */}} + +{{.Inner}} \ No newline at end of file diff --git a/vendor/league/plates/doc/static/CNAME b/vendor/league/plates/doc/static/CNAME new file mode 100644 index 0000000..1e00c34 --- /dev/null +++ b/vendor/league/plates/doc/static/CNAME @@ -0,0 +1 @@ +platesphp.com \ No newline at end of file diff --git a/vendor/league/plates/doc/static/css/custom.css b/vendor/league/plates/doc/static/css/custom.css new file mode 100644 index 0000000..a0d462f --- /dev/null +++ b/vendor/league/plates/doc/static/css/custom.css @@ -0,0 +1,23 @@ +.github { + position: absolute; + top: 0; + right: 0; + border: 0; + z-index: 1000; +} + +@media screen and (max-width: 1065px) { + .github { + display: none; + } +} + +*:focus { + outline: none; +} +.select2-container { + font-family: "Museo 300"; +} +.version-select { + margin: 8px 25px 0px 45px; +} diff --git a/vendor/league/plates/doc/static/favicon/apple-touch-icon-precomposed.png b/vendor/league/plates/doc/static/favicon/apple-touch-icon-precomposed.png new file mode 100644 index 0000000..460a2ba Binary files /dev/null and b/vendor/league/plates/doc/static/favicon/apple-touch-icon-precomposed.png differ diff --git a/vendor/league/plates/doc/static/favicon/favicon.ico b/vendor/league/plates/doc/static/favicon/favicon.ico new file mode 100644 index 0000000..44d7f3f Binary files /dev/null and b/vendor/league/plates/doc/static/favicon/favicon.ico differ diff --git a/vendor/league/plates/doc/static/images/logo.png b/vendor/league/plates/doc/static/images/logo.png new file mode 100644 index 0000000..19cf68a Binary files /dev/null and b/vendor/league/plates/doc/static/images/logo.png differ diff --git a/vendor/league/plates/example/example.php b/vendor/league/plates/example/example.php new file mode 100644 index 0000000..aaffe05 --- /dev/null +++ b/vendor/league/plates/example/example.php @@ -0,0 +1,12 @@ +addData(['company' => 'The Company Name'], 'layout'); + +// Render a template +echo $templates->render('profile', ['name' => 'Jonathan']); diff --git a/vendor/league/plates/example/templates/layout.php b/vendor/league/plates/example/templates/layout.php new file mode 100644 index 0000000..5b5847c --- /dev/null +++ b/vendor/league/plates/example/templates/layout.php @@ -0,0 +1,12 @@ + + + <?=$this->e($title)?> | <?=$this->e($company)?> + + + +section('content')?> + +section('scripts')?> + + + \ No newline at end of file diff --git a/vendor/league/plates/example/templates/profile.php b/vendor/league/plates/example/templates/profile.php new file mode 100644 index 0000000..0797e46 --- /dev/null +++ b/vendor/league/plates/example/templates/profile.php @@ -0,0 +1,12 @@ +layout('layout', ['title' => 'User Profile']) ?> + +

User Profile

+

Hello, e($name)?>!

+ +insert('sidebar') ?> + +push('scripts') ?> + +end() ?> \ No newline at end of file diff --git a/vendor/league/plates/example/templates/sidebar.php b/vendor/league/plates/example/templates/sidebar.php new file mode 100644 index 0000000..13d9ea8 --- /dev/null +++ b/vendor/league/plates/example/templates/sidebar.php @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/vendor/league/plates/phpunit.xml.dist b/vendor/league/plates/phpunit.xml.dist new file mode 100644 index 0000000..2184ac9 --- /dev/null +++ b/vendor/league/plates/phpunit.xml.dist @@ -0,0 +1,36 @@ + + + + + + ./tests + + + + + + src + + + + + + + + + + diff --git a/vendor/league/plates/src/Engine.php b/vendor/league/plates/src/Engine.php new file mode 100644 index 0000000..6c89642 --- /dev/null +++ b/vendor/league/plates/src/Engine.php @@ -0,0 +1,279 @@ +directory = new Directory($directory); + $this->fileExtension = new FileExtension($fileExtension); + $this->folders = new Folders(); + $this->functions = new Functions(); + $this->data = new Data(); + } + + /** + * Set path to templates directory. + * @param string|null $directory Pass null to disable the default directory. + * @return Engine + */ + public function setDirectory($directory) + { + $this->directory->set($directory); + + return $this; + } + + /** + * Get path to templates directory. + * @return string + */ + public function getDirectory() + { + return $this->directory->get(); + } + + /** + * Set the template file extension. + * @param string|null $fileExtension Pass null to manually set it. + * @return Engine + */ + public function setFileExtension($fileExtension) + { + $this->fileExtension->set($fileExtension); + + return $this; + } + + /** + * Get the template file extension. + * @return string + */ + public function getFileExtension() + { + return $this->fileExtension->get(); + } + + /** + * Add a new template folder for grouping templates under different namespaces. + * @param string $name + * @param string $directory + * @param boolean $fallback + * @return Engine + */ + public function addFolder($name, $directory, $fallback = false) + { + $this->folders->add($name, $directory, $fallback); + + return $this; + } + + /** + * Remove a template folder. + * @param string $name + * @return Engine + */ + public function removeFolder($name) + { + $this->folders->remove($name); + + return $this; + } + + /** + * Get collection of all template folders. + * @return Folders + */ + public function getFolders() + { + return $this->folders; + } + + /** + * Add preassigned template data. + * @param array $data; + * @param null|string|array $templates; + * @return Engine + */ + public function addData(array $data, $templates = null) + { + $this->data->add($data, $templates); + + return $this; + } + + /** + * Get all preassigned template data. + * @param null|string $template; + * @return array + */ + public function getData($template = null) + { + return $this->data->get($template); + } + + /** + * Register a new template function. + * @param string $name; + * @param callback $callback; + * @return Engine + */ + public function registerFunction($name, $callback) + { + $this->functions->add($name, $callback); + + return $this; + } + + /** + * Remove a template function. + * @param string $name; + * @return Engine + */ + public function dropFunction($name) + { + $this->functions->remove($name); + + return $this; + } + + /** + * Get a template function. + * @param string $name + * @return Func + */ + public function getFunction($name) + { + return $this->functions->get($name); + } + + /** + * Check if a template function exists. + * @param string $name + * @return boolean + */ + public function doesFunctionExist($name) + { + return $this->functions->exists($name); + } + + /** + * Load an extension. + * @param ExtensionInterface $extension + * @return Engine + */ + public function loadExtension(ExtensionInterface $extension) + { + $extension->register($this); + + return $this; + } + + /** + * Load multiple extensions. + * @param array $extensions + * @return Engine + */ + public function loadExtensions(array $extensions = array()) + { + foreach ($extensions as $extension) { + $this->loadExtension($extension); + } + + return $this; + } + + /** + * Get a template path. + * @param string $name + * @return string + */ + public function path($name) + { + $name = new Name($this, $name); + + return $name->getPath(); + } + + /** + * Check if a template exists. + * @param string $name + * @return boolean + */ + public function exists($name) + { + $name = new Name($this, $name); + + return $name->doesPathExist(); + } + + /** + * Create a new template. + * @param string $name + * @return Template + */ + public function make($name) + { + return new Template($this, $name); + } + + /** + * Create a new template and render it. + * @param string $name + * @param array $data + * @return string + */ + public function render($name, array $data = array()) + { + return $this->make($name)->render($data); + } +} diff --git a/vendor/league/plates/src/Extension/Asset.php b/vendor/league/plates/src/Extension/Asset.php new file mode 100644 index 0000000..1db5393 --- /dev/null +++ b/vendor/league/plates/src/Extension/Asset.php @@ -0,0 +1,85 @@ +path = rtrim($path, '/'); + $this->filenameMethod = $filenameMethod; + } + + /** + * Register extension function. + * @param Engine $engine + * @return null + */ + public function register(Engine $engine) + { + $engine->registerFunction('asset', array($this, 'cachedAssetUrl')); + } + + /** + * Create "cache busted" asset URL. + * @param string $url + * @return string + */ + public function cachedAssetUrl($url) + { + $filePath = $this->path . '/' . ltrim($url, '/'); + + if (!file_exists($filePath)) { + throw new LogicException( + 'Unable to locate the asset "' . $url . '" in the "' . $this->path . '" directory.' + ); + } + + $lastUpdated = filemtime($filePath); + $pathInfo = pathinfo($url); + + if ($pathInfo['dirname'] === '.') { + $directory = ''; + } elseif ($pathInfo['dirname'] === DIRECTORY_SEPARATOR) { + $directory = '/'; + } else { + $directory = $pathInfo['dirname'] . '/'; + } + + if ($this->filenameMethod) { + return $directory . $pathInfo['filename'] . '.' . $lastUpdated . '.' . $pathInfo['extension']; + } + + return $directory . $pathInfo['filename'] . '.' . $pathInfo['extension'] . '?v=' . $lastUpdated; + } +} diff --git a/vendor/league/plates/src/Extension/ExtensionInterface.php b/vendor/league/plates/src/Extension/ExtensionInterface.php new file mode 100644 index 0000000..0164d1e --- /dev/null +++ b/vendor/league/plates/src/Extension/ExtensionInterface.php @@ -0,0 +1,13 @@ +uri = $uri; + $this->parts = explode('/', $this->uri); + } + + /** + * Register extension functions. + * @param Engine $engine + * @return null + */ + public function register(Engine $engine) + { + $engine->registerFunction('uri', array($this, 'runUri')); + } + + /** + * Perform URI check. + * @param null|integer|string $var1 + * @param mixed $var2 + * @param mixed $var3 + * @param mixed $var4 + * @return mixed + */ + public function runUri($var1 = null, $var2 = null, $var3 = null, $var4 = null) + { + if (is_null($var1)) { + return $this->uri; + } + + if (is_numeric($var1) and is_null($var2)) { + return array_key_exists($var1, $this->parts) ? $this->parts[$var1] : null; + } + + if (is_numeric($var1) and is_string($var2)) { + return $this->checkUriSegmentMatch($var1, $var2, $var3, $var4); + } + + if (is_string($var1)) { + return $this->checkUriRegexMatch($var1, $var2, $var3); + } + + throw new LogicException('Invalid use of the uri function.'); + } + + /** + * Perform a URI segment match. + * @param integer $key + * @param string $string + * @param mixed $returnOnTrue + * @param mixed $returnOnFalse + * @return mixed + */ + protected function checkUriSegmentMatch($key, $string, $returnOnTrue = null, $returnOnFalse = null) + { + if (array_key_exists($key, $this->parts) && $this->parts[$key] === $string) { + return is_null($returnOnTrue) ? true : $returnOnTrue; + } + + return is_null($returnOnFalse) ? false : $returnOnFalse; + } + + /** + * Perform a regular express match. + * @param string $regex + * @param mixed $returnOnTrue + * @param mixed $returnOnFalse + * @return mixed + */ + protected function checkUriRegexMatch($regex, $returnOnTrue = null, $returnOnFalse = null) + { + if (preg_match('#^' . $regex . '$#', $this->uri) === 1) { + return is_null($returnOnTrue) ? true : $returnOnTrue; + } + + return is_null($returnOnFalse) ? false : $returnOnFalse; + } +} diff --git a/vendor/league/plates/src/Template/Data.php b/vendor/league/plates/src/Template/Data.php new file mode 100644 index 0000000..aa4d1e1 --- /dev/null +++ b/vendor/league/plates/src/Template/Data.php @@ -0,0 +1,93 @@ +shareWithAll($data); + } + + if (is_array($templates)) { + return $this->shareWithSome($data, $templates); + } + + if (is_string($templates)) { + return $this->shareWithSome($data, array($templates)); + } + + throw new LogicException( + 'The templates variable must be null, an array or a string, ' . gettype($templates) . ' given.' + ); + } + + /** + * Add data shared with all templates. + * @param array $data; + * @return Data + */ + public function shareWithAll($data) + { + $this->sharedVariables = array_merge($this->sharedVariables, $data); + + return $this; + } + + /** + * Add data shared with some templates. + * @param array $data; + * @param array $templates; + * @return Data + */ + public function shareWithSome($data, array $templates) + { + foreach ($templates as $template) { + if (isset($this->templateVariables[$template])) { + $this->templateVariables[$template] = array_merge($this->templateVariables[$template], $data); + } else { + $this->templateVariables[$template] = $data; + } + } + + return $this; + } + + /** + * Get template data. + * @param null|string $template; + * @return array + */ + public function get($template = null) + { + if (isset($template, $this->templateVariables[$template])) { + return array_merge($this->sharedVariables, $this->templateVariables[$template]); + } + + return $this->sharedVariables; + } +} diff --git a/vendor/league/plates/src/Template/Directory.php b/vendor/league/plates/src/Template/Directory.php new file mode 100644 index 0000000..f5de537 --- /dev/null +++ b/vendor/league/plates/src/Template/Directory.php @@ -0,0 +1,53 @@ +set($path); + } + + /** + * Set path to templates directory. + * @param string|null $path Pass null to disable the default directory. + * @return Directory + */ + public function set($path) + { + if (!is_null($path) and !is_dir($path)) { + throw new LogicException( + 'The specified path "' . $path . '" does not exist.' + ); + } + + $this->path = $path; + + return $this; + } + + /** + * Get path to templates directory. + * @return string + */ + public function get() + { + return $this->path; + } +} diff --git a/vendor/league/plates/src/Template/FileExtension.php b/vendor/league/plates/src/Template/FileExtension.php new file mode 100644 index 0000000..57646bd --- /dev/null +++ b/vendor/league/plates/src/Template/FileExtension.php @@ -0,0 +1,45 @@ +set($fileExtension); + } + + /** + * Set the template file extension. + * @param null|string $fileExtension + * @return FileExtension + */ + public function set($fileExtension) + { + $this->fileExtension = $fileExtension; + + return $this; + } + + /** + * Get the template file extension. + * @return string + */ + public function get() + { + return $this->fileExtension; + } +} diff --git a/vendor/league/plates/src/Template/Folder.php b/vendor/league/plates/src/Template/Folder.php new file mode 100644 index 0000000..01fcbdd --- /dev/null +++ b/vendor/league/plates/src/Template/Folder.php @@ -0,0 +1,109 @@ +setName($name); + $this->setPath($path); + $this->setFallback($fallback); + } + + /** + * Set the folder name. + * @param string $name + * @return Folder + */ + public function setName($name) + { + $this->name = $name; + + return $this; + } + + /** + * Get the folder name. + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set the folder path. + * @param string $path + * @return Folder + */ + public function setPath($path) + { + if (!is_dir($path)) { + throw new LogicException('The specified directory path "' . $path . '" does not exist.'); + } + + $this->path = $path; + + return $this; + } + + /** + * Get the folder path. + * @return string + */ + public function getPath() + { + return $this->path; + } + + /** + * Set the folder fallback status. + * @param boolean $fallback + * @return Folder + */ + public function setFallback($fallback) + { + $this->fallback = $fallback; + + return $this; + } + + /** + * Get the folder fallback status. + * @return boolean + */ + public function getFallback() + { + return $this->fallback; + } +} diff --git a/vendor/league/plates/src/Template/Folders.php b/vendor/league/plates/src/Template/Folders.php new file mode 100644 index 0000000..9bf266a --- /dev/null +++ b/vendor/league/plates/src/Template/Folders.php @@ -0,0 +1,75 @@ +exists($name)) { + throw new LogicException('The template folder "' . $name . '" is already being used.'); + } + + $this->folders[$name] = new Folder($name, $path, $fallback); + + return $this; + } + + /** + * Remove a template folder. + * @param string $name + * @return Folders + */ + public function remove($name) + { + if (!$this->exists($name)) { + throw new LogicException('The template folder "' . $name . '" was not found.'); + } + + unset($this->folders[$name]); + + return $this; + } + + /** + * Get a template folder. + * @param string $name + * @return Folder + */ + public function get($name) + { + if (!$this->exists($name)) { + throw new LogicException('The template folder "' . $name . '" was not found.'); + } + + return $this->folders[$name]; + } + + /** + * Check if a template folder exists. + * @param string $name + * @return boolean + */ + public function exists($name) + { + return isset($this->folders[$name]); + } +} diff --git a/vendor/league/plates/src/Template/Func.php b/vendor/league/plates/src/Template/Func.php new file mode 100644 index 0000000..79141f4 --- /dev/null +++ b/vendor/league/plates/src/Template/Func.php @@ -0,0 +1,107 @@ +setName($name); + $this->setCallback($callback); + } + + /** + * Set the function name. + * @param string $name + * @return Func + */ + public function setName($name) + { + if (preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $name) !== 1) { + throw new LogicException( + 'Not a valid function name.' + ); + } + + $this->name = $name; + + return $this; + } + + /** + * Get the function name. + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set the function callback + * @param callable $callback + * @return Func + */ + public function setCallback($callback) + { + if (!is_callable($callback, true)) { + throw new LogicException( + 'Not a valid function callback.' + ); + } + + $this->callback = $callback; + + return $this; + } + + /** + * Get the function callback. + * @return callable + */ + public function getCallback() + { + return $this->callback; + } + + /** + * Call the function. + * @param Template $template + * @param array $arguments + * @return mixed + */ + public function call(Template $template = null, $arguments = array()) + { + if (is_array($this->callback) and + isset($this->callback[0]) and + $this->callback[0] instanceof ExtensionInterface + ) { + $this->callback[0]->template = $template; + } + + return call_user_func_array($this->callback, $arguments); + } +} diff --git a/vendor/league/plates/src/Template/Functions.php b/vendor/league/plates/src/Template/Functions.php new file mode 100644 index 0000000..e0e4c2c --- /dev/null +++ b/vendor/league/plates/src/Template/Functions.php @@ -0,0 +1,78 @@ +exists($name)) { + throw new LogicException( + 'The template function name "' . $name . '" is already registered.' + ); + } + + $this->functions[$name] = new Func($name, $callback); + + return $this; + } + + /** + * Remove a template function. + * @param string $name; + * @return Functions + */ + public function remove($name) + { + if (!$this->exists($name)) { + throw new LogicException( + 'The template function "' . $name . '" was not found.' + ); + } + + unset($this->functions[$name]); + + return $this; + } + + /** + * Get a template function. + * @param string $name + * @return Func + */ + public function get($name) + { + if (!$this->exists($name)) { + throw new LogicException('The template function "' . $name . '" was not found.'); + } + + return $this->functions[$name]; + } + + /** + * Check if a template function exists. + * @param string $name + * @return boolean + */ + public function exists($name) + { + return isset($this->functions[$name]); + } +} diff --git a/vendor/league/plates/src/Template/Name.php b/vendor/league/plates/src/Template/Name.php new file mode 100644 index 0000000..a866923 --- /dev/null +++ b/vendor/league/plates/src/Template/Name.php @@ -0,0 +1,206 @@ +setEngine($engine); + $this->setName($name); + } + + /** + * Set the engine. + * @param Engine $engine + * @return Name + */ + public function setEngine(Engine $engine) + { + $this->engine = $engine; + + return $this; + } + + /** + * Get the engine. + * @return Engine + */ + public function getEngine() + { + return $this->engine; + } + + /** + * Set the original name and parse it. + * @param string $name + * @return Name + */ + public function setName($name) + { + $this->name = $name; + + $parts = explode('::', $this->name); + + if (count($parts) === 1) { + $this->setFile($parts[0]); + } elseif (count($parts) === 2) { + $this->setFolder($parts[0]); + $this->setFile($parts[1]); + } else { + throw new LogicException( + 'The template name "' . $this->name . '" is not valid. ' . + 'Do not use the folder namespace separator "::" more than once.' + ); + } + + return $this; + } + + /** + * Get the original name. + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set the parsed template folder. + * @param string $folder + * @return Name + */ + public function setFolder($folder) + { + $this->folder = $this->engine->getFolders()->get($folder); + + return $this; + } + + /** + * Get the parsed template folder. + * @return string + */ + public function getFolder() + { + return $this->folder; + } + + /** + * Set the parsed template file. + * @param string $file + * @return Name + */ + public function setFile($file) + { + if ($file === '') { + throw new LogicException( + 'The template name "' . $this->name . '" is not valid. ' . + 'The template name cannot be empty.' + ); + } + + $this->file = $file; + + if (!is_null($this->engine->getFileExtension())) { + $this->file .= '.' . $this->engine->getFileExtension(); + } + + return $this; + } + + /** + * Get the parsed template file. + * @return string + */ + public function getFile() + { + return $this->file; + } + + /** + * Resolve template path. + * @return string + */ + public function getPath() + { + if (is_null($this->folder)) { + return "{$this->getDefaultDirectory()}/{$this->file}"; + } + + $path = "{$this->folder->getPath()}/{$this->file}"; + + if ( + !is_file($path) + && $this->folder->getFallback() + && is_file("{$this->getDefaultDirectory()}/{$this->file}") + ) { + $path = "{$this->getDefaultDirectory()}/{$this->file}"; + } + + return $path; + } + + /** + * Check if template path exists. + * @return boolean + */ + public function doesPathExist() + { + return is_file($this->getPath()); + } + + /** + * Get the default templates directory. + * @return string + */ + protected function getDefaultDirectory() + { + $directory = $this->engine->getDirectory(); + + if (is_null($directory)) { + throw new LogicException( + 'The template name "' . $this->name . '" is not valid. '. + 'The default directory has not been defined.' + ); + } + + return $directory; + } +} diff --git a/vendor/league/plates/src/Template/Template.php b/vendor/league/plates/src/Template/Template.php new file mode 100644 index 0000000..64ee438 --- /dev/null +++ b/vendor/league/plates/src/Template/Template.php @@ -0,0 +1,384 @@ +engine = $engine; + $this->name = new Name($engine, $name); + + $this->data($this->engine->getData($name)); + } + + /** + * Magic method used to call extension functions. + * @param string $name + * @param array $arguments + * @return mixed + */ + public function __call($name, $arguments) + { + return $this->engine->getFunction($name)->call($this, $arguments); + } + + /** + * Alias for render() method. + * @throws \Throwable + * @throws \Exception + * @return string + */ + public function __toString() + { + return $this->render(); + } + + /** + * Assign or get template data. + * @param array $data + * @return mixed + */ + public function data(array $data = null) + { + if (is_null($data)) { + return $this->data; + } + + $this->data = array_merge($this->data, $data); + } + + /** + * Check if the template exists. + * @return boolean + */ + public function exists() + { + return $this->name->doesPathExist(); + } + + /** + * Get the template path. + * @return string + */ + public function path() + { + return $this->name->getPath(); + } + + /** + * Render the template and layout. + * @param array $data + * @throws \Throwable + * @throws \Exception + * @return string + */ + public function render(array $data = array()) + { + $this->data($data); + unset($data); + extract($this->data); + + if (!$this->exists()) { + throw new LogicException( + 'The template "' . $this->name->getName() . '" could not be found at "' . $this->path() . '".' + ); + } + + try { + $level = ob_get_level(); + ob_start(); + + include $this->path(); + + $content = ob_get_clean(); + + if (isset($this->layoutName)) { + $layout = $this->engine->make($this->layoutName); + $layout->sections = array_merge($this->sections, array('content' => $content)); + $content = $layout->render($this->layoutData); + } + + return $content; + } catch (Throwable $e) { + while (ob_get_level() > $level) { + ob_end_clean(); + } + + throw $e; + } catch (Exception $e) { + while (ob_get_level() > $level) { + ob_end_clean(); + } + + throw $e; + } + } + + /** + * Set the template's layout. + * @param string $name + * @param array $data + * @return null + */ + public function layout($name, array $data = array()) + { + $this->layoutName = $name; + $this->layoutData = $data; + } + + /** + * Start a new section block. + * @param string $name + * @return null + */ + public function start($name) + { + if ($name === 'content') { + throw new LogicException( + 'The section name "content" is reserved.' + ); + } + + if ($this->sectionName) { + throw new LogicException('You cannot nest sections within other sections.'); + } + + $this->sectionName = $name; + + ob_start(); + } + + /** + * Start a new section block in APPEND mode. + * @param string $name + * @return null + */ + public function push($name) + { + $this->appendSection = true; /* for backward compatibility */ + $this->sectionMode = self::SECTION_MODE_APPEND; + $this->start($name); + } + + /** + * Start a new section block in PREPEND mode. + * @param string $name + * @return null + */ + public function unshift($name) + { + $this->appendSection = false; /* for backward compatibility */ + $this->sectionMode = self::SECTION_MODE_PREPEND; + $this->start($name); + } + + /** + * Stop the current section block. + * @return null + */ + public function stop() + { + if (is_null($this->sectionName)) { + throw new LogicException( + 'You must start a section before you can stop it.' + ); + } + + if (!isset($this->sections[$this->sectionName])) { + $this->sections[$this->sectionName] = ''; + } + + switch ($this->sectionMode) { + + case self::SECTION_MODE_REWRITE: + $this->sections[$this->sectionName] = ob_get_clean(); + break; + + case self::SECTION_MODE_APPEND: + $this->sections[$this->sectionName] .= ob_get_clean(); + break; + + case self::SECTION_MODE_PREPEND: + $this->sections[$this->sectionName] = ob_get_clean().$this->sections[$this->sectionName]; + break; + + } + $this->sectionName = null; + $this->sectionMode = self::SECTION_MODE_REWRITE; + $this->appendSection = false; /* for backward compatibility */ + } + + /** + * Alias of stop(). + * @return null + */ + public function end() + { + $this->stop(); + } + + /** + * Returns the content for a section block. + * @param string $name Section name + * @param string $default Default section content + * @return string|null + */ + public function section($name, $default = null) + { + if (!isset($this->sections[$name])) { + return $default; + } + + return $this->sections[$name]; + } + + /** + * Fetch a rendered template. + * @param string $name + * @param array $data + * @return string + */ + public function fetch($name, array $data = array()) + { + return $this->engine->render($name, $data); + } + + /** + * Output a rendered template. + * @param string $name + * @param array $data + * @return null + */ + public function insert($name, array $data = array()) + { + echo $this->engine->render($name, $data); + } + + /** + * Apply multiple functions to variable. + * @param mixed $var + * @param string $functions + * @return mixed + */ + public function batch($var, $functions) + { + foreach (explode('|', $functions) as $function) { + if ($this->engine->doesFunctionExist($function)) { + $var = call_user_func(array($this, $function), $var); + } elseif (is_callable($function)) { + $var = call_user_func($function, $var); + } else { + throw new LogicException( + 'The batch function could not find the "' . $function . '" function.' + ); + } + } + + return $var; + } + + /** + * Escape string. + * @param string $string + * @param null|string $functions + * @return string + */ + public function escape($string, $functions = null) + { + static $flags; + + if (!isset($flags)) { + $flags = ENT_QUOTES | (defined('ENT_SUBSTITUTE') ? ENT_SUBSTITUTE : 0); + } + + if ($functions) { + $string = $this->batch($string, $functions); + } + + return htmlspecialchars($string, $flags, 'UTF-8'); + } + + /** + * Alias to escape function. + * @param string $string + * @param null|string $functions + * @return string + */ + public function e($string, $functions = null) + { + return $this->escape($string, $functions); + } +} diff --git a/vendor/odan/session/.cs.php b/vendor/odan/session/.cs.php new file mode 100644 index 0000000..ee27392 --- /dev/null +++ b/vendor/odan/session/.cs.php @@ -0,0 +1,44 @@ +setUsingCache(false) + ->setRiskyAllowed(true) + //->setCacheFile(__DIR__ . '/.php_cs.cache') + ->setRules([ + '@PSR1' => true, + '@PSR2' => true, + '@Symfony' => true, + 'psr4' => true, + // custom rules + 'align_multiline_comment' => ['comment_type' => 'phpdocs_only'], // psr-5 + 'phpdoc_to_comment' => false, + 'no_superfluous_phpdoc_tags' => false, + 'array_indentation' => true, + 'array_syntax' => ['syntax' => 'short'], + 'cast_spaces' => ['space' => 'none'], + 'concat_space' => ['spacing' => 'one'], + 'compact_nullable_typehint' => true, + 'declare_equal_normalize' => ['space' => 'single'], + 'increment_style' => ['style' => 'post'], + 'list_syntax' => ['syntax' => 'short'], + 'no_short_echo_tag' => true, + 'phpdoc_add_missing_param_annotation' => ['only_untyped' => false], + 'phpdoc_align' => false, + 'phpdoc_no_empty_return' => false, + 'phpdoc_order' => true, // psr-5 + 'phpdoc_no_useless_inheritdoc' => false, + 'protected_to_private' => false, + 'yoda_style' => false, + 'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'], + 'ordered_imports' => [ + 'sort_algorithm' => 'alpha', + 'imports_order' => ['class', 'const', 'function'] + ], + 'single_line_throw' => false, + ]) + ->setFinder(PhpCsFixer\Finder::create() + ->in(__DIR__ . '/src') + ->in(__DIR__ . '/tests') + ->name('*.php') + ->ignoreDotFiles(true) + ->ignoreVCS(true)); diff --git a/vendor/odan/session/.github/workflows/build.yml b/vendor/odan/session/.github/workflows/build.yml new file mode 100644 index 0000000..2d8b905 --- /dev/null +++ b/vendor/odan/session/.github/workflows/build.yml @@ -0,0 +1,48 @@ +name: build + +on: [push, pull_request] + +jobs: + run: + runs-on: ${{ matrix.operating-system }} + strategy: + matrix: + operating-system: [ubuntu-latest] + php-versions: ['7.3', '7.4', '8.0'] + name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }} + + steps: + - name: Checkout + uses: actions/checkout@v1 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + extensions: mbstring, pdo, pdo_mysql, intl, zip + coverage: none + + - name: Check PHP Version + run: php -v + + - name: Check Composer Version + run: composer -V + + - name: Check PHP Extensions + run: php -m + + - name: Validate composer.json and composer.lock + run: composer validate + + - name: Install dependencies for PHP 7 + if: matrix.php-versions < '8.0' + run: composer update --prefer-dist --no-progress + + - name: Install dependencies for PHP 8 + if: matrix.php-versions >= '8.0' + run: composer update --prefer-dist --no-progress --ignore-platform-reqs + + - name: Run test suite + run: composer check + env: + PHP_CS_FIXER_IGNORE_ENV: 1 diff --git a/vendor/odan/session/LICENSE b/vendor/odan/session/LICENSE new file mode 100644 index 0000000..fa19b85 --- /dev/null +++ b/vendor/odan/session/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2021 odan + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/vendor/odan/session/README.md b/vendor/odan/session/README.md new file mode 100644 index 0000000..65e0f81 --- /dev/null +++ b/vendor/odan/session/README.md @@ -0,0 +1,14 @@ +# Session handler + +[![Latest Version on Packagist](https://img.shields.io/github/release/odan/session.svg)](https://github.com/odan/session/releases) +[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE) +[![Build Status](https://github.com/odan/session/workflows/build/badge.svg)](https://github.com/odan/session/actions) +[![Code Coverage](https://scrutinizer-ci.com/g/odan/session/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/odan/session/?branch=master) +[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/odan/session/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/odan/session/?branch=master) +[![Total Downloads](https://img.shields.io/packagist/dt/odan/session.svg)](https://packagist.org/packages/odan/session/stats) + +A session handler for PHP + +* Issues: +* Documentation for v4: +* Documentation for v5: diff --git a/vendor/odan/session/_config.yml b/vendor/odan/session/_config.yml new file mode 100644 index 0000000..c419263 --- /dev/null +++ b/vendor/odan/session/_config.yml @@ -0,0 +1 @@ +theme: jekyll-theme-cayman \ No newline at end of file diff --git a/vendor/odan/session/composer.json b/vendor/odan/session/composer.json new file mode 100644 index 0000000..56d8a8b --- /dev/null +++ b/vendor/odan/session/composer.json @@ -0,0 +1,56 @@ +{ + "name": "odan/session", + "type": "library", + "description": "A Slim session handler", + "keywords": [ + "slim", + "session" + ], + "homepage": "https://github.com/odan/session", + "license": "MIT", + "require": { + "php": "^7.3 || ^8.0", + "psr/http-message": "^1.0", + "psr/http-server-handler": "^1.0", + "psr/http-server-middleware": "^1.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.16", + "middlewares/utils": "^3.1", + "overtrue/phplint": "^1.1 || ^2.0", + "phpstan/phpstan": "0.*", + "phpunit/phpunit": "^7 || ^8 || ^9", + "slim/psr7": "^1.1", + "squizlabs/php_codesniffer": "^3.4" + }, + "scripts": { + "check": [ + "@lint", + "@cs:check", + "@sniffer:check", + "@phpstan", + "@test:coverage" + ], + "cs:check": "php-cs-fixer fix --dry-run --format=txt --verbose --diff --diff-format=udiff --config=.cs.php", + "cs:fix": "php-cs-fixer fix --config=.cs.php", + "lint": "phplint ./ --exclude=vendor --no-interaction --no-cache", + "phpstan": "phpstan analyse src --level=max -c phpstan.neon --no-progress --ansi", + "sniffer:check": "phpcs --standard=phpcs.xml", + "sniffer:fix": "phpcbf --standard=phpcs.xml", + "test": "phpunit --configuration phpunit.xml --do-not-cache-result", + "test:coverage": "phpunit --configuration phpunit.xml --do-not-cache-result --coverage-clover build/logs/clover.xml --coverage-html build/coverage" + }, + "autoload": { + "psr-4": { + "Odan\\Session\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "Odan\\Session\\Test\\": "tests/" + } + }, + "config": { + "sort-packages": true + } +} diff --git a/vendor/odan/session/phpcs.xml b/vendor/odan/session/phpcs.xml new file mode 100644 index 0000000..55c4e02 --- /dev/null +++ b/vendor/odan/session/phpcs.xml @@ -0,0 +1,39 @@ + + + + + + + + + ./src + ./tests + + + + + + warning + + + warning + */tests/ + + + warning + + + warning + + + + warning + + + warning + + \ No newline at end of file diff --git a/vendor/odan/session/phpstan.neon b/vendor/odan/session/phpstan.neon new file mode 100644 index 0000000..8789eb7 --- /dev/null +++ b/vendor/odan/session/phpstan.neon @@ -0,0 +1,4 @@ +parameters: + checkGenericClassInNonGenericObjectType: false + checkMissingIterableValueType: false + inferPrivatePropertyTypeFromConstructor: true diff --git a/vendor/odan/session/phpunit.xml b/vendor/odan/session/phpunit.xml new file mode 100644 index 0000000..ee34618 --- /dev/null +++ b/vendor/odan/session/phpunit.xml @@ -0,0 +1,17 @@ + + + + + tests + + + + + src + + vendor + build + + + + diff --git a/vendor/odan/session/src/Exception/SessionException.php b/vendor/odan/session/src/Exception/SessionException.php new file mode 100644 index 0000000..23cde5a --- /dev/null +++ b/vendor/odan/session/src/Exception/SessionException.php @@ -0,0 +1,12 @@ +storage = $storage; + $this->storageKey = $storageKey; + } + + /** + * {@inheritdoc} + */ + public function add(string $key, string $message): void + { + // Create array for this key + if (!isset($this->storage[$this->storageKey][$key])) { + $this->storage[$this->storageKey][$key] = []; + } + + // Push onto the array + $this->storage[$this->storageKey][$key][] = $message; + } + + /** + * {@inheritdoc} + */ + public function get(string $key): array + { + if (!$this->has($key)) { + return []; + } + + $return = $this->storage[$this->storageKey][$key]; + unset($this->storage[$this->storageKey][$key]); + + return (array)$return; + } + + /** + * {@inheritdoc} + */ + public function has(string $key): bool + { + return isset($this->storage[$this->storageKey][$key]); + } + + /** + * {@inheritdoc} + */ + public function clear(): void + { + if ($this->storage->offsetExists($this->storageKey)) { + $this->storage->offsetUnset($this->storageKey); + } + } + + /** + * {@inheritdoc} + */ + public function set(string $key, array $messages): void + { + $this->storage[$this->storageKey][$key] = $messages; + } + + /** + * {@inheritdoc} + */ + public function all(): array + { + $result = $this->storage[$this->storageKey] ?? []; + $this->clear(); + + return (array)$result; + } +} diff --git a/vendor/odan/session/src/FlashInterface.php b/vendor/odan/session/src/FlashInterface.php new file mode 100644 index 0000000..bfb6307 --- /dev/null +++ b/vendor/odan/session/src/FlashInterface.php @@ -0,0 +1,61 @@ + $messages The messages + * + * @return void + */ + public function set(string $key, array $messages): void; + + /** + * Gets all flash messages. + * + * @return array All messages. Can be an empty array. + */ + public function all(): array; +} diff --git a/vendor/odan/session/src/MemorySession.php b/vendor/odan/session/src/MemorySession.php new file mode 100644 index 0000000..4ca2edd --- /dev/null +++ b/vendor/odan/session/src/MemorySession.php @@ -0,0 +1,285 @@ +storage = new ArrayObject(); + $this->flash = new Flash($this->storage); + + $this->setCookieParams(0, '/', '', false, true); + + $config = []; + foreach ((array)ini_get_all('session') as $key => $value) { + $config[substr($key, 8)] = $value['local_value']; + } + + $this->setOptions($config); + } + + /** + * Get storage. + * + * @return ArrayObject The storage + */ + public function getStorage(): ArrayObject + { + return $this->storage; + } + + /** + * Get flash instance. + * + * @return FlashInterface The flash instance + */ + public function getFlash(): FlashInterface + { + return $this->flash; + } + + /** + * {@inheritdoc} + */ + public function start(): void + { + if (!$this->id) { + $this->regenerateId(); + } + + $this->started = true; + } + + /** + * {@inheritdoc} + */ + public function isStarted(): bool + { + return $this->started; + } + + /** + * {@inheritdoc} + */ + public function regenerateId(): void + { + $this->id = str_replace('.', '', uniqid('sess_', true)); + } + + /** + * {@inheritdoc} + */ + public function destroy(): void + { + $this->storage->exchangeArray([]); + $this->regenerateId(); + } + + /** + * {@inheritdoc} + */ + public function getId(): string + { + return $this->id; + } + + /** + * {@inheritdoc} + */ + public function setId(string $id): void + { + if ($this->isStarted()) { + throw new RuntimeException('Cannot change session id when session is active'); + } + + $this->id = $id; + } + + /** + * {@inheritdoc} + */ + public function getName(): string + { + return $this->name; + } + + /** + * {@inheritdoc} + */ + public function setName(string $name): void + { + if ($this->isStarted()) { + throw new RuntimeException('Cannot change session name when session is active'); + } + $this->name = $name; + } + + /** + * {@inheritdoc} + */ + public function has(string $key): bool + { + if (empty($this->storage)) { + return false; + } + + return $this->storage->offsetExists($key); + } + + /** + * {@inheritdoc} + */ + public function get(string $key) + { + if ($this->has($key)) { + return $this->storage->offsetGet($key); + } + + return null; + } + + /** + * {@inheritdoc} + */ + public function all(): array + { + return (array)$this->storage; + } + + /** + * {@inheritdoc} + */ + public function set(string $key, $value): void + { + $this->storage[$key] = $value; + } + + /** + * {@inheritdoc} + */ + public function replace(array $values): void + { + $this->storage->exchangeArray(array_replace_recursive($this->storage->getArrayCopy(), $values)); + } + + /** + * {@inheritdoc} + */ + public function remove(string $key): void + { + $this->storage->offsetUnset($key); + } + + /** + * {@inheritdoc} + */ + public function clear(): void + { + $this->storage->exchangeArray([]); + } + + /** + * {@inheritdoc} + */ + public function count(): int + { + return $this->storage->count(); + } + + /** + * {@inheritdoc} + */ + public function save(): void + { + } + + /** + * {@inheritdoc} + */ + public function setOptions(array $config): void + { + foreach ($config as $key => $value) { + $this->config[$key] = $value; + } + } + + /** + * {@inheritdoc} + */ + public function getOptions(): array + { + return $this->config; + } + + /** + * {@inheritdoc} + */ + public function setCookieParams( + int $lifetime, + string $path = null, + string $domain = null, + bool $secure = false, + bool $httpOnly = false + ): void { + $this->cookie = [ + 'lifetime' => $lifetime, + 'path' => $path, + 'domain' => $domain, + 'secure' => $secure, + 'httponly' => $httpOnly, + ]; + } + + /** + * {@inheritdoc} + */ + public function getCookieParams(): array + { + return $this->cookie; + } +} diff --git a/vendor/odan/session/src/Middleware/SessionMiddleware.php b/vendor/odan/session/src/Middleware/SessionMiddleware.php new file mode 100644 index 0000000..556b44b --- /dev/null +++ b/vendor/odan/session/src/Middleware/SessionMiddleware.php @@ -0,0 +1,50 @@ +session = $session; + } + + /** + * Invoke middleware. + * + * @param ServerRequestInterface $request The request + * @param RequestHandlerInterface $handler The handler + * + * @return ResponseInterface The response + */ + public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface + { + if (!$this->session->isStarted()) { + $this->session->start(); + } + + $response = $handler->handle($request); + $this->session->save(); + + return $response; + } +} diff --git a/vendor/odan/session/src/PhpSession.php b/vendor/odan/session/src/PhpSession.php new file mode 100644 index 0000000..e6c0bb7 --- /dev/null +++ b/vendor/odan/session/src/PhpSession.php @@ -0,0 +1,295 @@ +storage = $storage ?? new ArrayObject(); + $this->flash = $flash ?? new Flash($this->storage); + } + + /** + * Get flash instance. + * + * @return FlashInterface The flash instance + */ + public function getFlash(): FlashInterface + { + return $this->flash; + } + + /** + * {@inheritdoc} + */ + public function start(): void + { + if ($this->isStarted()) { + throw new SessionException('Failed to start the session: Already started.'); + } + + if (headers_sent($file, $line) && filter_var(ini_get('session.use_cookies'), FILTER_VALIDATE_BOOLEAN)) { + throw new SessionException( + sprintf( + 'Failed to start the session because headers have already been sent by "%s" at line %d.', + $file, + $line + ) + ); + } + + // Try and start the session + if (!session_start()) { + throw new SessionException('Failed to start the session.'); + } + + // Load the session + $this->storage->exchangeArray($_SESSION ?? []); + } + + /** + * {@inheritdoc} + */ + public function isStarted(): bool + { + return session_status() === PHP_SESSION_ACTIVE; + } + + /** + * {@inheritdoc} + */ + public function regenerateId(): void + { + if (!$this->isStarted()) { + throw new SessionException('Cannot regenerate the session ID for non-active sessions.'); + } + + if (headers_sent()) { + throw new SessionException('Headers have already been sent.'); + } + + if (!session_regenerate_id(true)) { + throw new SessionException('The session ID could not be regenerated.'); + } + } + + /** + * {@inheritdoc} + */ + public function destroy(): void + { + // Cannot regenerate the session ID for non-active sessions. + if (!$this->isStarted()) { + return; + } + + $this->clear(); + + if (ini_get('session.use_cookies')) { + $params = session_get_cookie_params(); + setcookie( + $this->getName(), + '', + time() - 42000, + $params['path'], + $params['domain'], + $params['secure'], + $params['httponly'] + ); + } + + if (session_unset() === false) { + throw new SessionException('The session could not be unset.'); + } + + if (session_destroy() === false) { + throw new SessionException('The session could not be destroyed.'); + } + } + + /** + * {@inheritdoc} + */ + public function getId(): string + { + return (string)session_id(); + } + + /** + * {@inheritdoc} + */ + public function setId(string $id): void + { + if ($this->isStarted()) { + throw new SessionException('Cannot change session id when session is active'); + } + + session_id($id); + } + + /** + * {@inheritdoc} + */ + public function getName(): string + { + return (string)session_name(); + } + + /** + * {@inheritdoc} + */ + public function setName(string $name): void + { + if ($this->isStarted()) { + throw new SessionException('Cannot change session name when session is active'); + } + session_name($name); + } + + /** + * {@inheritdoc} + */ + public function has(string $key): bool + { + if (empty($this->storage)) { + return false; + } + + return $this->storage->offsetExists($key); + } + + /** + * {@inheritdoc} + */ + public function get(string $key) + { + return $this->has($key) ? $this->storage->offsetGet($key) : null; + } + + /** + * {@inheritdoc} + */ + public function all(): array + { + return (array)$this->storage; + } + + /** + * {@inheritdoc} + */ + public function set(string $key, $value): void + { + $this->storage->offsetSet($key, $value); + } + + /** + * {@inheritdoc} + */ + public function replace(array $values): void + { + $this->storage->exchangeArray( + array_replace_recursive($this->storage->getArrayCopy(), $values) + ); + } + + /** + * {@inheritdoc} + */ + public function remove(string $key): void + { + $this->storage->offsetUnset($key); + } + + /** + * {@inheritdoc} + */ + public function clear(): void + { + $this->storage->exchangeArray([]); + } + + /** + * {@inheritdoc} + */ + public function count(): int + { + return $this->storage->count(); + } + + /** + * {@inheritdoc} + */ + public function save(): void + { + $_SESSION = (array)$this->storage; + session_write_close(); + } + + /** + * {@inheritdoc} + */ + public function setOptions(array $config): void + { + foreach ($config as $key => $value) { + ini_set('session.' . $key, $value); + } + } + + /** + * {@inheritdoc} + */ + public function getOptions(): array + { + $config = []; + + foreach ((array)ini_get_all('session') as $key => $value) { + $config[substr($key, 8)] = $value['local_value']; + } + + return $config; + } + + /** + * {@inheritdoc} + */ + public function setCookieParams( + int $lifetime, + string $path = null, + string $domain = null, + bool $secure = false, + bool $httpOnly = false + ): void { + session_set_cookie_params($lifetime, $path ?? '/', $domain, $secure, $httpOnly); + } + + /** + * {@inheritdoc} + */ + public function getCookieParams(): array + { + return session_get_cookie_params(); + } +} diff --git a/vendor/odan/session/src/SessionAwareInterface.php b/vendor/odan/session/src/SessionAwareInterface.php new file mode 100644 index 0000000..8d60553 --- /dev/null +++ b/vendor/odan/session/src/SessionAwareInterface.php @@ -0,0 +1,16 @@ +session = $session; + } +} diff --git a/vendor/odan/session/src/SessionInterface.php b/vendor/odan/session/src/SessionInterface.php new file mode 100644 index 0000000..ac02791 --- /dev/null +++ b/vendor/odan/session/src/SessionInterface.php @@ -0,0 +1,201 @@ + value pair. + * + * @param array $attributes The new attributes + */ + public function replace(array $attributes): void; + + /** + * Deletes an attribute by key. + * + * @param string $key The key to remove + */ + public function remove(string $key): void; + + /** + * Clear all attributes. + */ + public function clear(): void; + + /** + * Returns the number of attributes. + * + * @return int The number of keys + */ + public function count(): int; + + /** + * Force the session to be saved and closed. + * + * This method is generally not required for real sessions as the session + * will be automatically saved at the end of code execution. + * + * @throws SessionException On error + */ + public function save(): void; + + /** + * Set session runtime configuration. + * + * @see http://php.net/manual/en/session.configuration.php + * + * @param array $config The session options + */ + public function setOptions(array $config): void; + + /** + * Get session runtime configuration. + * + * @return array The options + */ + public function getOptions(): array; + + /** + * Set cookie parameters. + * + * @see http://php.net/manual/en/function.session-set-cookie-params.php + * + * @param int $lifetime The lifetime of the cookie in seconds + * @param string|null $path The path where information is stored + * @param string|null $domain The domain of the cookie + * @param bool $secure The cookie should only be sent over secure connections + * @param bool $httpOnly The cookie can only be accessed through the HTTP protocol + */ + public function setCookieParams( + int $lifetime, + string $path = null, + string $domain = null, + bool $secure = false, + bool $httpOnly = false + ): void; + + /** + * Get cookie parameters. + * + * @see http://php.net/manual/en/function.session-get-cookie-params.php + * + * @return array The cookie parameters + */ + public function getCookieParams(): array; +} diff --git a/vendor/phpmailer/phpmailer/COMMITMENT b/vendor/phpmailer/phpmailer/COMMITMENT new file mode 100644 index 0000000..a687e0d --- /dev/null +++ b/vendor/phpmailer/phpmailer/COMMITMENT @@ -0,0 +1,46 @@ +GPL Cooperation Commitment +Version 1.0 + +Before filing or continuing to prosecute any legal proceeding or claim +(other than a Defensive Action) arising from termination of a Covered +License, we commit to extend to the person or entity ('you') accused +of violating the Covered License the following provisions regarding +cure and reinstatement, taken from GPL version 3. As used here, the +term 'this License' refers to the specific Covered License being +enforced. + + However, if you cease all violation of this License, then your + license from a particular copyright holder is reinstated (a) + provisionally, unless and until the copyright holder explicitly + and finally terminates your license, and (b) permanently, if the + copyright holder fails to notify you of the violation by some + reasonable means prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is + reinstated permanently if the copyright holder notifies you of the + violation by some reasonable means, this is the first time you + have received notice of violation of this License (for any work) + from that copyright holder, and you cure the violation prior to 30 + days after your receipt of the notice. + +We intend this Commitment to be irrevocable, and binding and +enforceable against us and assignees of or successors to our +copyrights. + +Definitions + +'Covered License' means the GNU General Public License, version 2 +(GPLv2), the GNU Lesser General Public License, version 2.1 +(LGPLv2.1), or the GNU Library General Public License, version 2 +(LGPLv2), all as published by the Free Software Foundation. + +'Defensive Action' means a legal proceeding or claim that We bring +against you in response to a prior proceeding or claim initiated by +you or your affiliate. + +'We' means each contributor to this repository as of the date of +inclusion of this file, including subsidiaries of a corporate +contributor. + +This work is available under a Creative Commons Attribution-ShareAlike +4.0 International license (https://creativecommons.org/licenses/by-sa/4.0/). diff --git a/vendor/phpmailer/phpmailer/LICENSE b/vendor/phpmailer/phpmailer/LICENSE new file mode 100644 index 0000000..f166cc5 --- /dev/null +++ b/vendor/phpmailer/phpmailer/LICENSE @@ -0,0 +1,502 @@ + 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/vendor/phpmailer/phpmailer/README.md b/vendor/phpmailer/phpmailer/README.md new file mode 100644 index 0000000..81b0897 --- /dev/null +++ b/vendor/phpmailer/phpmailer/README.md @@ -0,0 +1,227 @@ +![PHPMailer](https://raw.github.com/PHPMailer/PHPMailer/master/examples/images/phpmailer.png) + +# PHPMailer – A full-featured email creation and transfer class for PHP + +[![Test status](https://github.com/PHPMailer/PHPMailer/workflows/Tests/badge.svg)](https://github.com/PHPMailer/PHPMailer/actions) +[![codecov.io](https://codecov.io/gh/PHPMailer/PHPMailer/branch/master/graph/badge.svg?token=iORZpwmYmM)](https://codecov.io/gh/PHPMailer/PHPMailer) +[![Latest Stable Version](https://poser.pugx.org/phpmailer/phpmailer/v/stable.svg)](https://packagist.org/packages/phpmailer/phpmailer) +[![Total Downloads](https://poser.pugx.org/phpmailer/phpmailer/downloads)](https://packagist.org/packages/phpmailer/phpmailer) +[![License](https://poser.pugx.org/phpmailer/phpmailer/license.svg)](https://packagist.org/packages/phpmailer/phpmailer) +[![API Docs](https://github.com/phpmailer/phpmailer/workflows/Docs/badge.svg)](https://phpmailer.github.io/PHPMailer/) + +## 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 SMTPS and SMTP+STARTTLS transports +- Validates email addresses automatically +- Protects against header injection attacks +- Error messages in over 50 languages! +- DKIM and S/MIME signing support +- Compatible with PHP 5.5 and later, including PHP 8.1 +- Namespaced to prevent name clashes +- Much more! + +## Why you might need it +Many PHP developers need to send email from their code. The only PHP function that supports this directly is [`mail()`](https://www.php.net/manual/en/function.mail.php). However, it does not provide any assistance for making use of popular features such as encryption, authentication, HTML messages, and attachments. + +Formatting email correctly is surprisingly difficult. There are myriad overlapping (and conflicting) standards, 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, if not unsafe! + +The PHP `mail()` function usually sends via a local mail server, typically fronted by a `sendmail` binary on Linux, BSD, and macOS platforms, however, Windows usually doesn't include a local mail server; PHPMailer's integrated SMTP client allows email sending on all platforms without needing a local mail server. Be aware though, that the `mail()` function should be avoided when possible; it's both faster and [safer](https://exploitbox.io/paper/Pwning-PHP-Mail-Function-For-Fun-And-RCE.html) to use SMTP to localhost. + +*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/) +, [Laminas/Mail](https://docs.laminas.dev/laminas-mail/), [ZetaComponents](https://github.com/zetacomponents/Mail) etc. + +## License +This software is distributed under the [LGPL 2.1](http://www.gnu.org/licenses/lgpl-2.1.html) license, along with the [GPL Cooperation Commitment](https://gplcc.github.io/gplcc/). Please read [LICENSE](https://github.com/PHPMailer/PHPMailer/blob/master/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](https://getcomposer.org) is the recommended way to install PHPMailer. Just add this line to your `composer.json` file: + +```json +"phpmailer/phpmailer": "^6.5" +``` + +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, you +can [download PHPMailer as a zip file](https://github.com/PHPMailer/PHPMailer/archive/master.zip), (note that docs and examples are not included in the zip file), then 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 = SMTP::DEBUG_SERVER; //Enable verbose debug output + $mail->isSMTP(); //Send using SMTP + $mail->Host = 'smtp.example.com'; //Set the SMTP server to send through + $mail->SMTPAuth = true; //Enable SMTP authentication + $mail->Username = 'user@example.com'; //SMTP username + $mail->Password = 'secret'; //SMTP password + $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; //Enable implicit TLS encryption + $mail->Port = 465; //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS` + + //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 to play with in the [examples](https://github.com/PHPMailer/PHPMailer/tree/master/examples) folder, which covers many common scenarios including sending through gmail, building contact forms, sending to mailing lists, and more. + +If you are re-using the instance (e.g. when sending to a mailing list), you may need to clear the recipient list to avoid sending duplicate messages. See [the mailing list example](https://github.com/PHPMailer/PHPMailer/blob/master/examples/mailing_list.phps) for further guidance. + +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 many 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, 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, head for [the troubleshooting guide](https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting) as it's 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). + +To reduce PHPMailer's deployed code footprint, examples are not 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](https://phpmailer.github.io/PHPMailer/). + +You can generate complete API-level documentation by running `phpdoc` in the top-level folder, and documentation will appear in the `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/blob/master/test/PHPMailerTest.php) a good reference for 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 +[PHPMailer tests](https://github.com/PHPMailer/PHPMailer/tree/master/test/) use PHPUnit 9, with [a polyfill](https://github.com/Yoast/PHPUnit-Polyfills) to let 9-style tests run on older PHPUnit and PHP versions. + +[![Test status](https://github.com/PHPMailer/PHPMailer/workflows/Tests/badge.svg)](https://github.com/PHPMailer/PHPMailer/actions) + +If this isn't passing, is there something you can do to help? + +## Security +Please disclose any vulnerabilities found responsibly – report security issues to the maintainers privately. + +See [SECURITY](https://github.com/PHPMailer/PHPMailer/tree/master/SECURITY.md) and [PHPMailer's security advisories on GitHub](https://github.com/PHPMailer/PHPMailer/security). + +## 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/), the world's only privacy-first email marketing system. + +Smartmessages.net privacy-first email marketing logo + +Donations are very welcome, whether in beer 🍺, T-shirts 👕, or cold, hard cash 💰. Sponsorship through GitHub is a simple and convenient way to say "thank you" to PHPMailer's maintainers and contributors – just click the "Sponsor" button [on the project page](https://github.com/PHPMailer/PHPMailer). If your company uses PHPMailer, consider taking part in Tidelift's enterprise support programme. + +## PHPMailer For Enterprise + +Available as part of the Tidelift Subscription. + +The maintainers of PHPMailer and thousands of other packages are working with Tidelift to deliver commercial +support and maintenance for the open source packages you use to build your applications. Save time, reduce risk, and +improve code health, while paying the maintainers of the exact packages you +use. [Learn more.](https://tidelift.com/subscription/pkg/packagist-phpmailer-phpmailer?utm_source=packagist-phpmailer-phpmailer&utm_medium=referral&utm_campaign=enterprise&utm_term=repo) + +## 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](https://github.com/Synchro) (`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 Github Actions. +- 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/vendor/phpmailer/phpmailer/SECURITY.md b/vendor/phpmailer/phpmailer/SECURITY.md new file mode 100644 index 0000000..035a87f --- /dev/null +++ b/vendor/phpmailer/phpmailer/SECURITY.md @@ -0,0 +1,37 @@ +# Security notices relating to PHPMailer + +Please disclose any security issues or vulnerabilities found through [Tidelift's coordinated disclosure system](https://tidelift.com/security) or to the maintainers privately. + +PHPMailer 6.4.1 and earlier contain a vulnerability that can result in untrusted code being called (if such code is injected into the host project's scope by other means). If the `$patternselect` parameter to `validateAddress()` is set to `'php'` (the default, defined by `PHPMailer::$validator`), and the global namespace contains a function called `php`, it will be called in preference to the built-in validator of the same name. Mitigated in PHPMailer 6.5.0 by denying the use of simple strings as validator function names. Recorded as [CVE-2021-3603](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2021-3603). Reported by [Vikrant Singh Chauhan](mailto:vi@hackberry.xyz) via [huntr.dev](https://www.huntr.dev/). + +PHPMailer versions 6.4.1 and earlier contain a possible remote code execution vulnerability through the `$lang_path` parameter of the `setLanguage()` method. If the `$lang_path` parameter is passed unfiltered from user input, it can be set to [a UNC path](https://docs.microsoft.com/en-us/dotnet/standard/io/file-path-formats#unc-paths), and if an attacker is also able to persuade the server to load a file from that UNC path, a script file under their control may be executed. This vulnerability only applies to systems that resolve UNC paths, typically only Microsoft Windows. +PHPMailer 6.5.0 mitigates this by no longer treating translation files as PHP code, but by parsing their text content directly. This approach avoids the possibility of executing unknown code while retaining backward compatibility. This isn't ideal, so the current translation format is deprecated and will be replaced in the next major release. Recorded as [CVE-2021-34551](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2021-34551). Reported by [Jilin Diting Information Technology Co., Ltd](https://listensec.com) via Tidelift. + +PHPMailer versions between 6.1.8 and 6.4.0 contain a regression of the earlier CVE-2018-19296 object injection vulnerability as a result of [a fix for Windows UNC paths in 6.1.8](https://github.com/PHPMailer/PHPMailer/commit/e2e07a355ee8ff36aba21d0242c5950c56e4c6f9). Recorded as [CVE-2020-36326](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2020-36326). Reported by Fariskhi Vidyan via Tidelift. 6.4.1 fixes this issue, and also enforces stricter checks for URL schemes in local path contexts. + +PHPMailer versions 6.1.5 and earlier contain an output escaping bug that occurs in `Content-Type` and `Content-Disposition` when filenames passed into `addAttachment` and other methods that accept attachment names contain double quote characters, in contravention of RFC822 3.4.1. No specific vulnerability has been found relating to this, but it could allow file attachments to bypass attachment filters that are based on matching filename extensions. Recorded as [CVE-2020-13625](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2020-13625). Reported by Elar Lang of Clarified Security. + +PHPMailer versions prior to 6.0.6 and 5.2.27 are vulnerable to an object injection attack by passing `phar://` paths into `addAttachment()` and other functions that may receive unfiltered local paths, possibly leading to RCE. Recorded as [CVE-2018-19296](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2018-19296). See [this article](https://knasmueller.net/5-answers-about-php-phar-exploitation) for more info on this type of vulnerability. Mitigated by blocking the use of paths containing URL-protocol style prefixes such as `phar://`. Reported by Sehun Oh of cyberone.kr. + +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, and the file is not included when PHPMailer is loaded through composer, 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/vendor/phpmailer/phpmailer/VERSION b/vendor/phpmailer/phpmailer/VERSION new file mode 100644 index 0000000..3d5762e --- /dev/null +++ b/vendor/phpmailer/phpmailer/VERSION @@ -0,0 +1 @@ +6.5.1 \ No newline at end of file diff --git a/vendor/phpmailer/phpmailer/composer.json b/vendor/phpmailer/phpmailer/composer.json new file mode 100644 index 0000000..28557f5 --- /dev/null +++ b/vendor/phpmailer/phpmailer/composer.json @@ -0,0 +1,71 @@ +{ + "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" + } + ], + "funding": [ + { + "url": "https://github.com/Synchro", + "type": "github" + } + ], + "require": { + "php": ">=5.5.0", + "ext-ctype": "*", + "ext-filter": "*", + "ext-hash": "*" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0", + "doctrine/annotations": "^1.2", + "php-parallel-lint/php-console-highlighter": "^0.5.0", + "php-parallel-lint/php-parallel-lint": "^1.3", + "phpcompatibility/php-compatibility": "^9.3.5", + "roave/security-advisories": "dev-latest", + "squizlabs/php_codesniffer": "^3.6.0", + "yoast/phpunit-polyfills": "^1.0.0" + }, + "suggest": { + "ext-mbstring": "Needed to send email in multibyte encoding charset or decode encoded addresses", + "hayageek/oauth2-yahoo": "Needed for Yahoo XOAUTH2 authentication", + "league/oauth2-google": "Needed for Google XOAUTH2 authentication", + "psr/log": "For optional PSR-3 debug logging", + "stevenmaguire/oauth2-microsoft": "Needed for Microsoft XOAUTH2 authentication", + "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-only", + "scripts": { + "check": "./vendor/bin/phpcs", + "test": "./vendor/bin/phpunit --no-coverage", + "coverage": "./vendor/bin/phpunit", + "lint": [ + "@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php,phps --exclude vendor --exclude .git --exclude build" + ] + } +} diff --git a/vendor/phpmailer/phpmailer/get_oauth_token.php b/vendor/phpmailer/phpmailer/get_oauth_token.php new file mode 100644 index 0000000..befdc34 --- /dev/null +++ b/vendor/phpmailer/phpmailer/get_oauth_token.php @@ -0,0 +1,146 @@ + + * @author Jim Jagielski (jimjag) + * @author Andy Prevost (codeworxtech) + * @author Brent R. Matzelle (original founder) + * @copyright 2012 - 2020 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. + */ + +/** + * Get an OAuth2 token from an OAuth2 provider. + * * Install this script on your server so that it's accessible + * as [https/http]:////get_oauth_token.php + * e.g.: http://localhost/phpmailer/get_oauth_token.php + * * Ensure dependencies are installed with 'composer install' + * * Set up an app in your Google/Yahoo/Microsoft account + * * Set the script address as the app's redirect URL + * If no refresh token is obtained when running this file, + * revoke access to your app and run the script again. + */ + +namespace PHPMailer\PHPMailer; + +/** + * Aliases for League Provider Classes + * Make sure you have added these to your composer.json and run `composer install` + * Plenty to choose from here: + * @see http://oauth2-client.thephpleague.com/providers/thirdparty/ + */ +//@see https://github.com/thephpleague/oauth2-google +use League\OAuth2\Client\Provider\Google; +//@see https://packagist.org/packages/hayageek/oauth2-yahoo +use Hayageek\OAuth2\Client\Provider\Yahoo; +//@see https://github.com/stevenmaguire/oauth2-microsoft +use Stevenmaguire\OAuth2\Client\Provider\Microsoft; + +if (!isset($_GET['code']) && !isset($_GET['provider'])) { + ?> + +Select Provider:
+Google
+Yahoo
+Microsoft/Outlook/Hotmail/Live/Office365
+ + + $clientId, + 'clientSecret' => $clientSecret, + 'redirectUri' => $redirectUri, + 'accessType' => 'offline' +]; + +$options = []; +$provider = null; + +switch ($providerName) { + case 'Google': + $provider = new Google($params); + $options = [ + 'scope' => [ + 'https://mail.google.com/' + ] + ]; + break; + case 'Yahoo': + $provider = new Yahoo($params); + break; + case 'Microsoft': + $provider = new Microsoft($params); + $options = [ + 'scope' => [ + 'wl.imap', + 'wl.offline_access' + ] + ]; + break; +} + +if (null === $provider) { + exit('Provider missing'); +} + +if (!isset($_GET['code'])) { + //If we don't have an authorization code then get one + $authUrl = $provider->getAuthorizationUrl($options); + $_SESSION['oauth2state'] = $provider->getState(); + header('Location: ' . $authUrl); + exit; + //Check given state against previously stored one to mitigate CSRF attack +} elseif (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2state'])) { + unset($_SESSION['oauth2state']); + unset($_SESSION['provider']); + exit('Invalid state'); +} else { + unset($_SESSION['provider']); + //Try to get an access token (using the authorization code grant) + $token = $provider->getAccessToken( + 'authorization_code', + [ + 'code' => $_GET['code'] + ] + ); + //Use this to interact with an API on the users behalf + //Use this to get a new access token if the old one expires + echo 'Refresh Token: ', $token->getRefreshToken(); +} diff --git a/vendor/phpmailer/phpmailer/language/phpmailer.lang-af.php b/vendor/phpmailer/phpmailer/language/phpmailer.lang-af.php new file mode 100644 index 0000000..0b2a72d --- /dev/null +++ b/vendor/phpmailer/phpmailer/language/phpmailer.lang-af.php @@ -0,0 +1,26 @@ + + */ + +$PHPMAILER_LANG['authenticate'] = 'خطأ SMTP : لا يمكن تأكيد الهوية.'; +$PHPMAILER_LANG['connect_host'] = 'خطأ SMTP: لا يمكن الاتصال بالخادم SMTP.'; +$PHPMAILER_LANG['data_not_accepted'] = 'خطأ SMTP: لم يتم قبول المعلومات .'; +$PHPMAILER_LANG['empty_message'] = 'نص الرسالة فارغ'; +$PHPMAILER_LANG['encoding'] = 'ترميز غير معروف: '; +$PHPMAILER_LANG['execute'] = 'لا يمكن تنفيذ : '; +$PHPMAILER_LANG['file_access'] = 'لا يمكن الوصول للملف: '; +$PHPMAILER_LANG['file_open'] = 'خطأ في الملف: لا يمكن فتحه: '; +$PHPMAILER_LANG['from_failed'] = 'خطأ على مستوى عنوان المرسل : '; +$PHPMAILER_LANG['instantiate'] = 'لا يمكن توفير خدمة البريد.'; +$PHPMAILER_LANG['invalid_address'] = 'الإرسال غير ممكن لأن عنوان البريد الإلكتروني غير صالح: '; +$PHPMAILER_LANG['mailer_not_supported'] = ' برنامج الإرسال غير مدعوم.'; +$PHPMAILER_LANG['provide_address'] = 'يجب توفير عنوان البريد الإلكتروني لمستلم واحد على الأقل.'; +$PHPMAILER_LANG['recipients_failed'] = 'خطأ SMTP: الأخطاء التالية فشل في الارسال لكل من : '; +$PHPMAILER_LANG['signing'] = 'خطأ في التوقيع: '; +$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() غير ممكن.'; +$PHPMAILER_LANG['smtp_error'] = 'خطأ على مستوى الخادم SMTP: '; +$PHPMAILER_LANG['variable_set'] = 'لا يمكن تعيين أو إعادة تعيين متغير: '; +$PHPMAILER_LANG['extension_missing'] = 'الإضافة غير موجودة: '; diff --git a/vendor/phpmailer/phpmailer/language/phpmailer.lang-az.php b/vendor/phpmailer/phpmailer/language/phpmailer.lang-az.php new file mode 100644 index 0000000..552167e --- /dev/null +++ b/vendor/phpmailer/phpmailer/language/phpmailer.lang-az.php @@ -0,0 +1,27 @@ + + */ + +$PHPMAILER_LANG['authenticate'] = 'SMTP Greška: Neuspjela prijava.'; +$PHPMAILER_LANG['connect_host'] = 'SMTP Greška: Nije moguće spojiti se sa SMTP serverom.'; +$PHPMAILER_LANG['data_not_accepted'] = 'SMTP Greška: Podatci nisu prihvaćeni.'; +$PHPMAILER_LANG['empty_message'] = 'Sadržaj poruke je prazan.'; +$PHPMAILER_LANG['encoding'] = 'Nepoznata kriptografija: '; +$PHPMAILER_LANG['execute'] = 'Nije moguće izvršiti naredbu: '; +$PHPMAILER_LANG['file_access'] = 'Nije moguće pristupiti datoteci: '; +$PHPMAILER_LANG['file_open'] = 'Nije moguće otvoriti datoteku: '; +$PHPMAILER_LANG['from_failed'] = 'SMTP Greška: Slanje sa navedenih e-mail adresa nije uspjelo: '; +$PHPMAILER_LANG['recipients_failed'] = 'SMTP Greška: Slanje na navedene e-mail adrese nije uspjelo: '; +$PHPMAILER_LANG['instantiate'] = 'Ne mogu pokrenuti mail funkcionalnost.'; +$PHPMAILER_LANG['invalid_address'] = 'E-mail nije poslan. Neispravna e-mail adresa: '; +$PHPMAILER_LANG['mailer_not_supported'] = ' mailer nije podržan.'; +$PHPMAILER_LANG['provide_address'] = 'Definišite barem jednu adresu primaoca.'; +$PHPMAILER_LANG['signing'] = 'Greška prilikom prijave: '; +$PHPMAILER_LANG['smtp_connect_failed'] = 'Spajanje na SMTP server nije uspjelo.'; +$PHPMAILER_LANG['smtp_error'] = 'SMTP greška: '; +$PHPMAILER_LANG['variable_set'] = 'Nije moguće postaviti varijablu ili je vratiti nazad: '; +$PHPMAILER_LANG['extension_missing'] = 'Nedostaje ekstenzija: '; diff --git a/vendor/phpmailer/phpmailer/language/phpmailer.lang-be.php b/vendor/phpmailer/phpmailer/language/phpmailer.lang-be.php new file mode 100644 index 0000000..9e92dda --- /dev/null +++ b/vendor/phpmailer/phpmailer/language/phpmailer.lang-be.php @@ -0,0 +1,27 @@ + + */ + +$PHPMAILER_LANG['authenticate'] = 'Памылка SMTP: памылка ідэнтыфікацыі.'; +$PHPMAILER_LANG['connect_host'] = 'Памылка SMTP: нельга ўстанавіць сувязь з SMTP-серверам.'; +$PHPMAILER_LANG['data_not_accepted'] = 'Памылка SMTP: звесткі непрынятыя.'; +$PHPMAILER_LANG['empty_message'] = 'Пустое паведамленне.'; +$PHPMAILER_LANG['encoding'] = 'Невядомая кадыроўка тэксту: '; +$PHPMAILER_LANG['execute'] = 'Нельга выканаць каманду: '; +$PHPMAILER_LANG['file_access'] = 'Няма доступу да файла: '; +$PHPMAILER_LANG['file_open'] = 'Нельга адкрыць файл: '; +$PHPMAILER_LANG['from_failed'] = 'Няправільны адрас адпраўніка: '; +$PHPMAILER_LANG['instantiate'] = 'Нельга прымяніць функцыю mail().'; +$PHPMAILER_LANG['invalid_address'] = 'Нельга даслаць паведамленне, няправільны email атрымальніка: '; +$PHPMAILER_LANG['provide_address'] = 'Запоўніце, калі ласка, правільны email атрымальніка.'; +$PHPMAILER_LANG['mailer_not_supported'] = ' - паштовы сервер не падтрымліваецца.'; +$PHPMAILER_LANG['recipients_failed'] = 'Памылка SMTP: няправільныя атрымальнікі: '; +$PHPMAILER_LANG['signing'] = 'Памылка подпісу паведамлення: '; +$PHPMAILER_LANG['smtp_connect_failed'] = 'Памылка сувязі з SMTP-серверам.'; +$PHPMAILER_LANG['smtp_error'] = 'Памылка SMTP: '; +$PHPMAILER_LANG['variable_set'] = 'Нельга ўстанавіць або перамяніць значэнне пераменнай: '; +//$PHPMAILER_LANG['extension_missing'] = 'Extension missing: '; diff --git a/vendor/phpmailer/phpmailer/language/phpmailer.lang-bg.php b/vendor/phpmailer/phpmailer/language/phpmailer.lang-bg.php new file mode 100644 index 0000000..c41f675 --- /dev/null +++ b/vendor/phpmailer/phpmailer/language/phpmailer.lang-bg.php @@ -0,0 +1,27 @@ + + */ + +$PHPMAILER_LANG['authenticate'] = 'SMTP грешка: Не може да се удостовери пред сървъра.'; +$PHPMAILER_LANG['connect_host'] = 'SMTP грешка: Не може да се свърже с SMTP хоста.'; +$PHPMAILER_LANG['data_not_accepted'] = 'SMTP грешка: данните не са приети.'; +$PHPMAILER_LANG['empty_message'] = 'Съдържанието на съобщението е празно'; +$PHPMAILER_LANG['encoding'] = 'Неизвестно кодиране: '; +$PHPMAILER_LANG['execute'] = 'Не може да се изпълни: '; +$PHPMAILER_LANG['file_access'] = 'Няма достъп до файл: '; +$PHPMAILER_LANG['file_open'] = 'Файлова грешка: Не може да се отвори файл: '; +$PHPMAILER_LANG['from_failed'] = 'Следните адреси за подател са невалидни: '; +$PHPMAILER_LANG['instantiate'] = 'Не може да се инстанцира функцията mail.'; +$PHPMAILER_LANG['invalid_address'] = 'Невалиден адрес: '; +$PHPMAILER_LANG['mailer_not_supported'] = ' - пощенски сървър не се поддържа.'; +$PHPMAILER_LANG['provide_address'] = 'Трябва да предоставите поне един email адрес за получател.'; +$PHPMAILER_LANG['recipients_failed'] = 'SMTP грешка: Следните адреси за Получател са невалидни: '; +$PHPMAILER_LANG['signing'] = 'Грешка при подписване: '; +$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP провален connect().'; +$PHPMAILER_LANG['smtp_error'] = 'SMTP сървърна грешка: '; +$PHPMAILER_LANG['variable_set'] = 'Не може да се установи или възстанови променлива: '; +$PHPMAILER_LANG['extension_missing'] = 'Липсва разширение: '; diff --git a/vendor/phpmailer/phpmailer/language/phpmailer.lang-ca.php b/vendor/phpmailer/phpmailer/language/phpmailer.lang-ca.php new file mode 100644 index 0000000..3468485 --- /dev/null +++ b/vendor/phpmailer/phpmailer/language/phpmailer.lang-ca.php @@ -0,0 +1,27 @@ + + */ + +$PHPMAILER_LANG['authenticate'] = 'Error SMTP: No s’ha pogut autenticar.'; +$PHPMAILER_LANG['connect_host'] = 'Error SMTP: No es pot connectar al servidor SMTP.'; +$PHPMAILER_LANG['data_not_accepted'] = 'Error SMTP: Dades no acceptades.'; +$PHPMAILER_LANG['empty_message'] = 'El cos del missatge està buit.'; +$PHPMAILER_LANG['encoding'] = 'Codificació desconeguda: '; +$PHPMAILER_LANG['execute'] = 'No es pot executar: '; +$PHPMAILER_LANG['file_access'] = 'No es pot accedir a l’arxiu: '; +$PHPMAILER_LANG['file_open'] = 'Error d’Arxiu: No es pot obrir l’arxiu: '; +$PHPMAILER_LANG['from_failed'] = 'La(s) següent(s) adreces de remitent han fallat: '; +$PHPMAILER_LANG['instantiate'] = 'No s’ha pogut crear una instància de la funció Mail.'; +$PHPMAILER_LANG['invalid_address'] = 'Adreça d’email invalida: '; +$PHPMAILER_LANG['mailer_not_supported'] = ' mailer no està suportat'; +$PHPMAILER_LANG['provide_address'] = 'S’ha de proveir almenys una adreça d’email com a destinatari.'; +$PHPMAILER_LANG['recipients_failed'] = 'Error SMTP: Els següents destinataris han fallat: '; +$PHPMAILER_LANG['signing'] = 'Error al signar: '; +$PHPMAILER_LANG['smtp_connect_failed'] = 'Ha fallat el SMTP Connect().'; +$PHPMAILER_LANG['smtp_error'] = 'Error del servidor SMTP: '; +$PHPMAILER_LANG['variable_set'] = 'No s’ha pogut establir o restablir la variable: '; +//$PHPMAILER_LANG['extension_missing'] = 'Extension missing: '; diff --git a/vendor/phpmailer/phpmailer/language/phpmailer.lang-ch.php b/vendor/phpmailer/phpmailer/language/phpmailer.lang-ch.php new file mode 100644 index 0000000..500c952 --- /dev/null +++ b/vendor/phpmailer/phpmailer/language/phpmailer.lang-ch.php @@ -0,0 +1,27 @@ + + */ + +$PHPMAILER_LANG['authenticate'] = 'SMTP 错误:身份验证失败。'; +$PHPMAILER_LANG['connect_host'] = 'SMTP 错误: 不能连接SMTP主机。'; +$PHPMAILER_LANG['data_not_accepted'] = 'SMTP 错误: 数据不可接受。'; +//$PHPMAILER_LANG['empty_message'] = 'Message body empty'; +$PHPMAILER_LANG['encoding'] = '未知编码:'; +$PHPMAILER_LANG['execute'] = '不能执行: '; +$PHPMAILER_LANG['file_access'] = '不能访问文件:'; +$PHPMAILER_LANG['file_open'] = '文件错误:不能打开文件:'; +$PHPMAILER_LANG['from_failed'] = '下面的发送地址邮件发送失败了: '; +$PHPMAILER_LANG['instantiate'] = '不能实现mail方法。'; +//$PHPMAILER_LANG['invalid_address'] = 'Invalid address: '; +$PHPMAILER_LANG['mailer_not_supported'] = ' 您所选择的发送邮件的方法并不支持。'; +$PHPMAILER_LANG['provide_address'] = '您必须提供至少一个 收信人的email地址。'; +$PHPMAILER_LANG['recipients_failed'] = 'SMTP 错误: 下面的 收件人失败了: '; +//$PHPMAILER_LANG['signing'] = 'Signing Error: '; +//$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() failed.'; +//$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: '; +//$PHPMAILER_LANG['variable_set'] = 'Cannot set or reset variable: '; +//$PHPMAILER_LANG['extension_missing'] = 'Extension missing: '; diff --git a/vendor/phpmailer/phpmailer/language/phpmailer.lang-cs.php b/vendor/phpmailer/phpmailer/language/phpmailer.lang-cs.php new file mode 100644 index 0000000..e770a1a --- /dev/null +++ b/vendor/phpmailer/phpmailer/language/phpmailer.lang-cs.php @@ -0,0 +1,28 @@ + + * Rewrite and extension of the work by Mikael Stokkebro + * + */ + +$PHPMAILER_LANG['authenticate'] = 'SMTP fejl: Login mislykkedes.'; +$PHPMAILER_LANG['connect_host'] = 'SMTP fejl: Forbindelse til SMTP serveren kunne ikke oprettes.'; +$PHPMAILER_LANG['data_not_accepted'] = 'SMTP fejl: Data blev ikke accepteret.'; +$PHPMAILER_LANG['empty_message'] = 'Meddelelsen er uden indhold'; +$PHPMAILER_LANG['encoding'] = 'Ukendt encode-format: '; +$PHPMAILER_LANG['execute'] = 'Kunne ikke afvikle: '; +$PHPMAILER_LANG['file_access'] = 'Kunne ikke tilgå filen: '; +$PHPMAILER_LANG['file_open'] = 'Fil fejl: Kunne ikke åbne filen: '; +$PHPMAILER_LANG['from_failed'] = 'Følgende afsenderadresse er forkert: '; +$PHPMAILER_LANG['instantiate'] = 'Email funktionen kunne ikke initialiseres.'; +$PHPMAILER_LANG['invalid_address'] = 'Udgyldig adresse: '; +$PHPMAILER_LANG['mailer_not_supported'] = ' mailer understøttes ikke.'; +$PHPMAILER_LANG['provide_address'] = 'Indtast mindst en modtagers email adresse.'; +$PHPMAILER_LANG['recipients_failed'] = 'SMTP fejl: Følgende modtagere er forkerte: '; +$PHPMAILER_LANG['signing'] = 'Signeringsfejl: '; +$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() fejlede.'; +$PHPMAILER_LANG['smtp_error'] = 'SMTP server fejl: '; +$PHPMAILER_LANG['variable_set'] = 'Kunne ikke definere eller nulstille variablen: '; +$PHPMAILER_LANG['extension_missing'] = 'Udvidelse mangler: '; diff --git a/vendor/phpmailer/phpmailer/language/phpmailer.lang-de.php b/vendor/phpmailer/phpmailer/language/phpmailer.lang-de.php new file mode 100644 index 0000000..e7e59d2 --- /dev/null +++ b/vendor/phpmailer/phpmailer/language/phpmailer.lang-de.php @@ -0,0 +1,28 @@ + + */ + +$PHPMAILER_LANG['authenticate'] = 'Error SMTP: Imposible autentificar.'; +$PHPMAILER_LANG['connect_host'] = 'Error SMTP: Imposible conectar al servidor SMTP.'; +$PHPMAILER_LANG['data_not_accepted'] = 'Error SMTP: Datos no aceptados.'; +$PHPMAILER_LANG['empty_message'] = 'El cuerpo del mensaje está vacío.'; +$PHPMAILER_LANG['encoding'] = 'Codificación desconocida: '; +$PHPMAILER_LANG['execute'] = 'Imposible ejecutar: '; +$PHPMAILER_LANG['file_access'] = 'Imposible acceder al archivo: '; +$PHPMAILER_LANG['file_open'] = 'Error de Archivo: Imposible abrir el archivo: '; +$PHPMAILER_LANG['from_failed'] = 'La(s) siguiente(s) direcciones de remitente fallaron: '; +$PHPMAILER_LANG['instantiate'] = 'Imposible crear una instancia de la función Mail.'; +$PHPMAILER_LANG['invalid_address'] = 'Imposible enviar: dirección de email inválido: '; +$PHPMAILER_LANG['mailer_not_supported'] = ' mailer no está soportado.'; +$PHPMAILER_LANG['provide_address'] = 'Debe proporcionar al menos una dirección de email de destino.'; +$PHPMAILER_LANG['recipients_failed'] = 'Error SMTP: Los siguientes destinos fallaron: '; +$PHPMAILER_LANG['signing'] = 'Error al firmar: '; +$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() falló.'; +$PHPMAILER_LANG['smtp_error'] = 'Error del servidor SMTP: '; +$PHPMAILER_LANG['variable_set'] = 'No se pudo configurar la variable: '; +$PHPMAILER_LANG['extension_missing'] = 'Extensión faltante: '; diff --git a/vendor/phpmailer/phpmailer/language/phpmailer.lang-et.php b/vendor/phpmailer/phpmailer/language/phpmailer.lang-et.php new file mode 100644 index 0000000..93addc9 --- /dev/null +++ b/vendor/phpmailer/phpmailer/language/phpmailer.lang-et.php @@ -0,0 +1,28 @@ + + */ + +$PHPMAILER_LANG['authenticate'] = 'SMTP Viga: Autoriseerimise viga.'; +$PHPMAILER_LANG['connect_host'] = 'SMTP Viga: Ei õnnestunud luua ühendust SMTP serveriga.'; +$PHPMAILER_LANG['data_not_accepted'] = 'SMTP Viga: Vigased andmed.'; +$PHPMAILER_LANG['empty_message'] = 'Tühi kirja sisu'; +$PHPMAILER_LANG["encoding"] = 'Tundmatu kodeering: '; +$PHPMAILER_LANG['execute'] = 'Tegevus ebaõnnestus: '; +$PHPMAILER_LANG['file_access'] = 'Pole piisavalt õiguseid järgneva faili avamiseks: '; +$PHPMAILER_LANG['file_open'] = 'Faili Viga: Faili avamine ebaõnnestus: '; +$PHPMAILER_LANG['from_failed'] = 'Järgnev saatja e-posti aadress on vigane: '; +$PHPMAILER_LANG['instantiate'] = 'mail funktiooni käivitamine ebaõnnestus.'; +$PHPMAILER_LANG['invalid_address'] = 'Saatmine peatatud, e-posti address vigane: '; +$PHPMAILER_LANG['provide_address'] = 'Te peate määrama vähemalt ühe saaja e-posti aadressi.'; +$PHPMAILER_LANG['mailer_not_supported'] = ' maileri tugi puudub.'; +$PHPMAILER_LANG['recipients_failed'] = 'SMTP Viga: Järgnevate saajate e-posti aadressid on vigased: '; +$PHPMAILER_LANG["signing"] = 'Viga allkirjastamisel: '; +$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() ebaõnnestus.'; +$PHPMAILER_LANG['smtp_error'] = 'SMTP serveri viga: '; +$PHPMAILER_LANG['variable_set'] = 'Ei õnnestunud määrata või lähtestada muutujat: '; +$PHPMAILER_LANG['extension_missing'] = 'Nõutud laiendus on puudu: '; diff --git a/vendor/phpmailer/phpmailer/language/phpmailer.lang-fa.php b/vendor/phpmailer/phpmailer/language/phpmailer.lang-fa.php new file mode 100644 index 0000000..295a47f --- /dev/null +++ b/vendor/phpmailer/phpmailer/language/phpmailer.lang-fa.php @@ -0,0 +1,28 @@ + + * @author Mohammad Hossein Mojtahedi + */ + +$PHPMAILER_LANG['authenticate'] = 'خطای SMTP: احراز هویت با شکست مواجه شد.'; +$PHPMAILER_LANG['connect_host'] = 'خطای SMTP: اتصال به سرور SMTP برقرار نشد.'; +$PHPMAILER_LANG['data_not_accepted'] = 'خطای SMTP: داده‌ها نا‌درست هستند.'; +$PHPMAILER_LANG['empty_message'] = 'بخش متن پیام خالی است.'; +$PHPMAILER_LANG['encoding'] = 'کد‌گذاری نا‌شناخته: '; +$PHPMAILER_LANG['execute'] = 'امکان اجرا وجود ندارد: '; +$PHPMAILER_LANG['file_access'] = 'امکان دسترسی به فایل وجود ندارد: '; +$PHPMAILER_LANG['file_open'] = 'خطای File: امکان بازکردن فایل وجود ندارد: '; +$PHPMAILER_LANG['from_failed'] = 'آدرس فرستنده اشتباه است: '; +$PHPMAILER_LANG['instantiate'] = 'امکان معرفی تابع ایمیل وجود ندارد.'; +$PHPMAILER_LANG['invalid_address'] = 'آدرس ایمیل معتبر نیست: '; +$PHPMAILER_LANG['mailer_not_supported'] = ' mailer پشتیبانی نمی‌شود.'; +$PHPMAILER_LANG['provide_address'] = 'باید حداقل یک آدرس گیرنده وارد کنید.'; +$PHPMAILER_LANG['recipients_failed'] = 'خطای SMTP: ارسال به آدرس گیرنده با خطا مواجه شد: '; +$PHPMAILER_LANG['signing'] = 'خطا در امضا: '; +$PHPMAILER_LANG['smtp_connect_failed'] = 'خطا در اتصال به SMTP.'; +$PHPMAILER_LANG['smtp_error'] = 'خطا در SMTP Server: '; +$PHPMAILER_LANG['variable_set'] = 'امکان ارسال یا ارسال مجدد متغیر‌ها وجود ندارد: '; +$PHPMAILER_LANG['extension_missing'] = 'افزونه موجود نیست: '; diff --git a/vendor/phpmailer/phpmailer/language/phpmailer.lang-fi.php b/vendor/phpmailer/phpmailer/language/phpmailer.lang-fi.php new file mode 100644 index 0000000..243c054 --- /dev/null +++ b/vendor/phpmailer/phpmailer/language/phpmailer.lang-fi.php @@ -0,0 +1,28 @@ + + */ + +$PHPMAILER_LANG['authenticate'] = 'SMTP feilur: Kundi ikki góðkenna.'; +$PHPMAILER_LANG['connect_host'] = 'SMTP feilur: Kundi ikki knýta samband við SMTP vert.'; +$PHPMAILER_LANG['data_not_accepted'] = 'SMTP feilur: Data ikki góðkent.'; +//$PHPMAILER_LANG['empty_message'] = 'Message body empty'; +$PHPMAILER_LANG['encoding'] = 'Ókend encoding: '; +$PHPMAILER_LANG['execute'] = 'Kundi ikki útføra: '; +$PHPMAILER_LANG['file_access'] = 'Kundi ikki tilganga fílu: '; +$PHPMAILER_LANG['file_open'] = 'Fílu feilur: Kundi ikki opna fílu: '; +$PHPMAILER_LANG['from_failed'] = 'fylgjandi Frá/From adressa miseydnaðist: '; +$PHPMAILER_LANG['instantiate'] = 'Kuni ikki instantiera mail funktión.'; +//$PHPMAILER_LANG['invalid_address'] = 'Invalid address: '; +$PHPMAILER_LANG['mailer_not_supported'] = ' er ikki supporterað.'; +$PHPMAILER_LANG['provide_address'] = 'Tú skal uppgeva minst móttakara-emailadressu(r).'; +$PHPMAILER_LANG['recipients_failed'] = 'SMTP Feilur: Fylgjandi móttakarar miseydnaðust: '; +//$PHPMAILER_LANG['signing'] = 'Signing Error: '; +//$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() failed.'; +//$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: '; +//$PHPMAILER_LANG['variable_set'] = 'Cannot set or reset variable: '; +//$PHPMAILER_LANG['extension_missing'] = 'Extension missing: '; diff --git a/vendor/phpmailer/phpmailer/language/phpmailer.lang-fr.php b/vendor/phpmailer/phpmailer/language/phpmailer.lang-fr.php new file mode 100644 index 0000000..b57f0ec --- /dev/null +++ b/vendor/phpmailer/phpmailer/language/phpmailer.lang-fr.php @@ -0,0 +1,32 @@ + + */ + +$PHPMAILER_LANG['authenticate'] = 'Erro SMTP: Non puido ser autentificado.'; +$PHPMAILER_LANG['connect_host'] = 'Erro SMTP: Non puido conectar co servidor SMTP.'; +$PHPMAILER_LANG['data_not_accepted'] = 'Erro SMTP: Datos non aceptados.'; +$PHPMAILER_LANG['empty_message'] = 'Corpo da mensaxe vacía'; +$PHPMAILER_LANG['encoding'] = 'Codificación descoñecida: '; +$PHPMAILER_LANG['execute'] = 'Non puido ser executado: '; +$PHPMAILER_LANG['file_access'] = 'Nob puido acceder ó arquivo: '; +$PHPMAILER_LANG['file_open'] = 'Erro de Arquivo: No puido abrir o arquivo: '; +$PHPMAILER_LANG['from_failed'] = 'A(s) seguinte(s) dirección(s) de remitente(s) deron erro: '; +$PHPMAILER_LANG['instantiate'] = 'Non puido crear unha instancia da función Mail.'; +$PHPMAILER_LANG['invalid_address'] = 'Non puido envia-lo correo: dirección de email inválida: '; +$PHPMAILER_LANG['mailer_not_supported'] = ' mailer non está soportado.'; +$PHPMAILER_LANG['provide_address'] = 'Debe engadir polo menos unha dirección de email coma destino.'; +$PHPMAILER_LANG['recipients_failed'] = 'Erro SMTP: Os seguintes destinos fallaron: '; +$PHPMAILER_LANG['signing'] = 'Erro ó firmar: '; +$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() fallou.'; +$PHPMAILER_LANG['smtp_error'] = 'Erro do servidor SMTP: '; +$PHPMAILER_LANG['variable_set'] = 'Non puidemos axustar ou reaxustar a variábel: '; +//$PHPMAILER_LANG['extension_missing'] = 'Extension missing: '; diff --git a/vendor/phpmailer/phpmailer/language/phpmailer.lang-he.php b/vendor/phpmailer/phpmailer/language/phpmailer.lang-he.php new file mode 100644 index 0000000..b123aa5 --- /dev/null +++ b/vendor/phpmailer/phpmailer/language/phpmailer.lang-he.php @@ -0,0 +1,27 @@ + + */ + +$PHPMAILER_LANG['authenticate'] = 'שגיאת SMTP: פעולת האימות נכשלה.'; +$PHPMAILER_LANG['connect_host'] = 'שגיאת SMTP: לא הצלחתי להתחבר לשרת SMTP.'; +$PHPMAILER_LANG['data_not_accepted'] = 'שגיאת SMTP: מידע לא התקבל.'; +$PHPMAILER_LANG['empty_message'] = 'גוף ההודעה ריק'; +$PHPMAILER_LANG['invalid_address'] = 'כתובת שגויה: '; +$PHPMAILER_LANG['encoding'] = 'קידוד לא מוכר: '; +$PHPMAILER_LANG['execute'] = 'לא הצלחתי להפעיל את: '; +$PHPMAILER_LANG['file_access'] = 'לא ניתן לגשת לקובץ: '; +$PHPMAILER_LANG['file_open'] = 'שגיאת קובץ: לא ניתן לגשת לקובץ: '; +$PHPMAILER_LANG['from_failed'] = 'כתובות הנמענים הבאות נכשלו: '; +$PHPMAILER_LANG['instantiate'] = 'לא הצלחתי להפעיל את פונקציית המייל.'; +$PHPMAILER_LANG['mailer_not_supported'] = ' אינה נתמכת.'; +$PHPMAILER_LANG['provide_address'] = 'חובה לספק לפחות כתובת אחת של מקבל המייל.'; +$PHPMAILER_LANG['recipients_failed'] = 'שגיאת SMTP: הנמענים הבאים נכשלו: '; +$PHPMAILER_LANG['signing'] = 'שגיאת חתימה: '; +$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() failed.'; +$PHPMAILER_LANG['smtp_error'] = 'שגיאת שרת SMTP: '; +$PHPMAILER_LANG['variable_set'] = 'לא ניתן לקבוע או לשנות את המשתנה: '; +//$PHPMAILER_LANG['extension_missing'] = 'Extension missing: '; diff --git a/vendor/phpmailer/phpmailer/language/phpmailer.lang-hi.php b/vendor/phpmailer/phpmailer/language/phpmailer.lang-hi.php new file mode 100644 index 0000000..d973a35 --- /dev/null +++ b/vendor/phpmailer/phpmailer/language/phpmailer.lang-hi.php @@ -0,0 +1,27 @@ + + */ + +$PHPMAILER_LANG['authenticate'] = 'SMTP त्रुटि: प्रामाणिकता की जांच नहीं हो सका। '; +$PHPMAILER_LANG['connect_host'] = 'SMTP त्रुटि: SMTP सर्वर से कनेक्ट नहीं हो सका। '; +$PHPMAILER_LANG['data_not_accepted'] = 'SMTP त्रुटि: डेटा स्वीकार नहीं किया जाता है। '; +$PHPMAILER_LANG['empty_message'] = 'संदेश खाली है। '; +$PHPMAILER_LANG['encoding'] = 'अज्ञात एन्कोडिंग प्रकार। '; +$PHPMAILER_LANG['execute'] = 'आदेश को निष्पादित करने में विफल। '; +$PHPMAILER_LANG['file_access'] = 'फ़ाइल उपलब्ध नहीं है। '; +$PHPMAILER_LANG['file_open'] = 'फ़ाइल त्रुटि: फाइल को खोला नहीं जा सका। '; +$PHPMAILER_LANG['from_failed'] = 'प्रेषक का पता गलत है। '; +$PHPMAILER_LANG['instantiate'] = 'मेल फ़ंक्शन कॉल नहीं कर सकता है।'; +$PHPMAILER_LANG['invalid_address'] = 'पता गलत है। '; +$PHPMAILER_LANG['mailer_not_supported'] = 'मेल सर्वर के साथ काम नहीं करता है। '; +$PHPMAILER_LANG['provide_address'] = 'आपको कम से कम एक प्राप्तकर्ता का ई-मेल पता प्रदान करना होगा।'; +$PHPMAILER_LANG['recipients_failed'] = 'SMTP त्रुटि: निम्न प्राप्तकर्ताओं को पते भेजने में विफल। '; +$PHPMAILER_LANG['signing'] = 'साइनअप त्रुटि:। '; +$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP का connect () फ़ंक्शन विफल हुआ। '; +$PHPMAILER_LANG['smtp_error'] = 'SMTP सर्वर त्रुटि। '; +$PHPMAILER_LANG['variable_set'] = 'चर को बना या संशोधित नहीं किया जा सकता। '; +$PHPMAILER_LANG['extension_missing'] = 'एक्सटेन्षन गायब है: '; diff --git a/vendor/phpmailer/phpmailer/language/phpmailer.lang-hr.php b/vendor/phpmailer/phpmailer/language/phpmailer.lang-hr.php new file mode 100644 index 0000000..cacb6c3 --- /dev/null +++ b/vendor/phpmailer/phpmailer/language/phpmailer.lang-hr.php @@ -0,0 +1,27 @@ + + */ + +$PHPMAILER_LANG['authenticate'] = 'SMTP Greška: Neuspjela autentikacija.'; +$PHPMAILER_LANG['connect_host'] = 'SMTP Greška: Ne mogu se spojiti na SMTP poslužitelj.'; +$PHPMAILER_LANG['data_not_accepted'] = 'SMTP Greška: Podatci nisu prihvaćeni.'; +$PHPMAILER_LANG['empty_message'] = 'Sadržaj poruke je prazan.'; +$PHPMAILER_LANG['encoding'] = 'Nepoznati encoding: '; +$PHPMAILER_LANG['execute'] = 'Nije moguće izvršiti naredbu: '; +$PHPMAILER_LANG['file_access'] = 'Nije moguće pristupiti datoteci: '; +$PHPMAILER_LANG['file_open'] = 'Nije moguće otvoriti datoteku: '; +$PHPMAILER_LANG['from_failed'] = 'SMTP Greška: Slanje s navedenih e-mail adresa nije uspjelo: '; +$PHPMAILER_LANG['recipients_failed'] = 'SMTP Greška: Slanje na navedenih e-mail adresa nije uspjelo: '; +$PHPMAILER_LANG['instantiate'] = 'Ne mogu pokrenuti mail funkcionalnost.'; +$PHPMAILER_LANG['invalid_address'] = 'E-mail nije poslan. Neispravna e-mail adresa: '; +$PHPMAILER_LANG['mailer_not_supported'] = ' mailer nije podržan.'; +$PHPMAILER_LANG['provide_address'] = 'Definirajte barem jednu adresu primatelja.'; +$PHPMAILER_LANG['signing'] = 'Greška prilikom prijave: '; +$PHPMAILER_LANG['smtp_connect_failed'] = 'Spajanje na SMTP poslužitelj nije uspjelo.'; +$PHPMAILER_LANG['smtp_error'] = 'Greška SMTP poslužitelja: '; +$PHPMAILER_LANG['variable_set'] = 'Ne mogu postaviti varijablu niti ju vratiti nazad: '; +$PHPMAILER_LANG['extension_missing'] = 'Nedostaje proširenje: '; diff --git a/vendor/phpmailer/phpmailer/language/phpmailer.lang-hu.php b/vendor/phpmailer/phpmailer/language/phpmailer.lang-hu.php new file mode 100644 index 0000000..e6b58b0 --- /dev/null +++ b/vendor/phpmailer/phpmailer/language/phpmailer.lang-hu.php @@ -0,0 +1,27 @@ + + */ + +$PHPMAILER_LANG['authenticate'] = 'SMTP -ի սխալ: չհաջողվեց ստուգել իսկությունը.'; +$PHPMAILER_LANG['connect_host'] = 'SMTP -ի սխալ: չհաջողվեց կապ հաստատել SMTP սերվերի հետ.'; +$PHPMAILER_LANG['data_not_accepted'] = 'SMTP -ի սխալ: տվյալները ընդունված չեն.'; +$PHPMAILER_LANG['empty_message'] = 'Հաղորդագրությունը դատարկ է'; +$PHPMAILER_LANG['encoding'] = 'Կոդավորման անհայտ տեսակ: '; +$PHPMAILER_LANG['execute'] = 'Չհաջողվեց իրականացնել հրամանը: '; +$PHPMAILER_LANG['file_access'] = 'Ֆայլը հասանելի չէ: '; +$PHPMAILER_LANG['file_open'] = 'Ֆայլի սխալ: ֆայլը չհաջողվեց բացել: '; +$PHPMAILER_LANG['from_failed'] = 'Ուղարկողի հետևյալ հասցեն սխալ է: '; +$PHPMAILER_LANG['instantiate'] = 'Հնարավոր չէ կանչել mail ֆունկցիան.'; +$PHPMAILER_LANG['invalid_address'] = 'Հասցեն սխալ է: '; +$PHPMAILER_LANG['mailer_not_supported'] = ' փոստային սերվերի հետ չի աշխատում.'; +$PHPMAILER_LANG['provide_address'] = 'Անհրաժեշտ է տրամադրել գոնե մեկ ստացողի e-mail հասցե.'; +$PHPMAILER_LANG['recipients_failed'] = 'SMTP -ի սխալ: չի հաջողվել ուղարկել հետևյալ ստացողների հասցեներին: '; +$PHPMAILER_LANG['signing'] = 'Ստորագրման սխալ: '; +$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP -ի connect() ֆունկցիան չի հաջողվել'; +$PHPMAILER_LANG['smtp_error'] = 'SMTP սերվերի սխալ: '; +$PHPMAILER_LANG['variable_set'] = 'Չի հաջողվում ստեղծել կամ վերափոխել փոփոխականը: '; +$PHPMAILER_LANG['extension_missing'] = 'Հավելվածը բացակայում է: '; diff --git a/vendor/phpmailer/phpmailer/language/phpmailer.lang-id.php b/vendor/phpmailer/phpmailer/language/phpmailer.lang-id.php new file mode 100644 index 0000000..212a11f --- /dev/null +++ b/vendor/phpmailer/phpmailer/language/phpmailer.lang-id.php @@ -0,0 +1,31 @@ + + * @author @januridp + * @author Ian Mustafa + */ + +$PHPMAILER_LANG['authenticate'] = 'Kesalahan SMTP: Tidak dapat mengotentikasi.'; +$PHPMAILER_LANG['connect_host'] = 'Kesalahan SMTP: Tidak dapat terhubung ke host SMTP.'; +$PHPMAILER_LANG['data_not_accepted'] = 'Kesalahan SMTP: Data tidak diterima.'; +$PHPMAILER_LANG['empty_message'] = 'Isi pesan kosong'; +$PHPMAILER_LANG['encoding'] = 'Pengkodean karakter tidak dikenali: '; +$PHPMAILER_LANG['execute'] = 'Tidak dapat menjalankan proses: '; +$PHPMAILER_LANG['file_access'] = 'Tidak dapat mengakses berkas: '; +$PHPMAILER_LANG['file_open'] = 'Kesalahan Berkas: Berkas tidak dapat dibuka: '; +$PHPMAILER_LANG['from_failed'] = 'Alamat pengirim berikut mengakibatkan kesalahan: '; +$PHPMAILER_LANG['instantiate'] = 'Tidak dapat menginisialisasi fungsi surel.'; +$PHPMAILER_LANG['invalid_address'] = 'Gagal terkirim, alamat surel tidak sesuai: '; +$PHPMAILER_LANG['invalid_hostentry'] = 'Gagal terkirim, entri host tidak sesuai: '; +$PHPMAILER_LANG['invalid_host'] = 'Gagal terkirim, host tidak sesuai: '; +$PHPMAILER_LANG['provide_address'] = 'Harus tersedia minimal satu alamat tujuan'; +$PHPMAILER_LANG['mailer_not_supported'] = ' mailer tidak didukung'; +$PHPMAILER_LANG['recipients_failed'] = 'Kesalahan SMTP: Alamat tujuan berikut menyebabkan kesalahan: '; +$PHPMAILER_LANG['signing'] = 'Kesalahan dalam penandatangan SSL: '; +$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() gagal.'; +$PHPMAILER_LANG['smtp_error'] = 'Kesalahan pada pelayan SMTP: '; +$PHPMAILER_LANG['variable_set'] = 'Tidak dapat mengatur atau mengatur ulang variabel: '; +$PHPMAILER_LANG['extension_missing'] = 'Ekstensi PHP tidak tersedia: '; diff --git a/vendor/phpmailer/phpmailer/language/phpmailer.lang-it.php b/vendor/phpmailer/phpmailer/language/phpmailer.lang-it.php new file mode 100644 index 0000000..08a6b73 --- /dev/null +++ b/vendor/phpmailer/phpmailer/language/phpmailer.lang-it.php @@ -0,0 +1,28 @@ + + * @author Stefano Sabatini + */ + +$PHPMAILER_LANG['authenticate'] = 'SMTP Error: Impossibile autenticarsi.'; +$PHPMAILER_LANG['connect_host'] = 'SMTP Error: Impossibile connettersi all\'host SMTP.'; +$PHPMAILER_LANG['data_not_accepted'] = 'SMTP Error: Dati non accettati dal server.'; +$PHPMAILER_LANG['empty_message'] = 'Il corpo del messaggio è vuoto'; +$PHPMAILER_LANG['encoding'] = 'Codifica dei caratteri sconosciuta: '; +$PHPMAILER_LANG['execute'] = 'Impossibile eseguire l\'operazione: '; +$PHPMAILER_LANG['file_access'] = 'Impossibile accedere al file: '; +$PHPMAILER_LANG['file_open'] = 'File Error: Impossibile aprire il file: '; +$PHPMAILER_LANG['from_failed'] = 'I seguenti indirizzi mittenti hanno generato errore: '; +$PHPMAILER_LANG['instantiate'] = 'Impossibile istanziare la funzione mail'; +$PHPMAILER_LANG['invalid_address'] = 'Impossibile inviare, l\'indirizzo email non è valido: '; +$PHPMAILER_LANG['provide_address'] = 'Deve essere fornito almeno un indirizzo ricevente'; +$PHPMAILER_LANG['mailer_not_supported'] = 'Mailer non supportato'; +$PHPMAILER_LANG['recipients_failed'] = 'SMTP Error: I seguenti indirizzi destinatari hanno generato un errore: '; +$PHPMAILER_LANG['signing'] = 'Errore nella firma: '; +$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() fallita.'; +$PHPMAILER_LANG['smtp_error'] = 'Errore del server SMTP: '; +$PHPMAILER_LANG['variable_set'] = 'Impossibile impostare o resettare la variabile: '; +$PHPMAILER_LANG['extension_missing'] = 'Estensione mancante: '; diff --git a/vendor/phpmailer/phpmailer/language/phpmailer.lang-ja.php b/vendor/phpmailer/phpmailer/language/phpmailer.lang-ja.php new file mode 100644 index 0000000..c76f526 --- /dev/null +++ b/vendor/phpmailer/phpmailer/language/phpmailer.lang-ja.php @@ -0,0 +1,29 @@ + + * @author Yoshi Sakai + * @author Arisophy + */ + +$PHPMAILER_LANG['authenticate'] = 'SMTPエラー: 認証できませんでした。'; +$PHPMAILER_LANG['connect_host'] = 'SMTPエラー: SMTPホストに接続できませんでした。'; +$PHPMAILER_LANG['data_not_accepted'] = 'SMTPエラー: データが受け付けられませんでした。'; +$PHPMAILER_LANG['empty_message'] = 'メール本文が空です。'; +$PHPMAILER_LANG['encoding'] = '不明なエンコーディング: '; +$PHPMAILER_LANG['execute'] = '実行できませんでした: '; +$PHPMAILER_LANG['file_access'] = 'ファイルにアクセスできません: '; +$PHPMAILER_LANG['file_open'] = 'ファイルエラー: ファイルを開けません: '; +$PHPMAILER_LANG['from_failed'] = 'Fromアドレスを登録する際にエラーが発生しました: '; +$PHPMAILER_LANG['instantiate'] = 'メール関数が正常に動作しませんでした。'; +$PHPMAILER_LANG['invalid_address'] = '不正なメールアドレス: '; +$PHPMAILER_LANG['provide_address'] = '少なくとも1つメールアドレスを 指定する必要があります。'; +$PHPMAILER_LANG['mailer_not_supported'] = ' メーラーがサポートされていません。'; +$PHPMAILER_LANG['recipients_failed'] = 'SMTPエラー: 次の受信者アドレスに 間違いがあります: '; +$PHPMAILER_LANG['signing'] = '署名エラー: '; +$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP接続に失敗しました。'; +$PHPMAILER_LANG['smtp_error'] = 'SMTPサーバーエラー: '; +$PHPMAILER_LANG['variable_set'] = '変数が存在しません: '; +$PHPMAILER_LANG['extension_missing'] = '拡張機能が見つかりません: '; diff --git a/vendor/phpmailer/phpmailer/language/phpmailer.lang-ka.php b/vendor/phpmailer/phpmailer/language/phpmailer.lang-ka.php new file mode 100644 index 0000000..51fe403 --- /dev/null +++ b/vendor/phpmailer/phpmailer/language/phpmailer.lang-ka.php @@ -0,0 +1,27 @@ + + */ + +$PHPMAILER_LANG['authenticate'] = 'SMTP შეცდომა: ავტორიზაცია შეუძლებელია.'; +$PHPMAILER_LANG['connect_host'] = 'SMTP შეცდომა: SMTP სერვერთან დაკავშირება შეუძლებელია.'; +$PHPMAILER_LANG['data_not_accepted'] = 'SMTP შეცდომა: მონაცემები არ იქნა მიღებული.'; +$PHPMAILER_LANG['encoding'] = 'კოდირების უცნობი ტიპი: '; +$PHPMAILER_LANG['execute'] = 'შეუძლებელია შემდეგი ბრძანების შესრულება: '; +$PHPMAILER_LANG['file_access'] = 'შეუძლებელია წვდომა ფაილთან: '; +$PHPMAILER_LANG['file_open'] = 'ფაილური სისტემის შეცდომა: არ იხსნება ფაილი: '; +$PHPMAILER_LANG['from_failed'] = 'გამგზავნის არასწორი მისამართი: '; +$PHPMAILER_LANG['instantiate'] = 'mail ფუნქციის გაშვება ვერ ხერხდება.'; +$PHPMAILER_LANG['provide_address'] = 'გთხოვთ მიუთითოთ ერთი ადრესატის e-mail მისამართი მაინც.'; +$PHPMAILER_LANG['mailer_not_supported'] = ' - საფოსტო სერვერის მხარდაჭერა არ არის.'; +$PHPMAILER_LANG['recipients_failed'] = 'SMTP შეცდომა: შემდეგ მისამართებზე გაგზავნა ვერ მოხერხდა: '; +$PHPMAILER_LANG['empty_message'] = 'შეტყობინება ცარიელია'; +$PHPMAILER_LANG['invalid_address'] = 'არ გაიგზავნა, e-mail მისამართის არასწორი ფორმატი: '; +$PHPMAILER_LANG['signing'] = 'ხელმოწერის შეცდომა: '; +$PHPMAILER_LANG['smtp_connect_failed'] = 'შეცდომა SMTP სერვერთან დაკავშირებისას'; +$PHPMAILER_LANG['smtp_error'] = 'SMTP სერვერის შეცდომა: '; +$PHPMAILER_LANG['variable_set'] = 'შეუძლებელია შემდეგი ცვლადის შექმნა ან შეცვლა: '; +$PHPMAILER_LANG['extension_missing'] = 'ბიბლიოთეკა არ არსებობს: '; diff --git a/vendor/phpmailer/phpmailer/language/phpmailer.lang-ko.php b/vendor/phpmailer/phpmailer/language/phpmailer.lang-ko.php new file mode 100644 index 0000000..8c97dd9 --- /dev/null +++ b/vendor/phpmailer/phpmailer/language/phpmailer.lang-ko.php @@ -0,0 +1,27 @@ + + */ + +$PHPMAILER_LANG['authenticate'] = 'SMTP 오류: 인증할 수 없습니다.'; +$PHPMAILER_LANG['connect_host'] = 'SMTP 오류: SMTP 호스트에 접속할 수 없습니다.'; +$PHPMAILER_LANG['data_not_accepted'] = 'SMTP 오류: 데이터가 받아들여지지 않았습니다.'; +$PHPMAILER_LANG['empty_message'] = '메세지 내용이 없습니다'; +$PHPMAILER_LANG['encoding'] = '알 수 없는 인코딩: '; +$PHPMAILER_LANG['execute'] = '실행 불가: '; +$PHPMAILER_LANG['file_access'] = '파일 접근 불가: '; +$PHPMAILER_LANG['file_open'] = '파일 오류: 파일을 열 수 없습니다: '; +$PHPMAILER_LANG['from_failed'] = '다음 From 주소에서 오류가 발생했습니다: '; +$PHPMAILER_LANG['instantiate'] = 'mail 함수를 인스턴스화할 수 없습니다'; +$PHPMAILER_LANG['invalid_address'] = '잘못된 주소: '; +$PHPMAILER_LANG['mailer_not_supported'] = ' 메일러는 지원되지 않습니다.'; +$PHPMAILER_LANG['provide_address'] = '적어도 한 개 이상의 수신자 메일 주소를 제공해야 합니다.'; +$PHPMAILER_LANG['recipients_failed'] = 'SMTP 오류: 다음 수신자에서 오류가 발생했습니다: '; +$PHPMAILER_LANG['signing'] = '서명 오류: '; +$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP 연결을 실패하였습니다.'; +$PHPMAILER_LANG['smtp_error'] = 'SMTP 서버 오류: '; +$PHPMAILER_LANG['variable_set'] = '변수 설정 및 초기화 불가: '; +$PHPMAILER_LANG['extension_missing'] = '확장자 없음: '; diff --git a/vendor/phpmailer/phpmailer/language/phpmailer.lang-lt.php b/vendor/phpmailer/phpmailer/language/phpmailer.lang-lt.php new file mode 100644 index 0000000..4f115b1 --- /dev/null +++ b/vendor/phpmailer/phpmailer/language/phpmailer.lang-lt.php @@ -0,0 +1,27 @@ + + */ + +$PHPMAILER_LANG['authenticate'] = 'SMTP klaida: autentifikacija nepavyko.'; +$PHPMAILER_LANG['connect_host'] = 'SMTP klaida: nepavyksta prisijungti prie SMTP stoties.'; +$PHPMAILER_LANG['data_not_accepted'] = 'SMTP klaida: duomenys nepriimti.'; +$PHPMAILER_LANG['empty_message'] = 'Laiško turinys tuščias'; +$PHPMAILER_LANG['encoding'] = 'Neatpažinta koduotė: '; +$PHPMAILER_LANG['execute'] = 'Nepavyko įvykdyti komandos: '; +$PHPMAILER_LANG['file_access'] = 'Byla nepasiekiama: '; +$PHPMAILER_LANG['file_open'] = 'Bylos klaida: Nepavyksta atidaryti: '; +$PHPMAILER_LANG['from_failed'] = 'Neteisingas siuntėjo adresas: '; +$PHPMAILER_LANG['instantiate'] = 'Nepavyko paleisti mail funkcijos.'; +$PHPMAILER_LANG['invalid_address'] = 'Neteisingas adresas: '; +$PHPMAILER_LANG['mailer_not_supported'] = ' pašto stotis nepalaikoma.'; +$PHPMAILER_LANG['provide_address'] = 'Nurodykite bent vieną gavėjo adresą.'; +$PHPMAILER_LANG['recipients_failed'] = 'SMTP klaida: nepavyko išsiųsti šiems gavėjams: '; +$PHPMAILER_LANG['signing'] = 'Prisijungimo klaida: '; +$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP susijungimo klaida'; +$PHPMAILER_LANG['smtp_error'] = 'SMTP stoties klaida: '; +$PHPMAILER_LANG['variable_set'] = 'Nepavyko priskirti reikšmės kintamajam: '; +//$PHPMAILER_LANG['extension_missing'] = 'Extension missing: '; diff --git a/vendor/phpmailer/phpmailer/language/phpmailer.lang-lv.php b/vendor/phpmailer/phpmailer/language/phpmailer.lang-lv.php new file mode 100644 index 0000000..679b18c --- /dev/null +++ b/vendor/phpmailer/phpmailer/language/phpmailer.lang-lv.php @@ -0,0 +1,27 @@ + + */ + +$PHPMAILER_LANG['authenticate'] = 'SMTP kļūda: Autorizācija neizdevās.'; +$PHPMAILER_LANG['connect_host'] = 'SMTP Kļūda: Nevar izveidot savienojumu ar SMTP serveri.'; +$PHPMAILER_LANG['data_not_accepted'] = 'SMTP Kļūda: Nepieņem informāciju.'; +$PHPMAILER_LANG['empty_message'] = 'Ziņojuma teksts ir tukšs'; +$PHPMAILER_LANG['encoding'] = 'Neatpazīts kodējums: '; +$PHPMAILER_LANG['execute'] = 'Neizdevās izpildīt komandu: '; +$PHPMAILER_LANG['file_access'] = 'Fails nav pieejams: '; +$PHPMAILER_LANG['file_open'] = 'Faila kļūda: Nevar atvērt failu: '; +$PHPMAILER_LANG['from_failed'] = 'Nepareiza sūtītāja adrese: '; +$PHPMAILER_LANG['instantiate'] = 'Nevar palaist sūtīšanas funkciju.'; +$PHPMAILER_LANG['invalid_address'] = 'Nepareiza adrese: '; +$PHPMAILER_LANG['mailer_not_supported'] = ' sūtītājs netiek atbalstīts.'; +$PHPMAILER_LANG['provide_address'] = 'Lūdzu, norādiet vismaz vienu adresātu.'; +$PHPMAILER_LANG['recipients_failed'] = 'SMTP kļūda: neizdevās nosūtīt šādiem saņēmējiem: '; +$PHPMAILER_LANG['signing'] = 'Autorizācijas kļūda: '; +$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP savienojuma kļūda'; +$PHPMAILER_LANG['smtp_error'] = 'SMTP servera kļūda: '; +$PHPMAILER_LANG['variable_set'] = 'Nevar piešķirt mainīgā vērtību: '; +//$PHPMAILER_LANG['extension_missing'] = 'Extension missing: '; diff --git a/vendor/phpmailer/phpmailer/language/phpmailer.lang-mg.php b/vendor/phpmailer/phpmailer/language/phpmailer.lang-mg.php new file mode 100644 index 0000000..8a94f6a --- /dev/null +++ b/vendor/phpmailer/phpmailer/language/phpmailer.lang-mg.php @@ -0,0 +1,27 @@ + + */ + +$PHPMAILER_LANG['authenticate'] = 'Hadisoana SMTP: Tsy nahomby ny fanamarinana.'; +$PHPMAILER_LANG['connect_host'] = 'SMTP Error: Tsy afaka mampifandray amin\'ny mpampiantrano SMTP.'; +$PHPMAILER_LANG['data_not_accepted'] = 'SMTP diso: tsy voarakitra ny angona.'; +$PHPMAILER_LANG['empty_message'] = 'Tsy misy ny votoaty mailaka.'; +$PHPMAILER_LANG['encoding'] = 'Tsy fantatra encoding: '; +$PHPMAILER_LANG['execute'] = 'Tsy afaka manatanteraka ity baiko manaraka ity: '; +$PHPMAILER_LANG['file_access'] = 'Tsy nahomby ny fidirana amin\'ity rakitra ity: '; +$PHPMAILER_LANG['file_open'] = 'Hadisoana diso: Tsy afaka nanokatra ity file manaraka ity: '; +$PHPMAILER_LANG['from_failed'] = 'Ny adiresy iraka manaraka dia diso: '; +$PHPMAILER_LANG['instantiate'] = 'Tsy afaka nanomboka ny hetsika mail.'; +$PHPMAILER_LANG['invalid_address'] = 'Tsy mety ny adiresy: '; +$PHPMAILER_LANG['mailer_not_supported'] = ' mailer tsy manohana.'; +$PHPMAILER_LANG['provide_address'] = 'Alefaso azafady iray adiresy iray farafahakeliny.'; +$PHPMAILER_LANG['recipients_failed'] = 'SMTP Error: Tsy mety ireo mpanaraka ireto: '; +$PHPMAILER_LANG['signing'] = 'Error nandritra ny sonia:'; +$PHPMAILER_LANG['smtp_connect_failed'] = 'Tsy nahomby ny fifandraisana tamin\'ny server SMTP.'; +$PHPMAILER_LANG['smtp_error'] = 'Fahadisoana tamin\'ny server SMTP: '; +$PHPMAILER_LANG['variable_set'] = 'Tsy azo atao ny mametraka na mamerina ny variable: '; +$PHPMAILER_LANG['extension_missing'] = 'Tsy hita ny ampahany: '; diff --git a/vendor/phpmailer/phpmailer/language/phpmailer.lang-ms.php b/vendor/phpmailer/phpmailer/language/phpmailer.lang-ms.php new file mode 100644 index 0000000..71db338 --- /dev/null +++ b/vendor/phpmailer/phpmailer/language/phpmailer.lang-ms.php @@ -0,0 +1,27 @@ + + */ + +$PHPMAILER_LANG['authenticate'] = 'Ralat SMTP: Tidak dapat pengesahan.'; +$PHPMAILER_LANG['connect_host'] = 'Ralat SMTP: Tidak dapat menghubungi hos pelayan SMTP.'; +$PHPMAILER_LANG['data_not_accepted'] = 'Ralat SMTP: Data tidak diterima oleh pelayan.'; +$PHPMAILER_LANG['empty_message'] = 'Tiada isi untuk mesej'; +$PHPMAILER_LANG['encoding'] = 'Pengekodan tidak diketahui: '; +$PHPMAILER_LANG['execute'] = 'Tidak dapat melaksanakan: '; +$PHPMAILER_LANG['file_access'] = 'Tidak dapat mengakses fail: '; +$PHPMAILER_LANG['file_open'] = 'Ralat Fail: Tidak dapat membuka fail: '; +$PHPMAILER_LANG['from_failed'] = 'Berikut merupakan ralat dari alamat e-mel: '; +$PHPMAILER_LANG['instantiate'] = 'Tidak dapat memberi contoh fungsi e-mel.'; +$PHPMAILER_LANG['invalid_address'] = 'Alamat emel tidak sah: '; +$PHPMAILER_LANG['mailer_not_supported'] = ' jenis penghantar emel tidak disokong.'; +$PHPMAILER_LANG['provide_address'] = 'Anda perlu menyediakan sekurang-kurangnya satu alamat e-mel penerima.'; +$PHPMAILER_LANG['recipients_failed'] = 'Ralat SMTP: Penerima e-mel berikut telah gagal: '; +$PHPMAILER_LANG['signing'] = 'Ralat pada tanda tangan: '; +$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() telah gagal.'; +$PHPMAILER_LANG['smtp_error'] = 'Ralat pada pelayan SMTP: '; +$PHPMAILER_LANG['variable_set'] = 'Tidak boleh menetapkan atau menetapkan semula pembolehubah: '; +$PHPMAILER_LANG['extension_missing'] = 'Sambungan hilang: '; diff --git a/vendor/phpmailer/phpmailer/language/phpmailer.lang-nb.php b/vendor/phpmailer/phpmailer/language/phpmailer.lang-nb.php new file mode 100644 index 0000000..65793ce --- /dev/null +++ b/vendor/phpmailer/phpmailer/language/phpmailer.lang-nb.php @@ -0,0 +1,26 @@ + + */ + +$PHPMAILER_LANG['authenticate'] = 'SMTP-fout: authenticatie mislukt.'; +$PHPMAILER_LANG['buggy_php'] = 'PHP versie gededecteerd die onderhavig is aan een bug die kan resulteren in gecorrumpeerde berichten. Om dit te voorkomen, gebruik SMTP voor het verzenden van berichten, zet de mail.add_x_header optie in uw php.ini file uit, gebruik MacOS of Linux, of pas de gebruikte PHP versie aan naar versie 7.0.17+ or 7.1.3+.'; +$PHPMAILER_LANG['connect_host'] = 'SMTP-fout: kon niet verbinden met SMTP-host.'; +$PHPMAILER_LANG['data_not_accepted'] = 'SMTP-fout: data niet geaccepteerd.'; +$PHPMAILER_LANG['empty_message'] = 'Berichttekst is leeg'; +$PHPMAILER_LANG['encoding'] = 'Onbekende codering: '; +$PHPMAILER_LANG['execute'] = 'Kon niet uitvoeren: '; +$PHPMAILER_LANG['extension_missing'] = 'Extensie afwezig: '; +$PHPMAILER_LANG['file_access'] = 'Kreeg geen toegang tot bestand: '; +$PHPMAILER_LANG['file_open'] = 'Bestandsfout: kon bestand niet openen: '; +$PHPMAILER_LANG['from_failed'] = 'Het volgende afzendersadres is mislukt: '; +$PHPMAILER_LANG['instantiate'] = 'Kon mailfunctie niet initialiseren.'; +$PHPMAILER_LANG['invalid_address'] = 'Ongeldig adres: '; +$PHPMAILER_LANG['invalid_header'] = 'Ongeldige header naam of waarde'; +$PHPMAILER_LANG['invalid_hostentry'] = 'Ongeldige hostentry: '; +$PHPMAILER_LANG['invalid_host'] = 'Ongeldige host: '; +$PHPMAILER_LANG['mailer_not_supported'] = ' mailer wordt niet ondersteund.'; +$PHPMAILER_LANG['provide_address'] = 'Er moet minstens één ontvanger worden opgegeven.'; +$PHPMAILER_LANG['recipients_failed'] = 'SMTP-fout: de volgende ontvangers zijn mislukt: '; +$PHPMAILER_LANG['signing'] = 'Signeerfout: '; +$PHPMAILER_LANG['smtp_code'] = 'SMTP code: '; +$PHPMAILER_LANG['smtp_code_ex'] = 'Aanvullende SMTP informatie: '; +$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Verbinding mislukt.'; +$PHPMAILER_LANG['smtp_detail'] = 'Detail: '; +$PHPMAILER_LANG['smtp_error'] = 'SMTP-serverfout: '; +$PHPMAILER_LANG['variable_set'] = 'Kan de volgende variabele niet instellen of resetten: '; diff --git a/vendor/phpmailer/phpmailer/language/phpmailer.lang-pl.php b/vendor/phpmailer/phpmailer/language/phpmailer.lang-pl.php new file mode 100644 index 0000000..23caa71 --- /dev/null +++ b/vendor/phpmailer/phpmailer/language/phpmailer.lang-pl.php @@ -0,0 +1,27 @@ + + */ + +$PHPMAILER_LANG['authenticate'] = 'Erro do SMTP: Não foi possível realizar a autenticação.'; +$PHPMAILER_LANG['connect_host'] = 'Erro do SMTP: Não foi possível realizar ligação com o servidor SMTP.'; +$PHPMAILER_LANG['data_not_accepted'] = 'Erro do SMTP: Os dados foram rejeitados.'; +$PHPMAILER_LANG['empty_message'] = 'A mensagem no e-mail está vazia.'; +$PHPMAILER_LANG['encoding'] = 'Codificação desconhecida: '; +$PHPMAILER_LANG['execute'] = 'Não foi possível executar: '; +$PHPMAILER_LANG['file_access'] = 'Não foi possível aceder o ficheiro: '; +$PHPMAILER_LANG['file_open'] = 'Abertura do ficheiro: Não foi possível abrir o ficheiro: '; +$PHPMAILER_LANG['from_failed'] = 'Ocorreram falhas nos endereços dos seguintes remententes: '; +$PHPMAILER_LANG['instantiate'] = 'Não foi possível iniciar uma instância da função mail.'; +$PHPMAILER_LANG['invalid_address'] = 'Não foi enviado nenhum e-mail para o endereço de e-mail inválido: '; +$PHPMAILER_LANG['mailer_not_supported'] = ' mailer não é suportado.'; +$PHPMAILER_LANG['provide_address'] = 'Tem de fornecer pelo menos um endereço como destinatário do e-mail.'; +$PHPMAILER_LANG['recipients_failed'] = 'Erro do SMTP: O endereço do seguinte destinatário falhou: '; +$PHPMAILER_LANG['signing'] = 'Erro ao assinar: '; +$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() falhou.'; +$PHPMAILER_LANG['smtp_error'] = 'Erro de servidor SMTP: '; +$PHPMAILER_LANG['variable_set'] = 'Não foi possível definir ou redefinir a variável: '; +$PHPMAILER_LANG['extension_missing'] = 'Extensão em falta: '; diff --git a/vendor/phpmailer/phpmailer/language/phpmailer.lang-pt_br.php b/vendor/phpmailer/phpmailer/language/phpmailer.lang-pt_br.php new file mode 100644 index 0000000..d863809 --- /dev/null +++ b/vendor/phpmailer/phpmailer/language/phpmailer.lang-pt_br.php @@ -0,0 +1,30 @@ + + * @author Lucas Guimarães + * @author Phelipe Alves + * @author Fabio Beneditto + */ + +$PHPMAILER_LANG['authenticate'] = 'Erro de SMTP: Não foi possível autenticar.'; +$PHPMAILER_LANG['connect_host'] = 'Erro de SMTP: Não foi possível conectar ao servidor SMTP.'; +$PHPMAILER_LANG['data_not_accepted'] = 'Erro de SMTP: Dados rejeitados.'; +$PHPMAILER_LANG['empty_message'] = 'Mensagem vazia'; +$PHPMAILER_LANG['encoding'] = 'Codificação desconhecida: '; +$PHPMAILER_LANG['execute'] = 'Não foi possível executar: '; +$PHPMAILER_LANG['file_access'] = 'Não foi possível acessar o arquivo: '; +$PHPMAILER_LANG['file_open'] = 'Erro de Arquivo: Não foi possível abrir o arquivo: '; +$PHPMAILER_LANG['from_failed'] = 'Os seguintes remetentes falharam: '; +$PHPMAILER_LANG['instantiate'] = 'Não foi possível instanciar a função mail.'; +$PHPMAILER_LANG['invalid_address'] = 'Endereço de e-mail inválido: '; +$PHPMAILER_LANG['mailer_not_supported'] = ' mailer não é suportado.'; +$PHPMAILER_LANG['provide_address'] = 'Você deve informar pelo menos um destinatário.'; +$PHPMAILER_LANG['recipients_failed'] = 'Erro de SMTP: Os seguintes destinatários falharam: '; +$PHPMAILER_LANG['signing'] = 'Erro de Assinatura: '; +$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() falhou.'; +$PHPMAILER_LANG['smtp_error'] = 'Erro de servidor SMTP: '; +$PHPMAILER_LANG['variable_set'] = 'Não foi possível definir ou redefinir a variável: '; +$PHPMAILER_LANG['extension_missing'] = 'Extensão não existe: '; diff --git a/vendor/phpmailer/phpmailer/language/phpmailer.lang-ro.php b/vendor/phpmailer/phpmailer/language/phpmailer.lang-ro.php new file mode 100644 index 0000000..292ec1e --- /dev/null +++ b/vendor/phpmailer/phpmailer/language/phpmailer.lang-ro.php @@ -0,0 +1,27 @@ + + */ + +$PHPMAILER_LANG['authenticate'] = 'Eroare SMTP: Autentificarea a eșuat.'; +$PHPMAILER_LANG['connect_host'] = 'Eroare SMTP: Conectarea la serverul SMTP a eșuat.'; +$PHPMAILER_LANG['data_not_accepted'] = 'Eroare SMTP: Datele nu au fost acceptate.'; +$PHPMAILER_LANG['empty_message'] = 'Mesajul este gol.'; +$PHPMAILER_LANG['encoding'] = 'Encodare necunoscută: '; +$PHPMAILER_LANG['execute'] = 'Nu se poate executa următoarea comandă: '; +$PHPMAILER_LANG['file_access'] = 'Nu se poate accesa următorul fișier: '; +$PHPMAILER_LANG['file_open'] = 'Eroare fișier: Nu se poate deschide următorul fișier: '; +$PHPMAILER_LANG['from_failed'] = 'Următoarele adrese From au dat eroare: '; +$PHPMAILER_LANG['instantiate'] = 'Funcția mail nu a putut fi inițializată.'; +$PHPMAILER_LANG['invalid_address'] = 'Adresa de email nu este validă: '; +$PHPMAILER_LANG['mailer_not_supported'] = ' mailer nu este suportat.'; +$PHPMAILER_LANG['provide_address'] = 'Trebuie să adăugați cel puțin o adresă de email.'; +$PHPMAILER_LANG['recipients_failed'] = 'Eroare SMTP: Următoarele adrese de email au eșuat: '; +$PHPMAILER_LANG['signing'] = 'A aparut o problemă la semnarea emailului. '; +$PHPMAILER_LANG['smtp_connect_failed'] = 'Conectarea la serverul SMTP a eșuat.'; +$PHPMAILER_LANG['smtp_error'] = 'Eroare server SMTP: '; +$PHPMAILER_LANG['variable_set'] = 'Nu se poate seta/reseta variabila. '; +$PHPMAILER_LANG['extension_missing'] = 'Lipsește extensia: '; diff --git a/vendor/phpmailer/phpmailer/language/phpmailer.lang-ru.php b/vendor/phpmailer/phpmailer/language/phpmailer.lang-ru.php new file mode 100644 index 0000000..8c8c5e8 --- /dev/null +++ b/vendor/phpmailer/phpmailer/language/phpmailer.lang-ru.php @@ -0,0 +1,28 @@ + + * @author Foster Snowhill + */ + +$PHPMAILER_LANG['authenticate'] = 'Ошибка SMTP: ошибка авторизации.'; +$PHPMAILER_LANG['connect_host'] = 'Ошибка SMTP: не удается подключиться к SMTP-серверу.'; +$PHPMAILER_LANG['data_not_accepted'] = 'Ошибка SMTP: данные не приняты.'; +$PHPMAILER_LANG['encoding'] = 'Неизвестная кодировка: '; +$PHPMAILER_LANG['execute'] = 'Невозможно выполнить команду: '; +$PHPMAILER_LANG['file_access'] = 'Нет доступа к файлу: '; +$PHPMAILER_LANG['file_open'] = 'Файловая ошибка: не удаётся открыть файл: '; +$PHPMAILER_LANG['from_failed'] = 'Неверный адрес отправителя: '; +$PHPMAILER_LANG['instantiate'] = 'Невозможно запустить функцию mail().'; +$PHPMAILER_LANG['provide_address'] = 'Пожалуйста, введите хотя бы один email-адрес получателя.'; +$PHPMAILER_LANG['mailer_not_supported'] = ' — почтовый сервер не поддерживается.'; +$PHPMAILER_LANG['recipients_failed'] = 'Ошибка SMTP: не удалась отправка таким адресатам: '; +$PHPMAILER_LANG['empty_message'] = 'Пустое сообщение'; +$PHPMAILER_LANG['invalid_address'] = 'Не отправлено из-за неправильного формата email-адреса: '; +$PHPMAILER_LANG['signing'] = 'Ошибка подписи: '; +$PHPMAILER_LANG['smtp_connect_failed'] = 'Ошибка соединения с SMTP-сервером'; +$PHPMAILER_LANG['smtp_error'] = 'Ошибка SMTP-сервера: '; +$PHPMAILER_LANG['variable_set'] = 'Невозможно установить или сбросить переменную: '; +$PHPMAILER_LANG['extension_missing'] = 'Расширение отсутствует: '; diff --git a/vendor/phpmailer/phpmailer/language/phpmailer.lang-sk.php b/vendor/phpmailer/phpmailer/language/phpmailer.lang-sk.php new file mode 100644 index 0000000..028f5bc --- /dev/null +++ b/vendor/phpmailer/phpmailer/language/phpmailer.lang-sk.php @@ -0,0 +1,30 @@ + + * @author Peter Orlický + */ + +$PHPMAILER_LANG['authenticate'] = 'SMTP Error: Chyba autentifikácie.'; +$PHPMAILER_LANG['connect_host'] = 'SMTP Error: Nebolo možné nadviazať spojenie so SMTP serverom.'; +$PHPMAILER_LANG['data_not_accepted'] = 'SMTP Error: Dáta neboli prijaté'; +$PHPMAILER_LANG['empty_message'] = 'Prázdne telo správy.'; +$PHPMAILER_LANG['encoding'] = 'Neznáme kódovanie: '; +$PHPMAILER_LANG['execute'] = 'Nedá sa vykonať: '; +$PHPMAILER_LANG['file_access'] = 'Súbor nebol nájdený: '; +$PHPMAILER_LANG['file_open'] = 'File Error: Súbor sa otvoriť pre čítanie: '; +$PHPMAILER_LANG['from_failed'] = 'Následujúca adresa From je nesprávna: '; +$PHPMAILER_LANG['instantiate'] = 'Nedá sa vytvoriť inštancia emailovej funkcie.'; +$PHPMAILER_LANG['invalid_address'] = 'Neodoslané, emailová adresa je nesprávna: '; +$PHPMAILER_LANG['invalid_hostentry'] = 'Záznam hostiteľa je nesprávny: '; +$PHPMAILER_LANG['invalid_host'] = 'Hostiteľ je nesprávny: '; +$PHPMAILER_LANG['mailer_not_supported'] = ' emailový klient nieje podporovaný.'; +$PHPMAILER_LANG['provide_address'] = 'Musíte zadať aspoň jednu emailovú adresu príjemcu.'; +$PHPMAILER_LANG['recipients_failed'] = 'SMTP Error: Adresy príjemcov niesu správne '; +$PHPMAILER_LANG['signing'] = 'Chyba prihlasovania: '; +$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() zlyhalo.'; +$PHPMAILER_LANG['smtp_error'] = 'SMTP chyba serveru: '; +$PHPMAILER_LANG['variable_set'] = 'Nemožno nastaviť alebo resetovať premennú: '; +$PHPMAILER_LANG['extension_missing'] = 'Chýba rozšírenie: '; diff --git a/vendor/phpmailer/phpmailer/language/phpmailer.lang-sl.php b/vendor/phpmailer/phpmailer/language/phpmailer.lang-sl.php new file mode 100644 index 0000000..c437a88 --- /dev/null +++ b/vendor/phpmailer/phpmailer/language/phpmailer.lang-sl.php @@ -0,0 +1,31 @@ + + * @author Filip Š + * @author Blaž Oražem + */ + +$PHPMAILER_LANG['authenticate'] = 'SMTP napaka: Avtentikacija ni uspela.'; +$PHPMAILER_LANG['connect_host'] = 'SMTP napaka: Vzpostavljanje povezave s SMTP gostiteljem ni uspelo.'; +$PHPMAILER_LANG['data_not_accepted'] = 'SMTP napaka: Strežnik zavrača podatke.'; +$PHPMAILER_LANG['empty_message'] = 'E-poštno sporočilo nima vsebine.'; +$PHPMAILER_LANG['encoding'] = 'Nepoznan tip kodiranja: '; +$PHPMAILER_LANG['execute'] = 'Operacija ni uspela: '; +$PHPMAILER_LANG['file_access'] = 'Nimam dostopa do datoteke: '; +$PHPMAILER_LANG['file_open'] = 'Ne morem odpreti datoteke: '; +$PHPMAILER_LANG['from_failed'] = 'Neveljaven e-naslov pošiljatelja: '; +$PHPMAILER_LANG['instantiate'] = 'Ne morem inicializirati mail funkcije.'; +$PHPMAILER_LANG['invalid_address'] = 'E-poštno sporočilo ni bilo poslano. E-naslov je neveljaven: '; +$PHPMAILER_LANG['invalid_hostentry'] = 'Neveljaven vnos gostitelja: '; +$PHPMAILER_LANG['invalid_host'] = 'Neveljaven gostitelj: '; +$PHPMAILER_LANG['mailer_not_supported'] = ' mailer ni podprt.'; +$PHPMAILER_LANG['provide_address'] = 'Prosimo, vnesite vsaj enega naslovnika.'; +$PHPMAILER_LANG['recipients_failed'] = 'SMTP napaka: Sledeči naslovniki so neveljavni: '; +$PHPMAILER_LANG['signing'] = 'Napaka pri podpisovanju: '; +$PHPMAILER_LANG['smtp_connect_failed'] = 'Ne morem vzpostaviti povezave s SMTP strežnikom.'; +$PHPMAILER_LANG['smtp_error'] = 'Napaka SMTP strežnika: '; +$PHPMAILER_LANG['variable_set'] = 'Ne morem nastaviti oz. ponastaviti spremenljivke: '; +$PHPMAILER_LANG['extension_missing'] = 'Manjkajoča razširitev: '; diff --git a/vendor/phpmailer/phpmailer/language/phpmailer.lang-sr.php b/vendor/phpmailer/phpmailer/language/phpmailer.lang-sr.php new file mode 100644 index 0000000..0b5280f --- /dev/null +++ b/vendor/phpmailer/phpmailer/language/phpmailer.lang-sr.php @@ -0,0 +1,28 @@ + + * @author Miloš Milanović + */ + +$PHPMAILER_LANG['authenticate'] = 'SMTP грешка: аутентификација није успела.'; +$PHPMAILER_LANG['connect_host'] = 'SMTP грешка: повезивање са SMTP сервером није успело.'; +$PHPMAILER_LANG['data_not_accepted'] = 'SMTP грешка: подаци нису прихваћени.'; +$PHPMAILER_LANG['empty_message'] = 'Садржај поруке је празан.'; +$PHPMAILER_LANG['encoding'] = 'Непознато кодирање: '; +$PHPMAILER_LANG['execute'] = 'Није могуће извршити наредбу: '; +$PHPMAILER_LANG['file_access'] = 'Није могуће приступити датотеци: '; +$PHPMAILER_LANG['file_open'] = 'Није могуће отворити датотеку: '; +$PHPMAILER_LANG['from_failed'] = 'SMTP грешка: слање са следећих адреса није успело: '; +$PHPMAILER_LANG['recipients_failed'] = 'SMTP грешка: слање на следеће адресе није успело: '; +$PHPMAILER_LANG['instantiate'] = 'Није могуће покренути mail функцију.'; +$PHPMAILER_LANG['invalid_address'] = 'Порука није послата. Неисправна адреса: '; +$PHPMAILER_LANG['mailer_not_supported'] = ' мејлер није подржан.'; +$PHPMAILER_LANG['provide_address'] = 'Дефинишите бар једну адресу примаоца.'; +$PHPMAILER_LANG['signing'] = 'Грешка приликом пријаве: '; +$PHPMAILER_LANG['smtp_connect_failed'] = 'Повезивање са SMTP сервером није успело.'; +$PHPMAILER_LANG['smtp_error'] = 'Грешка SMTP сервера: '; +$PHPMAILER_LANG['variable_set'] = 'Није могуће задати нити ресетовати променљиву: '; +$PHPMAILER_LANG['extension_missing'] = 'Недостаје проширење: '; diff --git a/vendor/phpmailer/phpmailer/language/phpmailer.lang-sr_latn.php b/vendor/phpmailer/phpmailer/language/phpmailer.lang-sr_latn.php new file mode 100644 index 0000000..6213832 --- /dev/null +++ b/vendor/phpmailer/phpmailer/language/phpmailer.lang-sr_latn.php @@ -0,0 +1,28 @@ + + * @author Miloš Milanović + */ + +$PHPMAILER_LANG['authenticate'] = 'SMTP greška: autentifikacija nije uspela.'; +$PHPMAILER_LANG['connect_host'] = 'SMTP greška: povezivanje sa SMTP serverom nije uspelo.'; +$PHPMAILER_LANG['data_not_accepted'] = 'SMTP greška: podaci nisu prihvaćeni.'; +$PHPMAILER_LANG['empty_message'] = 'Sadržaj poruke je prazan.'; +$PHPMAILER_LANG['encoding'] = 'Nepoznato kodiranje: '; +$PHPMAILER_LANG['execute'] = 'Nije moguće izvršiti naredbu: '; +$PHPMAILER_LANG['file_access'] = 'Nije moguće pristupiti datoteci: '; +$PHPMAILER_LANG['file_open'] = 'Nije moguće otvoriti datoteku: '; +$PHPMAILER_LANG['from_failed'] = 'SMTP greška: slanje sa sledećih adresa nije uspelo: '; +$PHPMAILER_LANG['recipients_failed'] = 'SMTP greška: slanje na sledeće adrese nije uspelo: '; +$PHPMAILER_LANG['instantiate'] = 'Nije moguće pokrenuti mail funkciju.'; +$PHPMAILER_LANG['invalid_address'] = 'Poruka nije poslata. Neispravna adresa: '; +$PHPMAILER_LANG['mailer_not_supported'] = ' majler nije podržan.'; +$PHPMAILER_LANG['provide_address'] = 'Definišite bar jednu adresu primaoca.'; +$PHPMAILER_LANG['signing'] = 'Greška prilikom prijave: '; +$PHPMAILER_LANG['smtp_connect_failed'] = 'Povezivanje sa SMTP serverom nije uspelo.'; +$PHPMAILER_LANG['smtp_error'] = 'Greška SMTP servera: '; +$PHPMAILER_LANG['variable_set'] = 'Nije moguće zadati niti resetovati promenljivu: '; +$PHPMAILER_LANG['extension_missing'] = 'Nedostaje proširenje: '; diff --git a/vendor/phpmailer/phpmailer/language/phpmailer.lang-sv.php b/vendor/phpmailer/phpmailer/language/phpmailer.lang-sv.php new file mode 100644 index 0000000..9872c19 --- /dev/null +++ b/vendor/phpmailer/phpmailer/language/phpmailer.lang-sv.php @@ -0,0 +1,27 @@ + + */ + +$PHPMAILER_LANG['authenticate'] = 'SMTP fel: Kunde inte autentisera.'; +$PHPMAILER_LANG['connect_host'] = 'SMTP fel: Kunde inte ansluta till SMTP-server.'; +$PHPMAILER_LANG['data_not_accepted'] = 'SMTP fel: Data accepterades inte.'; +//$PHPMAILER_LANG['empty_message'] = 'Message body empty'; +$PHPMAILER_LANG['encoding'] = 'Okänt encode-format: '; +$PHPMAILER_LANG['execute'] = 'Kunde inte köra: '; +$PHPMAILER_LANG['file_access'] = 'Ingen åtkomst till fil: '; +$PHPMAILER_LANG['file_open'] = 'Fil fel: Kunde inte öppna fil: '; +$PHPMAILER_LANG['from_failed'] = 'Följande avsändaradress är felaktig: '; +$PHPMAILER_LANG['instantiate'] = 'Kunde inte initiera e-postfunktion.'; +$PHPMAILER_LANG['invalid_address'] = 'Felaktig adress: '; +$PHPMAILER_LANG['provide_address'] = 'Du måste ange minst en mottagares e-postadress.'; +$PHPMAILER_LANG['mailer_not_supported'] = ' mailer stöds inte.'; +$PHPMAILER_LANG['recipients_failed'] = 'SMTP fel: Följande mottagare är felaktig: '; +$PHPMAILER_LANG['signing'] = 'Signeringsfel: '; +$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() misslyckades.'; +$PHPMAILER_LANG['smtp_error'] = 'SMTP serverfel: '; +$PHPMAILER_LANG['variable_set'] = 'Kunde inte definiera eller återställa variabel: '; +$PHPMAILER_LANG['extension_missing'] = 'Tillägg ej tillgängligt: '; diff --git a/vendor/phpmailer/phpmailer/language/phpmailer.lang-tl.php b/vendor/phpmailer/phpmailer/language/phpmailer.lang-tl.php new file mode 100644 index 0000000..d15bed1 --- /dev/null +++ b/vendor/phpmailer/phpmailer/language/phpmailer.lang-tl.php @@ -0,0 +1,28 @@ + + */ + +$PHPMAILER_LANG['authenticate'] = 'SMTP Error: Hindi mapatotohanan.'; +$PHPMAILER_LANG['connect_host'] = 'SMTP Error: Hindi makakonekta sa SMTP host.'; +$PHPMAILER_LANG['data_not_accepted'] = 'SMTP Error: Ang datos ay hindi naitanggap.'; +$PHPMAILER_LANG['empty_message'] = 'Walang laman ang mensahe'; +$PHPMAILER_LANG['encoding'] = 'Hindi alam ang encoding: '; +$PHPMAILER_LANG['execute'] = 'Hindi maisasagawa: '; +$PHPMAILER_LANG['file_access'] = 'Hindi ma-access ang file: '; +$PHPMAILER_LANG['file_open'] = 'File Error: Hindi mabuksan ang file: '; +$PHPMAILER_LANG['from_failed'] = 'Ang sumusunod na address ay nabigo: '; +$PHPMAILER_LANG['instantiate'] = 'Hindi maisimulan ang instance ng mail function.'; +$PHPMAILER_LANG['invalid_address'] = 'Hindi wasto ang address na naibigay: '; +$PHPMAILER_LANG['mailer_not_supported'] = 'Ang mailer ay hindi suportado.'; +$PHPMAILER_LANG['provide_address'] = 'Kailangan mong magbigay ng kahit isang email address na tatanggap.'; +$PHPMAILER_LANG['recipients_failed'] = 'SMTP Error: Ang mga sumusunod na tatanggap ay nabigo: '; +$PHPMAILER_LANG['signing'] = 'Hindi ma-sign: '; +$PHPMAILER_LANG['smtp_connect_failed'] = 'Ang SMTP connect() ay nabigo.'; +$PHPMAILER_LANG['smtp_error'] = 'Ang server ng SMTP ay nabigo: '; +$PHPMAILER_LANG['variable_set'] = 'Hindi matatakda o ma-reset ang mga variables: '; +$PHPMAILER_LANG['extension_missing'] = 'Nawawala ang extension: '; diff --git a/vendor/phpmailer/phpmailer/language/phpmailer.lang-tr.php b/vendor/phpmailer/phpmailer/language/phpmailer.lang-tr.php new file mode 100644 index 0000000..f938f80 --- /dev/null +++ b/vendor/phpmailer/phpmailer/language/phpmailer.lang-tr.php @@ -0,0 +1,31 @@ + + * @fixed by Boris Yurchenko + */ + +$PHPMAILER_LANG['authenticate'] = 'Помилка SMTP: помилка авторизації.'; +$PHPMAILER_LANG['connect_host'] = 'Помилка SMTP: не вдається під\'єднатися до SMTP-серверу.'; +$PHPMAILER_LANG['data_not_accepted'] = 'Помилка SMTP: дані не прийнято.'; +$PHPMAILER_LANG['encoding'] = 'Невідоме кодування: '; +$PHPMAILER_LANG['execute'] = 'Неможливо виконати команду: '; +$PHPMAILER_LANG['file_access'] = 'Немає доступу до файлу: '; +$PHPMAILER_LANG['file_open'] = 'Помилка файлової системи: не вдається відкрити файл: '; +$PHPMAILER_LANG['from_failed'] = 'Невірна адреса відправника: '; +$PHPMAILER_LANG['instantiate'] = 'Неможливо запустити функцію mail().'; +$PHPMAILER_LANG['provide_address'] = 'Будь ласка, введіть хоча б одну email-адресу отримувача.'; +$PHPMAILER_LANG['mailer_not_supported'] = ' - поштовий сервер не підтримується.'; +$PHPMAILER_LANG['recipients_failed'] = 'Помилка SMTP: не вдалося відправлення для таких отримувачів: '; +$PHPMAILER_LANG['empty_message'] = 'Пусте повідомлення'; +$PHPMAILER_LANG['invalid_address'] = 'Не відправлено через неправильний формат email-адреси: '; +$PHPMAILER_LANG['signing'] = 'Помилка підпису: '; +$PHPMAILER_LANG['smtp_connect_failed'] = 'Помилка з\'єднання з SMTP-сервером'; +$PHPMAILER_LANG['smtp_error'] = 'Помилка SMTP-сервера: '; +$PHPMAILER_LANG['variable_set'] = 'Неможливо встановити або скинути змінну: '; +$PHPMAILER_LANG['extension_missing'] = 'Розширення відсутнє: '; diff --git a/vendor/phpmailer/phpmailer/language/phpmailer.lang-vi.php b/vendor/phpmailer/phpmailer/language/phpmailer.lang-vi.php new file mode 100644 index 0000000..d65576e --- /dev/null +++ b/vendor/phpmailer/phpmailer/language/phpmailer.lang-vi.php @@ -0,0 +1,27 @@ + + */ + +$PHPMAILER_LANG['authenticate'] = 'Lỗi SMTP: Không thể xác thực.'; +$PHPMAILER_LANG['connect_host'] = 'Lỗi SMTP: Không thể kết nối máy chủ SMTP.'; +$PHPMAILER_LANG['data_not_accepted'] = 'Lỗi SMTP: Dữ liệu không được chấp nhận.'; +$PHPMAILER_LANG['empty_message'] = 'Không có nội dung'; +$PHPMAILER_LANG['encoding'] = 'Mã hóa không xác định: '; +$PHPMAILER_LANG['execute'] = 'Không thực hiện được: '; +$PHPMAILER_LANG['file_access'] = 'Không thể truy cập tệp tin '; +$PHPMAILER_LANG['file_open'] = 'Lỗi Tập tin: Không thể mở tệp tin: '; +$PHPMAILER_LANG['from_failed'] = 'Lỗi địa chỉ gửi đi: '; +$PHPMAILER_LANG['instantiate'] = 'Không dùng được các hàm gửi thư.'; +$PHPMAILER_LANG['invalid_address'] = 'Đại chỉ emai không đúng: '; +$PHPMAILER_LANG['mailer_not_supported'] = ' trình gửi thư không được hỗ trợ.'; +$PHPMAILER_LANG['provide_address'] = 'Bạn phải cung cấp ít nhất một địa chỉ người nhận.'; +$PHPMAILER_LANG['recipients_failed'] = 'Lỗi SMTP: lỗi địa chỉ người nhận: '; +$PHPMAILER_LANG['signing'] = 'Lỗi đăng nhập: '; +$PHPMAILER_LANG['smtp_connect_failed'] = 'Lỗi kết nối với SMTP'; +$PHPMAILER_LANG['smtp_error'] = 'Lỗi máy chủ smtp '; +$PHPMAILER_LANG['variable_set'] = 'Không thể thiết lập hoặc thiết lập lại biến: '; +//$PHPMAILER_LANG['extension_missing'] = 'Extension missing: '; diff --git a/vendor/phpmailer/phpmailer/language/phpmailer.lang-zh.php b/vendor/phpmailer/phpmailer/language/phpmailer.lang-zh.php new file mode 100644 index 0000000..35e4e70 --- /dev/null +++ b/vendor/phpmailer/phpmailer/language/phpmailer.lang-zh.php @@ -0,0 +1,29 @@ + + * @author Peter Dave Hello <@PeterDaveHello/> + * @author Jason Chiang + */ + +$PHPMAILER_LANG['authenticate'] = 'SMTP 錯誤:登入失敗。'; +$PHPMAILER_LANG['connect_host'] = 'SMTP 錯誤:無法連線到 SMTP 主機。'; +$PHPMAILER_LANG['data_not_accepted'] = 'SMTP 錯誤:無法接受的資料。'; +$PHPMAILER_LANG['empty_message'] = '郵件內容為空'; +$PHPMAILER_LANG['encoding'] = '未知編碼: '; +$PHPMAILER_LANG['execute'] = '無法執行:'; +$PHPMAILER_LANG['file_access'] = '無法存取檔案:'; +$PHPMAILER_LANG['file_open'] = '檔案錯誤:無法開啟檔案:'; +$PHPMAILER_LANG['from_failed'] = '發送地址錯誤:'; +$PHPMAILER_LANG['instantiate'] = '未知函數呼叫。'; +$PHPMAILER_LANG['invalid_address'] = '因為電子郵件地址無效,無法傳送: '; +$PHPMAILER_LANG['mailer_not_supported'] = '不支援的發信客戶端。'; +$PHPMAILER_LANG['provide_address'] = '必須提供至少一個收件人地址。'; +$PHPMAILER_LANG['recipients_failed'] = 'SMTP 錯誤:以下收件人地址錯誤:'; +$PHPMAILER_LANG['signing'] = '電子簽章錯誤: '; +$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP 連線失敗'; +$PHPMAILER_LANG['smtp_error'] = 'SMTP 伺服器錯誤: '; +$PHPMAILER_LANG['variable_set'] = '無法設定或重設變數: '; +$PHPMAILER_LANG['extension_missing'] = '遺失模組 Extension: '; diff --git a/vendor/phpmailer/phpmailer/language/phpmailer.lang-zh_cn.php b/vendor/phpmailer/phpmailer/language/phpmailer.lang-zh_cn.php new file mode 100644 index 0000000..728a499 --- /dev/null +++ b/vendor/phpmailer/phpmailer/language/phpmailer.lang-zh_cn.php @@ -0,0 +1,29 @@ + + * @author young + * @author Teddysun + */ + +$PHPMAILER_LANG['authenticate'] = 'SMTP 错误:登录失败。'; +$PHPMAILER_LANG['connect_host'] = 'SMTP 错误:无法连接到 SMTP 主机。'; +$PHPMAILER_LANG['data_not_accepted'] = 'SMTP 错误:数据不被接受。'; +$PHPMAILER_LANG['empty_message'] = '邮件正文为空。'; +$PHPMAILER_LANG['encoding'] = '未知编码:'; +$PHPMAILER_LANG['execute'] = '无法执行:'; +$PHPMAILER_LANG['file_access'] = '无法访问文件:'; +$PHPMAILER_LANG['file_open'] = '文件错误:无法打开文件:'; +$PHPMAILER_LANG['from_failed'] = '发送地址错误:'; +$PHPMAILER_LANG['instantiate'] = '未知函数调用。'; +$PHPMAILER_LANG['invalid_address'] = '发送失败,电子邮箱地址是无效的:'; +$PHPMAILER_LANG['mailer_not_supported'] = '发信客户端不被支持。'; +$PHPMAILER_LANG['provide_address'] = '必须提供至少一个收件人地址。'; +$PHPMAILER_LANG['recipients_failed'] = 'SMTP 错误:收件人地址错误:'; +$PHPMAILER_LANG['signing'] = '登录失败:'; +$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP服务器连接失败。'; +$PHPMAILER_LANG['smtp_error'] = 'SMTP服务器出错:'; +$PHPMAILER_LANG['variable_set'] = '无法设置或重置变量:'; +$PHPMAILER_LANG['extension_missing'] = '丢失模块 Extension:'; diff --git a/vendor/phpmailer/phpmailer/src/Exception.php b/vendor/phpmailer/phpmailer/src/Exception.php new file mode 100644 index 0000000..52eaf95 --- /dev/null +++ b/vendor/phpmailer/phpmailer/src/Exception.php @@ -0,0 +1,40 @@ + + * @author Jim Jagielski (jimjag) + * @author Andy Prevost (codeworxtech) + * @author Brent R. Matzelle (original founder) + * @copyright 2012 - 2020 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 exception handler. + * + * @author Marcus Bointon + */ +class Exception extends \Exception +{ + /** + * Prettify error message output. + * + * @return string + */ + public function errorMessage() + { + return '' . htmlspecialchars($this->getMessage(), ENT_COMPAT | ENT_HTML401) . "
\n"; + } +} diff --git a/vendor/phpmailer/phpmailer/src/OAuth.php b/vendor/phpmailer/phpmailer/src/OAuth.php new file mode 100644 index 0000000..c93d0be --- /dev/null +++ b/vendor/phpmailer/phpmailer/src/OAuth.php @@ -0,0 +1,139 @@ + + * @author Jim Jagielski (jimjag) + * @author Andy Prevost (codeworxtech) + * @author Brent R. Matzelle (original founder) + * @copyright 2012 - 2020 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; + +use League\OAuth2\Client\Grant\RefreshToken; +use League\OAuth2\Client\Provider\AbstractProvider; +use League\OAuth2\Client\Token\AccessToken; + +/** + * OAuth - OAuth2 authentication wrapper class. + * Uses the oauth2-client package from the League of Extraordinary Packages. + * + * @see http://oauth2-client.thephpleague.com + * + * @author Marcus Bointon (Synchro/coolbru) + */ +class OAuth +{ + /** + * An instance of the League OAuth Client Provider. + * + * @var AbstractProvider + */ + protected $provider; + + /** + * The current OAuth access token. + * + * @var AccessToken + */ + protected $oauthToken; + + /** + * The user's email address, usually used as the login ID + * and also the from address when sending email. + * + * @var string + */ + protected $oauthUserEmail = ''; + + /** + * The client secret, generated in the app definition of the service you're connecting to. + * + * @var string + */ + protected $oauthClientSecret = ''; + + /** + * The client ID, generated in the app definition of the service you're connecting to. + * + * @var string + */ + protected $oauthClientId = ''; + + /** + * The refresh token, used to obtain new AccessTokens. + * + * @var string + */ + protected $oauthRefreshToken = ''; + + /** + * OAuth constructor. + * + * @param array $options Associative array containing + * `provider`, `userName`, `clientSecret`, `clientId` and `refreshToken` elements + */ + public function __construct($options) + { + $this->provider = $options['provider']; + $this->oauthUserEmail = $options['userName']; + $this->oauthClientSecret = $options['clientSecret']; + $this->oauthClientId = $options['clientId']; + $this->oauthRefreshToken = $options['refreshToken']; + } + + /** + * Get a new RefreshToken. + * + * @return RefreshToken + */ + protected function getGrant() + { + return new RefreshToken(); + } + + /** + * Get a new AccessToken. + * + * @return AccessToken + */ + protected function getToken() + { + return $this->provider->getAccessToken( + $this->getGrant(), + ['refresh_token' => $this->oauthRefreshToken] + ); + } + + /** + * Generate a base64-encoded OAuth token. + * + * @return string + */ + public function getOauth64() + { + //Get a new token if it's not available or has expired + if (null === $this->oauthToken || $this->oauthToken->hasExpired()) { + $this->oauthToken = $this->getToken(); + } + + return base64_encode( + 'user=' . + $this->oauthUserEmail . + "\001auth=Bearer " . + $this->oauthToken . + "\001\001" + ); + } +} diff --git a/vendor/phpmailer/phpmailer/src/PHPMailer.php b/vendor/phpmailer/phpmailer/src/PHPMailer.php new file mode 100644 index 0000000..5b6dcfa --- /dev/null +++ b/vendor/phpmailer/phpmailer/src/PHPMailer.php @@ -0,0 +1,5029 @@ + + * @author Jim Jagielski (jimjag) + * @author Andy Prevost (codeworxtech) + * @author Brent R. Matzelle (original founder) + * @copyright 2012 - 2020 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 - PHP email creation and transport class. + * + * @author Marcus Bointon (Synchro/coolbru) + * @author Jim Jagielski (jimjag) + * @author Andy Prevost (codeworxtech) + * @author Brent R. Matzelle (original founder) + */ +class PHPMailer +{ + const CHARSET_ASCII = 'us-ascii'; + const CHARSET_ISO88591 = 'iso-8859-1'; + const CHARSET_UTF8 = 'utf-8'; + + const CONTENT_TYPE_PLAINTEXT = 'text/plain'; + const CONTENT_TYPE_TEXT_CALENDAR = 'text/calendar'; + const CONTENT_TYPE_TEXT_HTML = 'text/html'; + const CONTENT_TYPE_MULTIPART_ALTERNATIVE = 'multipart/alternative'; + const CONTENT_TYPE_MULTIPART_MIXED = 'multipart/mixed'; + const CONTENT_TYPE_MULTIPART_RELATED = 'multipart/related'; + + const ENCODING_7BIT = '7bit'; + const ENCODING_8BIT = '8bit'; + const ENCODING_BASE64 = 'base64'; + const ENCODING_BINARY = 'binary'; + const ENCODING_QUOTED_PRINTABLE = 'quoted-printable'; + + const ENCRYPTION_STARTTLS = 'tls'; + const ENCRYPTION_SMTPS = 'ssl'; + + const ICAL_METHOD_REQUEST = 'REQUEST'; + const ICAL_METHOD_PUBLISH = 'PUBLISH'; + const ICAL_METHOD_REPLY = 'REPLY'; + const ICAL_METHOD_ADD = 'ADD'; + const ICAL_METHOD_CANCEL = 'CANCEL'; + const ICAL_METHOD_REFRESH = 'REFRESH'; + const ICAL_METHOD_COUNTER = 'COUNTER'; + const ICAL_METHOD_DECLINECOUNTER = 'DECLINECOUNTER'; + + /** + * Email priority. + * Options: null (default), 1 = High, 3 = Normal, 5 = low. + * When null, the header is not set at all. + * + * @var int|null + */ + public $Priority; + + /** + * The character set of the message. + * + * @var string + */ + public $CharSet = self::CHARSET_ISO88591; + + /** + * The MIME Content-type of the message. + * + * @var string + */ + public $ContentType = self::CONTENT_TYPE_PLAINTEXT; + + /** + * The message encoding. + * Options: "8bit", "7bit", "binary", "base64", and "quoted-printable". + * + * @var string + */ + public $Encoding = self::ENCODING_8BIT; + + /** + * Holds the most recent mailer error message. + * + * @var string + */ + public $ErrorInfo = ''; + + /** + * The From email address for the message. + * + * @var string + */ + public $From = ''; + + /** + * The From name of the message. + * + * @var string + */ + public $FromName = ''; + + /** + * The envelope sender of the message. + * This will usually be turned into a Return-Path header by the receiver, + * and is the address that bounces will be sent to. + * If not empty, will be passed via `-f` to sendmail or as the 'MAIL FROM' value over SMTP. + * + * @var string + */ + public $Sender = ''; + + /** + * The Subject of the message. + * + * @var string + */ + public $Subject = ''; + + /** + * An HTML or plain text message body. + * If HTML then call isHTML(true). + * + * @var string + */ + public $Body = ''; + + /** + * The plain-text message body. + * This body can be read by mail clients that do not have HTML email + * capability such as mutt & Eudora. + * Clients that can read HTML will view the normal Body. + * + * @var string + */ + public $AltBody = ''; + + /** + * An iCal message part body. + * Only supported in simple alt or alt_inline message types + * To generate iCal event structures, use classes like EasyPeasyICS or iCalcreator. + * + * @see http://sprain.ch/blog/downloads/php-class-easypeasyics-create-ical-files-with-php/ + * @see http://kigkonsult.se/iCalcreator/ + * + * @var string + */ + public $Ical = ''; + + /** + * Value-array of "method" in Contenttype header "text/calendar" + * + * @var string[] + */ + protected static $IcalMethods = [ + self::ICAL_METHOD_REQUEST, + self::ICAL_METHOD_PUBLISH, + self::ICAL_METHOD_REPLY, + self::ICAL_METHOD_ADD, + self::ICAL_METHOD_CANCEL, + self::ICAL_METHOD_REFRESH, + self::ICAL_METHOD_COUNTER, + self::ICAL_METHOD_DECLINECOUNTER, + ]; + + /** + * The complete compiled MIME message body. + * + * @var string + */ + protected $MIMEBody = ''; + + /** + * The complete compiled MIME message headers. + * + * @var string + */ + protected $MIMEHeader = ''; + + /** + * Extra headers that createHeader() doesn't fold in. + * + * @var string + */ + protected $mailHeader = ''; + + /** + * Word-wrap the message body to this number of chars. + * Set to 0 to not wrap. A useful value here is 78, for RFC2822 section 2.1.1 compliance. + * + * @see static::STD_LINE_LENGTH + * + * @var int + */ + public $WordWrap = 0; + + /** + * Which method to use to send mail. + * Options: "mail", "sendmail", or "smtp". + * + * @var string + */ + public $Mailer = 'mail'; + + /** + * The path to the sendmail program. + * + * @var string + */ + public $Sendmail = '/usr/sbin/sendmail'; + + /** + * Whether mail() uses a fully sendmail-compatible MTA. + * One which supports sendmail's "-oi -f" options. + * + * @var bool + */ + public $UseSendmailOptions = true; + + /** + * The email address that a reading confirmation should be sent to, also known as read receipt. + * + * @var string + */ + public $ConfirmReadingTo = ''; + + /** + * The hostname to use in the Message-ID header and as default HELO string. + * If empty, PHPMailer attempts to find one with, in order, + * $_SERVER['SERVER_NAME'], gethostname(), php_uname('n'), or the value + * 'localhost.localdomain'. + * + * @see PHPMailer::$Helo + * + * @var string + */ + public $Hostname = ''; + + /** + * An ID to be used in the Message-ID header. + * If empty, a unique id will be generated. + * You can set your own, but it must be in the format "", + * as defined in RFC5322 section 3.6.4 or it will be ignored. + * + * @see https://tools.ietf.org/html/rfc5322#section-3.6.4 + * + * @var string + */ + public $MessageID = ''; + + /** + * The message Date to be used in the Date header. + * If empty, the current date will be added. + * + * @var string + */ + public $MessageDate = ''; + + /** + * SMTP hosts. + * Either a single hostname or multiple semicolon-delimited hostnames. + * You can also specify a different port + * for each host by using this format: [hostname:port] + * (e.g. "smtp1.example.com:25;smtp2.example.com"). + * You can also specify encryption type, for example: + * (e.g. "tls://smtp1.example.com:587;ssl://smtp2.example.com:465"). + * Hosts will be tried in order. + * + * @var string + */ + public $Host = 'localhost'; + + /** + * The default SMTP server port. + * + * @var int + */ + public $Port = 25; + + /** + * The SMTP HELO/EHLO name used for the SMTP connection. + * Default is $Hostname. If $Hostname is empty, PHPMailer attempts to find + * one with the same method described above for $Hostname. + * + * @see PHPMailer::$Hostname + * + * @var string + */ + public $Helo = ''; + + /** + * What kind of encryption to use on the SMTP connection. + * Options: '', static::ENCRYPTION_STARTTLS, or static::ENCRYPTION_SMTPS. + * + * @var string + */ + public $SMTPSecure = ''; + + /** + * Whether to enable TLS encryption automatically if a server supports it, + * even if `SMTPSecure` is not set to 'tls'. + * Be aware that in PHP >= 5.6 this requires that the server's certificates are valid. + * + * @var bool + */ + public $SMTPAutoTLS = true; + + /** + * Whether to use SMTP authentication. + * Uses the Username and Password properties. + * + * @see PHPMailer::$Username + * @see PHPMailer::$Password + * + * @var bool + */ + public $SMTPAuth = false; + + /** + * Options array passed to stream_context_create when connecting via SMTP. + * + * @var array + */ + public $SMTPOptions = []; + + /** + * SMTP username. + * + * @var string + */ + public $Username = ''; + + /** + * SMTP password. + * + * @var string + */ + public $Password = ''; + + /** + * SMTP auth type. + * Options are CRAM-MD5, LOGIN, PLAIN, XOAUTH2, attempted in that order if not specified. + * + * @var string + */ + public $AuthType = ''; + + /** + * An instance of the PHPMailer OAuth class. + * + * @var OAuth + */ + protected $oauth; + + /** + * The SMTP server timeout in seconds. + * Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2. + * + * @var int + */ + public $Timeout = 300; + + /** + * Comma separated list of DSN notifications + * 'NEVER' under no circumstances a DSN must be returned to the sender. + * If you use NEVER all other notifications will be ignored. + * 'SUCCESS' will notify you when your mail has arrived at its destination. + * 'FAILURE' will arrive if an error occurred during delivery. + * 'DELAY' will notify you if there is an unusual delay in delivery, but the actual + * delivery's outcome (success or failure) is not yet decided. + * + * @see https://tools.ietf.org/html/rfc3461 See section 4.1 for more information about NOTIFY + */ + public $dsn = ''; + + /** + * SMTP class debug output mode. + * Debug output level. + * Options: + * @see SMTP::DEBUG_OFF: No output + * @see SMTP::DEBUG_CLIENT: Client messages + * @see SMTP::DEBUG_SERVER: Client and server messages + * @see SMTP::DEBUG_CONNECTION: As SERVER plus connection status + * @see SMTP::DEBUG_LOWLEVEL: Noisy, low-level data output, rarely needed + * + * @see SMTP::$do_debug + * + * @var int + */ + public $SMTPDebug = 0; + + /** + * 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 + * By default PHPMailer will use `echo` if run from a `cli` or `cli-server` SAPI, `html` otherwise. + * Alternatively, you can provide a callable expecting two params: a message string and the debug level: + * + * ```php + * $mail->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; + * ``` + * + * @see SMTP::$Debugoutput + * + * @var string|callable|\Psr\Log\LoggerInterface + */ + public $Debugoutput = 'echo'; + + /** + * Whether to keep the SMTP connection open after each message. + * If this is set to true then the connection will remain open after a send, + * and closing the connection will require an explicit call to smtpClose(). + * It's a good idea to use this if you are sending multiple messages as it reduces overhead. + * See the mailing list example for how to use it. + * + * @var bool + */ + public $SMTPKeepAlive = false; + + /** + * Whether to split multiple to addresses into multiple messages + * or send them all in one message. + * Only supported in `mail` and `sendmail` transports, not in SMTP. + * + * @var bool + * + * @deprecated 6.0.0 PHPMailer isn't a mailing list manager! + */ + public $SingleTo = false; + + /** + * Storage for addresses when SingleTo is enabled. + * + * @var array + */ + protected $SingleToArray = []; + + /** + * Whether to generate VERP addresses on send. + * Only applicable when sending via SMTP. + * + * @see https://en.wikipedia.org/wiki/Variable_envelope_return_path + * @see http://www.postfix.org/VERP_README.html Postfix VERP info + * + * @var bool + */ + public $do_verp = false; + + /** + * Whether to allow sending messages with an empty body. + * + * @var bool + */ + public $AllowEmpty = false; + + /** + * DKIM selector. + * + * @var string + */ + public $DKIM_selector = ''; + + /** + * DKIM Identity. + * Usually the email address used as the source of the email. + * + * @var string + */ + public $DKIM_identity = ''; + + /** + * DKIM passphrase. + * Used if your key is encrypted. + * + * @var string + */ + public $DKIM_passphrase = ''; + + /** + * DKIM signing domain name. + * + * @example 'example.com' + * + * @var string + */ + public $DKIM_domain = ''; + + /** + * DKIM Copy header field values for diagnostic use. + * + * @var bool + */ + public $DKIM_copyHeaderFields = true; + + /** + * DKIM Extra signing headers. + * + * @example ['List-Unsubscribe', 'List-Help'] + * + * @var array + */ + public $DKIM_extraHeaders = []; + + /** + * DKIM private key file path. + * + * @var string + */ + public $DKIM_private = ''; + + /** + * DKIM private key string. + * + * If set, takes precedence over `$DKIM_private`. + * + * @var string + */ + public $DKIM_private_string = ''; + + /** + * Callback Action function name. + * + * The function that handles the result of the send email action. + * It is called out by send() for each email sent. + * + * Value can be any php callable: http://www.php.net/is_callable + * + * Parameters: + * bool $result result of the send action + * array $to email addresses of the recipients + * array $cc cc email addresses + * array $bcc bcc email addresses + * string $subject the subject + * string $body the email body + * string $from email address of sender + * string $extra extra information of possible use + * "smtp_transaction_id' => last smtp transaction id + * + * @var string + */ + public $action_function = ''; + + /** + * What to put in the X-Mailer header. + * Options: An empty string for PHPMailer default, whitespace/null for none, or a string to use. + * + * @var string|null + */ + public $XMailer = ''; + + /** + * Which validator to use by default when validating email addresses. + * May be a callable to inject your own validator, but there are several built-in validators. + * The default validator uses PHP's FILTER_VALIDATE_EMAIL filter_var option. + * + * @see PHPMailer::validateAddress() + * + * @var string|callable + */ + public static $validator = 'php'; + + /** + * An instance of the SMTP sender class. + * + * @var SMTP + */ + protected $smtp; + + /** + * The array of 'to' names and addresses. + * + * @var array + */ + protected $to = []; + + /** + * The array of 'cc' names and addresses. + * + * @var array + */ + protected $cc = []; + + /** + * The array of 'bcc' names and addresses. + * + * @var array + */ + protected $bcc = []; + + /** + * The array of reply-to names and addresses. + * + * @var array + */ + protected $ReplyTo = []; + + /** + * An array of all kinds of addresses. + * Includes all of $to, $cc, $bcc. + * + * @see PHPMailer::$to + * @see PHPMailer::$cc + * @see PHPMailer::$bcc + * + * @var array + */ + protected $all_recipients = []; + + /** + * An array of names and addresses queued for validation. + * In send(), valid and non duplicate entries are moved to $all_recipients + * and one of $to, $cc, or $bcc. + * This array is used only for addresses with IDN. + * + * @see PHPMailer::$to + * @see PHPMailer::$cc + * @see PHPMailer::$bcc + * @see PHPMailer::$all_recipients + * + * @var array + */ + protected $RecipientsQueue = []; + + /** + * An array of reply-to names and addresses queued for validation. + * In send(), valid and non duplicate entries are moved to $ReplyTo. + * This array is used only for addresses with IDN. + * + * @see PHPMailer::$ReplyTo + * + * @var array + */ + protected $ReplyToQueue = []; + + /** + * The array of attachments. + * + * @var array + */ + protected $attachment = []; + + /** + * The array of custom headers. + * + * @var array + */ + protected $CustomHeader = []; + + /** + * The most recent Message-ID (including angular brackets). + * + * @var string + */ + protected $lastMessageID = ''; + + /** + * The message's MIME type. + * + * @var string + */ + protected $message_type = ''; + + /** + * The array of MIME boundary strings. + * + * @var array + */ + protected $boundary = []; + + /** + * The array of available text strings for the current language. + * + * @var array + */ + protected $language = []; + + /** + * The number of errors encountered. + * + * @var int + */ + protected $error_count = 0; + + /** + * The S/MIME certificate file path. + * + * @var string + */ + protected $sign_cert_file = ''; + + /** + * The S/MIME key file path. + * + * @var string + */ + protected $sign_key_file = ''; + + /** + * The optional S/MIME extra certificates ("CA Chain") file path. + * + * @var string + */ + protected $sign_extracerts_file = ''; + + /** + * The S/MIME password for the key. + * Used only if the key is encrypted. + * + * @var string + */ + protected $sign_key_pass = ''; + + /** + * Whether to throw exceptions for errors. + * + * @var bool + */ + protected $exceptions = false; + + /** + * Unique ID used for message ID and boundaries. + * + * @var string + */ + protected $uniqueid = ''; + + /** + * The PHPMailer Version number. + * + * @var string + */ + const VERSION = '6.5.1'; + + /** + * Error severity: message only, continue processing. + * + * @var int + */ + const STOP_MESSAGE = 0; + + /** + * Error severity: message, likely ok to continue processing. + * + * @var int + */ + const STOP_CONTINUE = 1; + + /** + * Error severity: message, plus full stop, critical error reached. + * + * @var int + */ + const STOP_CRITICAL = 2; + + /** + * The SMTP standard CRLF line break. + * If you want to change line break format, change static::$LE, not this. + */ + const CRLF = "\r\n"; + + /** + * "Folding White Space" a white space string used for line folding. + */ + const FWS = ' '; + + /** + * SMTP RFC standard line ending; Carriage Return, Line Feed. + * + * @var string + */ + protected static $LE = self::CRLF; + + /** + * The maximum line length supported by mail(). + * + * Background: mail() will sometimes corrupt messages + * with headers headers longer than 65 chars, see #818. + * + * @var int + */ + const MAIL_MAX_LINE_LENGTH = 63; + + /** + * The maximum line length allowed by RFC 2822 section 2.1.1. + * + * @var int + */ + const MAX_LINE_LENGTH = 998; + + /** + * The lower maximum line length allowed by RFC 2822 section 2.1.1. + * This length does NOT include the line break + * 76 means that lines will be 77 or 78 chars depending on whether + * the line break format is LF or CRLF; both are valid. + * + * @var int + */ + const STD_LINE_LENGTH = 76; + + /** + * Constructor. + * + * @param bool $exceptions Should we throw external exceptions? + */ + public function __construct($exceptions = null) + { + if (null !== $exceptions) { + $this->exceptions = (bool) $exceptions; + } + //Pick an appropriate debug output format automatically + $this->Debugoutput = (strpos(PHP_SAPI, 'cli') !== false ? 'echo' : 'html'); + } + + /** + * Destructor. + */ + public function __destruct() + { + //Close any open SMTP connection nicely + $this->smtpClose(); + } + + /** + * Call mail() in a safe_mode-aware fashion. + * Also, unless sendmail_path points to sendmail (or something that + * claims to be sendmail), don't pass params (not a perfect fix, + * but it will do). + * + * @param string $to To + * @param string $subject Subject + * @param string $body Message Body + * @param string $header Additional Header(s) + * @param string|null $params Params + * + * @return bool + */ + private function mailPassthru($to, $subject, $body, $header, $params) + { + //Check overloading of mail function to avoid double-encoding + if (ini_get('mbstring.func_overload') & 1) { + $subject = $this->secureHeader($subject); + } else { + $subject = $this->encodeHeader($this->secureHeader($subject)); + } + //Calling mail() with null params breaks + $this->edebug('Sending with mail()'); + $this->edebug('Sendmail path: ' . ini_get('sendmail_path')); + $this->edebug("Envelope sender: {$this->Sender}"); + $this->edebug("To: {$to}"); + $this->edebug("Subject: {$subject}"); + $this->edebug("Headers: {$header}"); + if (!$this->UseSendmailOptions || null === $params) { + $result = @mail($to, $subject, $body, $header); + } else { + $this->edebug("Additional params: {$params}"); + $result = @mail($to, $subject, $body, $header, $params); + } + $this->edebug('Result: ' . ($result ? 'true' : 'false')); + return $result; + } + + /** + * Output debugging info via a user-defined method. + * Only generates output if debug output is enabled. + * + * @see PHPMailer::$Debugoutput + * @see PHPMailer::$SMTPDebug + * + * @param string $str + */ + protected function edebug($str) + { + if ($this->SMTPDebug <= 0) { + 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 (is_callable($this->Debugoutput) && !in_array($this->Debugoutput, ['error_log', 'html', 'echo'])) { + call_user_func($this->Debugoutput, $str, $this->SMTPDebug); + + return; + } + switch ($this->Debugoutput) { + case 'error_log': + //Don't output, just log + /** @noinspection ForgottenDebugOutputInspection */ + error_log($str); + break; + case 'html': + //Cleans up output a bit for a better looking, HTML-safe output + echo htmlentities( + preg_replace('/[\r\n]+/', '', $str), + ENT_QUOTES, + 'UTF-8' + ), "
\n"; + break; + case 'echo': + default: + //Normalize line breaks + $str = preg_replace('/\r\n|\r/m', "\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"; + } + } + + /** + * Sets message type to HTML or plain. + * + * @param bool $isHtml True for HTML mode + */ + public function isHTML($isHtml = true) + { + if ($isHtml) { + $this->ContentType = static::CONTENT_TYPE_TEXT_HTML; + } else { + $this->ContentType = static::CONTENT_TYPE_PLAINTEXT; + } + } + + /** + * Send messages using SMTP. + */ + public function isSMTP() + { + $this->Mailer = 'smtp'; + } + + /** + * Send messages using PHP's mail() function. + */ + public function isMail() + { + $this->Mailer = 'mail'; + } + + /** + * Send messages using $Sendmail. + */ + public function isSendmail() + { + $ini_sendmail_path = ini_get('sendmail_path'); + + if (false === stripos($ini_sendmail_path, 'sendmail')) { + $this->Sendmail = '/usr/sbin/sendmail'; + } else { + $this->Sendmail = $ini_sendmail_path; + } + $this->Mailer = 'sendmail'; + } + + /** + * Send messages using qmail. + */ + public function isQmail() + { + $ini_sendmail_path = ini_get('sendmail_path'); + + if (false === stripos($ini_sendmail_path, 'qmail')) { + $this->Sendmail = '/var/qmail/bin/qmail-inject'; + } else { + $this->Sendmail = $ini_sendmail_path; + } + $this->Mailer = 'qmail'; + } + + /** + * Add a "To" address. + * + * @param string $address The email address to send to + * @param string $name + * + * @throws Exception + * + * @return bool true on success, false if address already used or invalid in some way + */ + public function addAddress($address, $name = '') + { + return $this->addOrEnqueueAnAddress('to', $address, $name); + } + + /** + * Add a "CC" address. + * + * @param string $address The email address to send to + * @param string $name + * + * @throws Exception + * + * @return bool true on success, false if address already used or invalid in some way + */ + public function addCC($address, $name = '') + { + return $this->addOrEnqueueAnAddress('cc', $address, $name); + } + + /** + * Add a "BCC" address. + * + * @param string $address The email address to send to + * @param string $name + * + * @throws Exception + * + * @return bool true on success, false if address already used or invalid in some way + */ + public function addBCC($address, $name = '') + { + return $this->addOrEnqueueAnAddress('bcc', $address, $name); + } + + /** + * Add a "Reply-To" address. + * + * @param string $address The email address to reply to + * @param string $name + * + * @throws Exception + * + * @return bool true on success, false if address already used or invalid in some way + */ + public function addReplyTo($address, $name = '') + { + return $this->addOrEnqueueAnAddress('Reply-To', $address, $name); + } + + /** + * Add an address to one of the recipient arrays or to the ReplyTo array. Because PHPMailer + * can't validate addresses with an IDN without knowing the PHPMailer::$CharSet (that can still + * be modified after calling this function), addition of such addresses is delayed until send(). + * Addresses that have been added already return false, but do not throw exceptions. + * + * @param string $kind One of 'to', 'cc', 'bcc', or 'ReplyTo' + * @param string $address The email address to send, resp. to reply to + * @param string $name + * + * @throws Exception + * + * @return bool true on success, false if address already used or invalid in some way + */ + protected function addOrEnqueueAnAddress($kind, $address, $name) + { + $address = trim($address); + $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim + $pos = strrpos($address, '@'); + if (false === $pos) { + //At-sign is missing. + $error_message = sprintf( + '%s (%s): %s', + $this->lang('invalid_address'), + $kind, + $address + ); + $this->setError($error_message); + $this->edebug($error_message); + if ($this->exceptions) { + throw new Exception($error_message); + } + + return false; + } + $params = [$kind, $address, $name]; + //Enqueue addresses with IDN until we know the PHPMailer::$CharSet. + if (static::idnSupported() && $this->has8bitChars(substr($address, ++$pos))) { + if ('Reply-To' !== $kind) { + if (!array_key_exists($address, $this->RecipientsQueue)) { + $this->RecipientsQueue[$address] = $params; + + return true; + } + } elseif (!array_key_exists($address, $this->ReplyToQueue)) { + $this->ReplyToQueue[$address] = $params; + + return true; + } + + return false; + } + + //Immediately add standard addresses without IDN. + return call_user_func_array([$this, 'addAnAddress'], $params); + } + + /** + * Add an address to one of the recipient arrays or to the ReplyTo array. + * Addresses that have been added already return false, but do not throw exceptions. + * + * @param string $kind One of 'to', 'cc', 'bcc', or 'ReplyTo' + * @param string $address The email address to send, resp. to reply to + * @param string $name + * + * @throws Exception + * + * @return bool true on success, false if address already used or invalid in some way + */ + protected function addAnAddress($kind, $address, $name = '') + { + if (!in_array($kind, ['to', 'cc', 'bcc', 'Reply-To'])) { + $error_message = sprintf( + '%s: %s', + $this->lang('Invalid recipient kind'), + $kind + ); + $this->setError($error_message); + $this->edebug($error_message); + if ($this->exceptions) { + throw new Exception($error_message); + } + + return false; + } + if (!static::validateAddress($address)) { + $error_message = sprintf( + '%s (%s): %s', + $this->lang('invalid_address'), + $kind, + $address + ); + $this->setError($error_message); + $this->edebug($error_message); + if ($this->exceptions) { + throw new Exception($error_message); + } + + return false; + } + if ('Reply-To' !== $kind) { + if (!array_key_exists(strtolower($address), $this->all_recipients)) { + $this->{$kind}[] = [$address, $name]; + $this->all_recipients[strtolower($address)] = true; + + return true; + } + } elseif (!array_key_exists(strtolower($address), $this->ReplyTo)) { + $this->ReplyTo[strtolower($address)] = [$address, $name]; + + return true; + } + + return false; + } + + /** + * Parse and validate a string containing one or more RFC822-style comma-separated email addresses + * of the form "display name
" into an array of name/address pairs. + * Uses the imap_rfc822_parse_adrlist function if the IMAP extension is available. + * Note that quotes in the name part are removed. + * + * @see http://www.andrew.cmu.edu/user/agreen1/testing/mrbs/web/Mail/RFC822.php A more careful implementation + * + * @param string $addrstr The address list string + * @param bool $useimap Whether to use the IMAP extension to parse the list + * + * @return array + */ + public static function parseAddresses($addrstr, $useimap = true, $charset = self::CHARSET_ISO88591) + { + $addresses = []; + if ($useimap && function_exists('imap_rfc822_parse_adrlist')) { + //Use this built-in parser if it's available + $list = imap_rfc822_parse_adrlist($addrstr, ''); + // Clear any potential IMAP errors to get rid of notices being thrown at end of script. + imap_errors(); + foreach ($list as $address) { + if ( + '.SYNTAX-ERROR.' !== $address->host && + static::validateAddress($address->mailbox . '@' . $address->host) + ) { + //Decode the name part if it's present and encoded + if ( + property_exists($address, 'personal') && + //Check for a Mbstring constant rather than using extension_loaded, which is sometimes disabled + defined('MB_CASE_UPPER') && + preg_match('/^=\?.*\?=$/s', $address->personal) + ) { + $origCharset = mb_internal_encoding(); + mb_internal_encoding($charset); + //Undo any RFC2047-encoded spaces-as-underscores + $address->personal = str_replace('_', '=20', $address->personal); + //Decode the name + $address->personal = mb_decode_mimeheader($address->personal); + mb_internal_encoding($origCharset); + } + + $addresses[] = [ + 'name' => (property_exists($address, 'personal') ? $address->personal : ''), + 'address' => $address->mailbox . '@' . $address->host, + ]; + } + } + } else { + //Use this simpler parser + $list = explode(',', $addrstr); + foreach ($list as $address) { + $address = trim($address); + //Is there a separate name part? + if (strpos($address, '<') === false) { + //No separate name, just use the whole thing + if (static::validateAddress($address)) { + $addresses[] = [ + 'name' => '', + 'address' => $address, + ]; + } + } else { + list($name, $email) = explode('<', $address); + $email = trim(str_replace('>', '', $email)); + $name = trim($name); + if (static::validateAddress($email)) { + //Check for a Mbstring constant rather than using extension_loaded, which is sometimes disabled + //If this name is encoded, decode it + if (defined('MB_CASE_UPPER') && preg_match('/^=\?.*\?=$/s', $name)) { + $origCharset = mb_internal_encoding(); + mb_internal_encoding($charset); + //Undo any RFC2047-encoded spaces-as-underscores + $name = str_replace('_', '=20', $name); + //Decode the name + $name = mb_decode_mimeheader($name); + mb_internal_encoding($origCharset); + } + $addresses[] = [ + //Remove any surrounding quotes and spaces from the name + 'name' => trim($name, '\'" '), + 'address' => $email, + ]; + } + } + } + } + + return $addresses; + } + + /** + * Set the From and FromName properties. + * + * @param string $address + * @param string $name + * @param bool $auto Whether to also set the Sender address, defaults to true + * + * @throws Exception + * + * @return bool + */ + public function setFrom($address, $name = '', $auto = true) + { + $address = trim($address); + $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim + //Don't validate now addresses with IDN. Will be done in send(). + $pos = strrpos($address, '@'); + if ( + (false === $pos) + || ((!$this->has8bitChars(substr($address, ++$pos)) || !static::idnSupported()) + && !static::validateAddress($address)) + ) { + $error_message = sprintf( + '%s (From): %s', + $this->lang('invalid_address'), + $address + ); + $this->setError($error_message); + $this->edebug($error_message); + if ($this->exceptions) { + throw new Exception($error_message); + } + + return false; + } + $this->From = $address; + $this->FromName = $name; + if ($auto && empty($this->Sender)) { + $this->Sender = $address; + } + + return true; + } + + /** + * Return the Message-ID header of the last email. + * Technically this is the value from the last time the headers were created, + * but it's also the message ID of the last sent message except in + * pathological cases. + * + * @return string + */ + public function getLastMessageID() + { + return $this->lastMessageID; + } + + /** + * Check that a string looks like an email address. + * Validation patterns supported: + * * `auto` Pick best pattern automatically; + * * `pcre8` Use the squiloople.com pattern, requires PCRE > 8.0; + * * `pcre` Use old PCRE implementation; + * * `php` Use PHP built-in FILTER_VALIDATE_EMAIL; + * * `html5` Use the pattern given by the HTML5 spec for 'email' type form input elements. + * * `noregex` Don't use a regex: super fast, really dumb. + * Alternatively you may pass in a callable to inject your own validator, for example: + * + * ```php + * PHPMailer::validateAddress('user@example.com', function($address) { + * return (strpos($address, '@') !== false); + * }); + * ``` + * + * You can also set the PHPMailer::$validator static to a callable, allowing built-in methods to use your validator. + * + * @param string $address The email address to check + * @param string|callable $patternselect Which pattern to use + * + * @return bool + */ + public static function validateAddress($address, $patternselect = null) + { + if (null === $patternselect) { + $patternselect = static::$validator; + } + //Don't allow strings as callables, see SECURITY.md and CVE-2021-3603 + if (is_callable($patternselect) && !is_string($patternselect)) { + return call_user_func($patternselect, $address); + } + //Reject line breaks in addresses; it's valid RFC5322, but not RFC5321 + if (strpos($address, "\n") !== false || strpos($address, "\r") !== false) { + return false; + } + switch ($patternselect) { + case 'pcre': //Kept for BC + case 'pcre8': + /* + * A more complex and more permissive version of the RFC5322 regex on which FILTER_VALIDATE_EMAIL + * is based. + * In addition to the addresses allowed by filter_var, also permits: + * * dotless domains: `a@b` + * * comments: `1234 @ local(blah) .machine .example` + * * quoted elements: `'"test blah"@example.org'` + * * numeric TLDs: `a@b.123` + * * unbracketed IPv4 literals: `a@192.168.0.1` + * * IPv6 literals: 'first.last@[IPv6:a1::]' + * Not all of these will necessarily work for sending! + * + * @see http://squiloople.com/2009/12/20/email-address-validation/ + * @copyright 2009-2010 Michael Rushton + * Feel free to use and redistribute this code. But please keep this copyright notice. + */ + return (bool) preg_match( + '/^(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){255,})(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){65,}@)' . + '((?>(?>(?>((?>(?>(?>\x0D\x0A)?[\t ])+|(?>[\t ]*\x0D\x0A)?[\t ]+)?)(\((?>(?2)' . + '(?>[\x01-\x08\x0B\x0C\x0E-\'*-\[\]-\x7F]|\\\[\x00-\x7F]|(?3)))*(?2)\)))+(?2))|(?2))?)' . + '([!#-\'*+\/-9=?^-~-]+|"(?>(?2)(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\x7F]))*' . + '(?2)")(?>(?1)\.(?1)(?4))*(?1)@(?!(?1)[a-z0-9-]{64,})(?1)(?>([a-z0-9](?>[a-z0-9-]*[a-z0-9])?)' . + '(?>(?1)\.(?!(?1)[a-z0-9-]{64,})(?1)(?5)){0,126}|\[(?:(?>IPv6:(?>([a-f0-9]{1,4})(?>:(?6)){7}' . + '|(?!(?:.*[a-f0-9][:\]]){8,})((?6)(?>:(?6)){0,6})?::(?7)?))|(?>(?>IPv6:(?>(?6)(?>:(?6)){5}:' . + '|(?!(?:.*[a-f0-9]:){6,})(?8)?::(?>((?6)(?>:(?6)){0,4}):)?))?(25[0-5]|2[0-4][0-9]|1[0-9]{2}' . + '|[1-9]?[0-9])(?>\.(?9)){3}))\])(?1)$/isD', + $address + ); + case 'html5': + /* + * This is the pattern used in the HTML5 spec for validation of 'email' type form input elements. + * + * @see https://html.spec.whatwg.org/#e-mail-state-(type=email) + */ + return (bool) preg_match( + '/^[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}' . + '[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/sD', + $address + ); + case 'php': + default: + return filter_var($address, FILTER_VALIDATE_EMAIL) !== false; + } + } + + /** + * Tells whether IDNs (Internationalized Domain Names) are supported or not. This requires the + * `intl` and `mbstring` PHP extensions. + * + * @return bool `true` if required functions for IDN support are present + */ + public static function idnSupported() + { + return function_exists('idn_to_ascii') && function_exists('mb_convert_encoding'); + } + + /** + * Converts IDN in given email address to its ASCII form, also known as punycode, if possible. + * Important: Address must be passed in same encoding as currently set in PHPMailer::$CharSet. + * This function silently returns unmodified address if: + * - No conversion is necessary (i.e. domain name is not an IDN, or is already in ASCII form) + * - Conversion to punycode is impossible (e.g. required PHP functions are not available) + * or fails for any reason (e.g. domain contains characters not allowed in an IDN). + * + * @see PHPMailer::$CharSet + * + * @param string $address The email address to convert + * + * @return string The encoded address in ASCII form + */ + public function punyencodeAddress($address) + { + //Verify we have required functions, CharSet, and at-sign. + $pos = strrpos($address, '@'); + if ( + !empty($this->CharSet) && + false !== $pos && + static::idnSupported() + ) { + $domain = substr($address, ++$pos); + //Verify CharSet string is a valid one, and domain properly encoded in this CharSet. + if ($this->has8bitChars($domain) && @mb_check_encoding($domain, $this->CharSet)) { + //Convert the domain from whatever charset it's in to UTF-8 + $domain = mb_convert_encoding($domain, self::CHARSET_UTF8, $this->CharSet); + //Ignore IDE complaints about this line - method signature changed in PHP 5.4 + $errorcode = 0; + if (defined('INTL_IDNA_VARIANT_UTS46')) { + //Use the current punycode standard (appeared in PHP 7.2) + $punycode = idn_to_ascii($domain, $errorcode, \INTL_IDNA_VARIANT_UTS46); + } elseif (defined('INTL_IDNA_VARIANT_2003')) { + //Fall back to this old, deprecated/removed encoding + $punycode = idn_to_ascii($domain, $errorcode, \INTL_IDNA_VARIANT_2003); + } else { + //Fall back to a default we don't know about + $punycode = idn_to_ascii($domain, $errorcode); + } + if (false !== $punycode) { + return substr($address, 0, $pos) . $punycode; + } + } + } + + return $address; + } + + /** + * Create a message and send it. + * Uses the sending method specified by $Mailer. + * + * @throws Exception + * + * @return bool false on error - See the ErrorInfo property for details of the error + */ + public function send() + { + try { + if (!$this->preSend()) { + return false; + } + + return $this->postSend(); + } catch (Exception $exc) { + $this->mailHeader = ''; + $this->setError($exc->getMessage()); + if ($this->exceptions) { + throw $exc; + } + + return false; + } + } + + /** + * Prepare a message for sending. + * + * @throws Exception + * + * @return bool + */ + public function preSend() + { + if ( + 'smtp' === $this->Mailer + || ('mail' === $this->Mailer && (\PHP_VERSION_ID >= 80000 || stripos(PHP_OS, 'WIN') === 0)) + ) { + //SMTP mandates RFC-compliant line endings + //and it's also used with mail() on Windows + static::setLE(self::CRLF); + } else { + //Maintain backward compatibility with legacy Linux command line mailers + static::setLE(PHP_EOL); + } + //Check for buggy PHP versions that add a header with an incorrect line break + if ( + 'mail' === $this->Mailer + && ((\PHP_VERSION_ID >= 70000 && \PHP_VERSION_ID < 70017) + || (\PHP_VERSION_ID >= 70100 && \PHP_VERSION_ID < 70103)) + && ini_get('mail.add_x_header') === '1' + && stripos(PHP_OS, 'WIN') === 0 + ) { + trigger_error($this->lang('buggy_php'), E_USER_WARNING); + } + + try { + $this->error_count = 0; //Reset errors + $this->mailHeader = ''; + + //Dequeue recipient and Reply-To addresses with IDN + foreach (array_merge($this->RecipientsQueue, $this->ReplyToQueue) as $params) { + $params[1] = $this->punyencodeAddress($params[1]); + call_user_func_array([$this, 'addAnAddress'], $params); + } + if (count($this->to) + count($this->cc) + count($this->bcc) < 1) { + throw new Exception($this->lang('provide_address'), self::STOP_CRITICAL); + } + + //Validate From, Sender, and ConfirmReadingTo addresses + foreach (['From', 'Sender', 'ConfirmReadingTo'] as $address_kind) { + $this->$address_kind = trim($this->$address_kind); + if (empty($this->$address_kind)) { + continue; + } + $this->$address_kind = $this->punyencodeAddress($this->$address_kind); + if (!static::validateAddress($this->$address_kind)) { + $error_message = sprintf( + '%s (%s): %s', + $this->lang('invalid_address'), + $address_kind, + $this->$address_kind + ); + $this->setError($error_message); + $this->edebug($error_message); + if ($this->exceptions) { + throw new Exception($error_message); + } + + return false; + } + } + + //Set whether the message is multipart/alternative + if ($this->alternativeExists()) { + $this->ContentType = static::CONTENT_TYPE_MULTIPART_ALTERNATIVE; + } + + $this->setMessageType(); + //Refuse to send an empty message unless we are specifically allowing it + if (!$this->AllowEmpty && empty($this->Body)) { + throw new Exception($this->lang('empty_message'), self::STOP_CRITICAL); + } + + //Trim subject consistently + $this->Subject = trim($this->Subject); + //Create body before headers in case body makes changes to headers (e.g. altering transfer encoding) + $this->MIMEHeader = ''; + $this->MIMEBody = $this->createBody(); + //createBody may have added some headers, so retain them + $tempheaders = $this->MIMEHeader; + $this->MIMEHeader = $this->createHeader(); + $this->MIMEHeader .= $tempheaders; + + //To capture the complete message when using mail(), create + //an extra header list which createHeader() doesn't fold in + if ('mail' === $this->Mailer) { + if (count($this->to) > 0) { + $this->mailHeader .= $this->addrAppend('To', $this->to); + } else { + $this->mailHeader .= $this->headerLine('To', 'undisclosed-recipients:;'); + } + $this->mailHeader .= $this->headerLine( + 'Subject', + $this->encodeHeader($this->secureHeader($this->Subject)) + ); + } + + //Sign with DKIM if enabled + if ( + !empty($this->DKIM_domain) + && !empty($this->DKIM_selector) + && (!empty($this->DKIM_private_string) + || (!empty($this->DKIM_private) + && static::isPermittedPath($this->DKIM_private) + && file_exists($this->DKIM_private) + ) + ) + ) { + $header_dkim = $this->DKIM_Add( + $this->MIMEHeader . $this->mailHeader, + $this->encodeHeader($this->secureHeader($this->Subject)), + $this->MIMEBody + ); + $this->MIMEHeader = static::stripTrailingWSP($this->MIMEHeader) . static::$LE . + static::normalizeBreaks($header_dkim) . static::$LE; + } + + return true; + } catch (Exception $exc) { + $this->setError($exc->getMessage()); + if ($this->exceptions) { + throw $exc; + } + + return false; + } + } + + /** + * Actually send a message via the selected mechanism. + * + * @throws Exception + * + * @return bool + */ + public function postSend() + { + try { + //Choose the mailer and send through it + switch ($this->Mailer) { + case 'sendmail': + case 'qmail': + return $this->sendmailSend($this->MIMEHeader, $this->MIMEBody); + case 'smtp': + return $this->smtpSend($this->MIMEHeader, $this->MIMEBody); + case 'mail': + return $this->mailSend($this->MIMEHeader, $this->MIMEBody); + default: + $sendMethod = $this->Mailer . 'Send'; + if (method_exists($this, $sendMethod)) { + return $this->$sendMethod($this->MIMEHeader, $this->MIMEBody); + } + + return $this->mailSend($this->MIMEHeader, $this->MIMEBody); + } + } catch (Exception $exc) { + if ($this->Mailer === 'smtp' && $this->SMTPKeepAlive == true) { + $this->smtp->reset(); + } + $this->setError($exc->getMessage()); + $this->edebug($exc->getMessage()); + if ($this->exceptions) { + throw $exc; + } + } + + return false; + } + + /** + * Send mail using the $Sendmail program. + * + * @see PHPMailer::$Sendmail + * + * @param string $header The message headers + * @param string $body The message body + * + * @throws Exception + * + * @return bool + */ + protected function sendmailSend($header, $body) + { + if ($this->Mailer === 'qmail') { + $this->edebug('Sending with qmail'); + } else { + $this->edebug('Sending with sendmail'); + } + $header = static::stripTrailingWSP($header) . static::$LE . static::$LE; + //This sets the SMTP envelope sender which gets turned into a return-path header by the receiver + //A space after `-f` is optional, but there is a long history of its presence + //causing problems, so we don't use one + //Exim docs: http://www.exim.org/exim-html-current/doc/html/spec_html/ch-the_exim_command_line.html + //Sendmail docs: http://www.sendmail.org/~ca/email/man/sendmail.html + //Qmail docs: http://www.qmail.org/man/man8/qmail-inject.html + //Example problem: https://www.drupal.org/node/1057954 + if (empty($this->Sender) && !empty(ini_get('sendmail_from'))) { + //PHP config has a sender address we can use + $this->Sender = ini_get('sendmail_from'); + } + //CVE-2016-10033, CVE-2016-10045: Don't pass -f if characters will be escaped. + if (!empty($this->Sender) && static::validateAddress($this->Sender) && self::isShellSafe($this->Sender)) { + if ($this->Mailer === 'qmail') { + $sendmailFmt = '%s -f%s'; + } else { + $sendmailFmt = '%s -oi -f%s -t'; + } + } else { + //allow sendmail to choose a default envelope sender. It may + //seem preferable to force it to use the From header as with + //SMTP, but that introduces new problems (see + //), and + //it has historically worked this way. + $sendmailFmt = '%s -oi -t'; + } + + $sendmail = sprintf($sendmailFmt, escapeshellcmd($this->Sendmail), $this->Sender); + $this->edebug('Sendmail path: ' . $this->Sendmail); + $this->edebug('Sendmail command: ' . $sendmail); + $this->edebug('Envelope sender: ' . $this->Sender); + $this->edebug("Headers: {$header}"); + + if ($this->SingleTo) { + foreach ($this->SingleToArray as $toAddr) { + $mail = @popen($sendmail, 'w'); + if (!$mail) { + throw new Exception($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL); + } + $this->edebug("To: {$toAddr}"); + fwrite($mail, 'To: ' . $toAddr . "\n"); + fwrite($mail, $header); + fwrite($mail, $body); + $result = pclose($mail); + $addrinfo = static::parseAddresses($toAddr, true, $this->charSet); + $this->doCallback( + ($result === 0), + [[$addrinfo['address'], $addrinfo['name']]], + $this->cc, + $this->bcc, + $this->Subject, + $body, + $this->From, + [] + ); + $this->edebug("Result: " . ($result === 0 ? 'true' : 'false')); + if (0 !== $result) { + throw new Exception($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL); + } + } + } else { + $mail = @popen($sendmail, 'w'); + if (!$mail) { + throw new Exception($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL); + } + fwrite($mail, $header); + fwrite($mail, $body); + $result = pclose($mail); + $this->doCallback( + ($result === 0), + $this->to, + $this->cc, + $this->bcc, + $this->Subject, + $body, + $this->From, + [] + ); + $this->edebug("Result: " . ($result === 0 ? 'true' : 'false')); + if (0 !== $result) { + throw new Exception($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL); + } + } + + return true; + } + + /** + * Fix CVE-2016-10033 and CVE-2016-10045 by disallowing potentially unsafe shell characters. + * Note that escapeshellarg and escapeshellcmd are inadequate for our purposes, especially on Windows. + * + * @see https://github.com/PHPMailer/PHPMailer/issues/924 CVE-2016-10045 bug report + * + * @param string $string The string to be validated + * + * @return bool + */ + protected static function isShellSafe($string) + { + //Future-proof + if ( + escapeshellcmd($string) !== $string + || !in_array(escapeshellarg($string), ["'$string'", "\"$string\""]) + ) { + return false; + } + + $length = strlen($string); + + for ($i = 0; $i < $length; ++$i) { + $c = $string[$i]; + + //All other characters have a special meaning in at least one common shell, including = and +. + //Full stop (.) has a special meaning in cmd.exe, but its impact should be negligible here. + //Note that this does permit non-Latin alphanumeric characters based on the current locale. + if (!ctype_alnum($c) && strpos('@_-.', $c) === false) { + return false; + } + } + + return true; + } + + /** + * Check whether a file path is of a permitted type. + * Used to reject URLs and phar files from functions that access local file paths, + * such as addAttachment. + * + * @param string $path A relative or absolute path to a file + * + * @return bool + */ + protected static function isPermittedPath($path) + { + //Matches scheme definition from https://tools.ietf.org/html/rfc3986#section-3.1 + return !preg_match('#^[a-z][a-z\d+.-]*://#i', $path); + } + + /** + * Check whether a file path is safe, accessible, and readable. + * + * @param string $path A relative or absolute path to a file + * + * @return bool + */ + protected static function fileIsAccessible($path) + { + if (!static::isPermittedPath($path)) { + return false; + } + $readable = file_exists($path); + //If not a UNC path (expected to start with \\), check read permission, see #2069 + if (strpos($path, '\\\\') !== 0) { + $readable = $readable && is_readable($path); + } + return $readable; + } + + /** + * Send mail using the PHP mail() function. + * + * @see http://www.php.net/manual/en/book.mail.php + * + * @param string $header The message headers + * @param string $body The message body + * + * @throws Exception + * + * @return bool + */ + protected function mailSend($header, $body) + { + $header = static::stripTrailingWSP($header) . static::$LE . static::$LE; + + $toArr = []; + foreach ($this->to as $toaddr) { + $toArr[] = $this->addrFormat($toaddr); + } + $to = implode(', ', $toArr); + + $params = null; + //This sets the SMTP envelope sender which gets turned into a return-path header by the receiver + //A space after `-f` is optional, but there is a long history of its presence + //causing problems, so we don't use one + //Exim docs: http://www.exim.org/exim-html-current/doc/html/spec_html/ch-the_exim_command_line.html + //Sendmail docs: http://www.sendmail.org/~ca/email/man/sendmail.html + //Qmail docs: http://www.qmail.org/man/man8/qmail-inject.html + //Example problem: https://www.drupal.org/node/1057954 + //CVE-2016-10033, CVE-2016-10045: Don't pass -f if characters will be escaped. + if (empty($this->Sender) && !empty(ini_get('sendmail_from'))) { + //PHP config has a sender address we can use + $this->Sender = ini_get('sendmail_from'); + } + if (!empty($this->Sender) && static::validateAddress($this->Sender)) { + if (self::isShellSafe($this->Sender)) { + $params = sprintf('-f%s', $this->Sender); + } + $old_from = ini_get('sendmail_from'); + ini_set('sendmail_from', $this->Sender); + } + $result = false; + if ($this->SingleTo && count($toArr) > 1) { + foreach ($toArr as $toAddr) { + $result = $this->mailPassthru($toAddr, $this->Subject, $body, $header, $params); + $addrinfo = static::parseAddresses($toAddr, true, $this->charSet); + $this->doCallback( + $result, + [[$addrinfo['address'], $addrinfo['name']]], + $this->cc, + $this->bcc, + $this->Subject, + $body, + $this->From, + [] + ); + } + } else { + $result = $this->mailPassthru($to, $this->Subject, $body, $header, $params); + $this->doCallback($result, $this->to, $this->cc, $this->bcc, $this->Subject, $body, $this->From, []); + } + if (isset($old_from)) { + ini_set('sendmail_from', $old_from); + } + if (!$result) { + throw new Exception($this->lang('instantiate'), self::STOP_CRITICAL); + } + + return true; + } + + /** + * Get an instance to use for SMTP operations. + * Override this function to load your own SMTP implementation, + * or set one with setSMTPInstance. + * + * @return SMTP + */ + public function getSMTPInstance() + { + if (!is_object($this->smtp)) { + $this->smtp = new SMTP(); + } + + return $this->smtp; + } + + /** + * Provide an instance to use for SMTP operations. + * + * @return SMTP + */ + public function setSMTPInstance(SMTP $smtp) + { + $this->smtp = $smtp; + + return $this->smtp; + } + + /** + * Send mail via SMTP. + * Returns false if there is a bad MAIL FROM, RCPT, or DATA input. + * + * @see PHPMailer::setSMTPInstance() to use a different class. + * + * @uses \PHPMailer\PHPMailer\SMTP + * + * @param string $header The message headers + * @param string $body The message body + * + * @throws Exception + * + * @return bool + */ + protected function smtpSend($header, $body) + { + $header = static::stripTrailingWSP($header) . static::$LE . static::$LE; + $bad_rcpt = []; + if (!$this->smtpConnect($this->SMTPOptions)) { + throw new Exception($this->lang('smtp_connect_failed'), self::STOP_CRITICAL); + } + //Sender already validated in preSend() + if ('' === $this->Sender) { + $smtp_from = $this->From; + } else { + $smtp_from = $this->Sender; + } + if (!$this->smtp->mail($smtp_from)) { + $this->setError($this->lang('from_failed') . $smtp_from . ' : ' . implode(',', $this->smtp->getError())); + throw new Exception($this->ErrorInfo, self::STOP_CRITICAL); + } + + $callbacks = []; + //Attempt to send to all recipients + foreach ([$this->to, $this->cc, $this->bcc] as $togroup) { + foreach ($togroup as $to) { + if (!$this->smtp->recipient($to[0], $this->dsn)) { + $error = $this->smtp->getError(); + $bad_rcpt[] = ['to' => $to[0], 'error' => $error['detail']]; + $isSent = false; + } else { + $isSent = true; + } + + $callbacks[] = ['issent' => $isSent, 'to' => $to[0], 'name' => $to[1]]; + } + } + + //Only send the DATA command if we have viable recipients + if ((count($this->all_recipients) > count($bad_rcpt)) && !$this->smtp->data($header . $body)) { + throw new Exception($this->lang('data_not_accepted'), self::STOP_CRITICAL); + } + + $smtp_transaction_id = $this->smtp->getLastTransactionID(); + + if ($this->SMTPKeepAlive) { + $this->smtp->reset(); + } else { + $this->smtp->quit(); + $this->smtp->close(); + } + + foreach ($callbacks as $cb) { + $this->doCallback( + $cb['issent'], + [[$cb['to'], $cb['name']]], + [], + [], + $this->Subject, + $body, + $this->From, + ['smtp_transaction_id' => $smtp_transaction_id] + ); + } + + //Create error message for any bad addresses + if (count($bad_rcpt) > 0) { + $errstr = ''; + foreach ($bad_rcpt as $bad) { + $errstr .= $bad['to'] . ': ' . $bad['error']; + } + throw new Exception($this->lang('recipients_failed') . $errstr, self::STOP_CONTINUE); + } + + return true; + } + + /** + * Initiate a connection to an SMTP server. + * Returns false if the operation failed. + * + * @param array $options An array of options compatible with stream_context_create() + * + * @throws Exception + * + * @uses \PHPMailer\PHPMailer\SMTP + * + * @return bool + */ + public function smtpConnect($options = null) + { + if (null === $this->smtp) { + $this->smtp = $this->getSMTPInstance(); + } + + //If no options are provided, use whatever is set in the instance + if (null === $options) { + $options = $this->SMTPOptions; + } + + //Already connected? + if ($this->smtp->connected()) { + return true; + } + + $this->smtp->setTimeout($this->Timeout); + $this->smtp->setDebugLevel($this->SMTPDebug); + $this->smtp->setDebugOutput($this->Debugoutput); + $this->smtp->setVerp($this->do_verp); + $hosts = explode(';', $this->Host); + $lastexception = null; + + foreach ($hosts as $hostentry) { + $hostinfo = []; + if ( + !preg_match( + '/^(?:(ssl|tls):\/\/)?(.+?)(?::(\d+))?$/', + trim($hostentry), + $hostinfo + ) + ) { + $this->edebug($this->lang('invalid_hostentry') . ' ' . trim($hostentry)); + //Not a valid host entry + continue; + } + //$hostinfo[1]: optional ssl or tls prefix + //$hostinfo[2]: the hostname + //$hostinfo[3]: optional port number + //The host string prefix can temporarily override the current setting for SMTPSecure + //If it's not specified, the default value is used + + //Check the host name is a valid name or IP address before trying to use it + if (!static::isValidHost($hostinfo[2])) { + $this->edebug($this->lang('invalid_host') . ' ' . $hostinfo[2]); + continue; + } + $prefix = ''; + $secure = $this->SMTPSecure; + $tls = (static::ENCRYPTION_STARTTLS === $this->SMTPSecure); + if ('ssl' === $hostinfo[1] || ('' === $hostinfo[1] && static::ENCRYPTION_SMTPS === $this->SMTPSecure)) { + $prefix = 'ssl://'; + $tls = false; //Can't have SSL and TLS at the same time + $secure = static::ENCRYPTION_SMTPS; + } elseif ('tls' === $hostinfo[1]) { + $tls = true; + //TLS doesn't use a prefix + $secure = static::ENCRYPTION_STARTTLS; + } + //Do we need the OpenSSL extension? + $sslext = defined('OPENSSL_ALGO_SHA256'); + if (static::ENCRYPTION_STARTTLS === $secure || static::ENCRYPTION_SMTPS === $secure) { + //Check for an OpenSSL constant rather than using extension_loaded, which is sometimes disabled + if (!$sslext) { + throw new Exception($this->lang('extension_missing') . 'openssl', self::STOP_CRITICAL); + } + } + $host = $hostinfo[2]; + $port = $this->Port; + if ( + array_key_exists(3, $hostinfo) && + is_numeric($hostinfo[3]) && + $hostinfo[3] > 0 && + $hostinfo[3] < 65536 + ) { + $port = (int) $hostinfo[3]; + } + if ($this->smtp->connect($prefix . $host, $port, $this->Timeout, $options)) { + try { + if ($this->Helo) { + $hello = $this->Helo; + } else { + $hello = $this->serverHostname(); + } + $this->smtp->hello($hello); + //Automatically enable TLS encryption if: + //* it's not disabled + //* we have openssl extension + //* we are not already using SSL + //* the server offers STARTTLS + if ($this->SMTPAutoTLS && $sslext && 'ssl' !== $secure && $this->smtp->getServerExt('STARTTLS')) { + $tls = true; + } + if ($tls) { + if (!$this->smtp->startTLS()) { + throw new Exception($this->lang('connect_host')); + } + //We must resend EHLO after TLS negotiation + $this->smtp->hello($hello); + } + if ( + $this->SMTPAuth && !$this->smtp->authenticate( + $this->Username, + $this->Password, + $this->AuthType, + $this->oauth + ) + ) { + throw new Exception($this->lang('authenticate')); + } + + return true; + } catch (Exception $exc) { + $lastexception = $exc; + $this->edebug($exc->getMessage()); + //We must have connected, but then failed TLS or Auth, so close connection nicely + $this->smtp->quit(); + } + } + } + //If we get here, all connection attempts have failed, so close connection hard + $this->smtp->close(); + //As we've caught all exceptions, just report whatever the last one was + if ($this->exceptions && null !== $lastexception) { + throw $lastexception; + } + + return false; + } + + /** + * Close the active SMTP session if one exists. + */ + public function smtpClose() + { + if ((null !== $this->smtp) && $this->smtp->connected()) { + $this->smtp->quit(); + $this->smtp->close(); + } + } + + /** + * Set the language for error messages. + * The default language is English. + * + * @param string $langcode ISO 639-1 2-character language code (e.g. French is "fr") + * Optionally, the language code can be enhanced with a 4-character + * script annotation and/or a 2-character country annotation. + * @param string $lang_path Path to the language file directory, with trailing separator (slash).D + * Do not set this from user input! + * + * @return bool Returns true if the requested language was loaded, false otherwise. + */ + public function setLanguage($langcode = 'en', $lang_path = '') + { + //Backwards compatibility for renamed language codes + $renamed_langcodes = [ + 'br' => 'pt_br', + 'cz' => 'cs', + 'dk' => 'da', + 'no' => 'nb', + 'se' => 'sv', + 'rs' => 'sr', + 'tg' => 'tl', + 'am' => 'hy', + ]; + + if (array_key_exists($langcode, $renamed_langcodes)) { + $langcode = $renamed_langcodes[$langcode]; + } + + //Define full set of translatable strings in English + $PHPMAILER_LANG = [ + 'authenticate' => 'SMTP Error: Could not authenticate.', + 'buggy_php' => 'Your version of PHP is affected by a bug that may result in corrupted messages.' . + ' To fix it, switch to sending using SMTP, disable the mail.add_x_header option in' . + ' your php.ini, switch to MacOS or Linux, or upgrade your PHP to version 7.0.17+ or 7.1.3+.', + 'connect_host' => 'SMTP Error: Could not connect to SMTP host.', + 'data_not_accepted' => 'SMTP Error: data not accepted.', + 'empty_message' => 'Message body empty', + 'encoding' => 'Unknown encoding: ', + 'execute' => 'Could not execute: ', + 'extension_missing' => 'Extension missing: ', + 'file_access' => 'Could not access file: ', + 'file_open' => 'File Error: Could not open file: ', + 'from_failed' => 'The following From address failed: ', + 'instantiate' => 'Could not instantiate mail function.', + 'invalid_address' => 'Invalid address: ', + 'invalid_header' => 'Invalid header name or value', + 'invalid_hostentry' => 'Invalid hostentry: ', + 'invalid_host' => 'Invalid host: ', + 'mailer_not_supported' => ' mailer is not supported.', + 'provide_address' => 'You must provide at least one recipient email address.', + 'recipients_failed' => 'SMTP Error: The following recipients failed: ', + 'signing' => 'Signing Error: ', + 'smtp_code' => 'SMTP code: ', + 'smtp_code_ex' => 'Additional SMTP info: ', + 'smtp_connect_failed' => 'SMTP connect() failed.', + 'smtp_detail' => 'Detail: ', + 'smtp_error' => 'SMTP server error: ', + 'variable_set' => 'Cannot set or reset variable: ', + ]; + if (empty($lang_path)) { + //Calculate an absolute path so it can work if CWD is not here + $lang_path = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'language' . DIRECTORY_SEPARATOR; + } + + //Validate $langcode + $foundlang = true; + $langcode = strtolower($langcode); + if ( + !preg_match('/^(?P[a-z]{2})(?P + + +For security reasons, Tracy is visible only on localhost. Look into the source code to see how to enable Tracy.

'; +} diff --git a/vendor/tracy/tracy/examples/ajax-jquery.php b/vendor/tracy/tracy/examples/ajax-jquery.php new file mode 100644 index 0000000..9703175 --- /dev/null +++ b/vendor/tracy/tracy/examples/ajax-jquery.php @@ -0,0 +1,82 @@ + + + +

Tracy: AJAX demo

+ +

+ see Debug Bar in the bottom right corner +

+ +

+ use ESC to toggle BlueScreen +

+ + + + + + +For security reasons, Tracy is visible only on localhost. Look into the source code to see how to enable Tracy.

'; +} diff --git a/vendor/tracy/tracy/examples/assets/E_COMPILE_ERROR.php b/vendor/tracy/tracy/examples/assets/E_COMPILE_ERROR.php new file mode 100644 index 0000000..f78d3bd --- /dev/null +++ b/vendor/tracy/tracy/examples/assets/E_COMPILE_ERROR.php @@ -0,0 +1,5 @@ + + + +

Tracy: bar dump demo

+ +

You can dump variables to bar in rightmost bottom egde.

+ +test', 'String'); + + +if (Debugger::$productionMode) { + echo '

For security reasons, Tracy is visible only on localhost. Look into the source code to see how to enable Tracy.

'; +} diff --git a/vendor/tracy/tracy/examples/dump-snapshot.php b/vendor/tracy/tracy/examples/dump-snapshot.php new file mode 100644 index 0000000..617142d --- /dev/null +++ b/vendor/tracy/tracy/examples/dump-snapshot.php @@ -0,0 +1,56 @@ + + + +

Tracy: Dumper with common snapshot demo

+ +
+ &$snapshot]); +echo Dumper::toHtml($obj, [Dumper::SNAPSHOT => &$snapshot]); + + + +// changed array is detected +$arr[0] = 'CHANGED!'; +echo Dumper::toHtml($arr, [Dumper::SNAPSHOT => &$snapshot]); + + +// changed object is not detected, because is part of snapshot +$obj->x = 'CHANGED!'; +echo Dumper::toHtml($obj, [Dumper::SNAPSHOT => &$snapshot]); + + +// prints snapshot +echo ''; +echo '
'; + +if (Debugger::$productionMode) { + echo '

For security reasons, Tracy is visible only on localhost. Look into the source code to see how to enable Tracy.

'; +} diff --git a/vendor/tracy/tracy/examples/dump.php b/vendor/tracy/tracy/examples/dump.php new file mode 100644 index 0000000..8672022 --- /dev/null +++ b/vendor/tracy/tracy/examples/dump.php @@ -0,0 +1,99 @@ + + + +

Tracy: dump() demo

+ +Basic Types\n"; + +dump('any string', 123, [true, false, null]); + + + +echo "

Dark Mode

\n"; + +Debugger::$dumpTheme = 'dark'; + +dump('any string'); + + + +echo "

Objects

\n"; +echo "

Hover over the name \$baz to see property declaring class and over the hash #5 to see same objects.

\n"; + +class ParentClass +{ + public $foo = [10, 20]; + + protected $bar = 30; + + private $baz = 'parent'; +} + +class ChildClass extends ParentClass +{ + private $baz = 'child'; +} + + +$obj = new ChildClass; +$obj->dynamic = 'hello'; +$obj->selfReference = $obj; + +dump($obj); + + + +echo "

Strings

\n"; +echo "

Hover over the string to see length.

\n"; + +$arr = [ + 'single line' => 'hello', + 'binary' => "binary\xA0string", + 'multi line' => "first\r\nsecond\nthird\n indented line", + 'long' => str_repeat('tracy ', 1000), // affected by Tracy\Debugger::$maxLength +]; + +dump($arr); + + +echo "

References and Recursion

\n"; +echo "

Hover over the reference &1 to see referenced values.

\n"; + +$arr = ['first', 'second', 'third']; +$arr[] = &$arr[0]; +$arr[] = &$arr[1]; +$arr[] = &$arr; + +dump($arr); + + +echo "

Special Types

\n"; + +$arr = [ + fopen(__FILE__, 'r'), + new class {}, + function ($x, $y) use (&$arr, $obj) {}, +]; + +dump($arr); + + + +if (Debugger::$productionMode) { + echo '

For security reasons, Tracy is visible only on localhost. Look into the source code to see how to enable Tracy.

'; +} diff --git a/vendor/tracy/tracy/examples/exception.php b/vendor/tracy/tracy/examples/exception.php new file mode 100644 index 0000000..3accca0 --- /dev/null +++ b/vendor/tracy/tracy/examples/exception.php @@ -0,0 +1,52 @@ + + + +

Tracy: exception demo

+ +second(true, false); + } + + + public function second($arg1, $arg2) + { + self::third([1, 2, 3]); + } + + + public static function third($arg1) + { + throw new Exception('The my exception', 123); + } +} + + +function demo($a, $b) +{ + $demo = new DemoClass; + $demo->first($a, $b); +} + + +if (Debugger::$productionMode) { + echo '

For security reasons, Tracy is visible only on localhost. Look into the source code to see how to enable Tracy.

'; +} + +demo(10, 'any string'); diff --git a/vendor/tracy/tracy/examples/fatal-error.php b/vendor/tracy/tracy/examples/fatal-error.php new file mode 100644 index 0000000..391d471 --- /dev/null +++ b/vendor/tracy/tracy/examples/fatal-error.php @@ -0,0 +1,24 @@ + + + +

Tracy: fatal error demo

+ +For security reasons, Tracy is visible only on localhost. Look into the source code to see how to enable Tracy.

'; +} + +require __DIR__ . '/assets/E_COMPILE_ERROR.php'; diff --git a/vendor/tracy/tracy/examples/firelogger.php b/vendor/tracy/tracy/examples/firelogger.php new file mode 100644 index 0000000..b3e2009 --- /dev/null +++ b/vendor/tracy/tracy/examples/firelogger.php @@ -0,0 +1,45 @@ + 'val1', 'key2' => true]]; + +// will show in FireLogger +Debugger::fireLog('Hello World'); +Debugger::fireLog($arr); + + +function first($arg1, $arg2) +{ + second(true, false); +} + + +function second($arg1, $arg2) +{ + third([1, 2, 3]); +} + + +function third($arg1) +{ + throw new Exception('The my exception', 123); +} + + +try { + first(10, 'any string'); +} catch (Exception $e) { + Debugger::fireLog($e); +} + +?> + + +

Tracy: FireLogger demo

+ +

How to enable FireLogger?

diff --git a/vendor/tracy/tracy/examples/notice.php b/vendor/tracy/tracy/examples/notice.php new file mode 100644 index 0000000..ff67554 --- /dev/null +++ b/vendor/tracy/tracy/examples/notice.php @@ -0,0 +1,33 @@ + + + +

Tracy Notice and StrictMode demo

+ +For security reasons, Tracy is visible only on localhost. Look into the source code to see how to enable Tracy.

'; +} diff --git a/vendor/tracy/tracy/examples/output-debugger.php b/vendor/tracy/tracy/examples/output-debugger.php new file mode 100644 index 0000000..bfd79f4 --- /dev/null +++ b/vendor/tracy/tracy/examples/output-debugger.php @@ -0,0 +1,17 @@ +'; +} + + +head(); +echo '

Output Debugger demo

'; diff --git a/vendor/tracy/tracy/examples/preloading.php b/vendor/tracy/tracy/examples/preloading.php new file mode 100644 index 0000000..154918c --- /dev/null +++ b/vendor/tracy/tracy/examples/preloading.php @@ -0,0 +1,37 @@ + + + +

Tracy: Preloading

+ + + + + + +For security reasons, Tracy is visible only on localhost. Look into the source code to see how to enable Tracy.

'; +} diff --git a/vendor/tracy/tracy/examples/redirect.php b/vendor/tracy/tracy/examples/redirect.php new file mode 100644 index 0000000..4ec6b6c --- /dev/null +++ b/vendor/tracy/tracy/examples/redirect.php @@ -0,0 +1,36 @@ + + + +

Tracy: redirect demo

+ +

redirect again or redirect to AJAX demo

+ +For security reasons, Tracy is visible only on localhost. Look into the source code to see how to enable Tracy.

'; +} diff --git a/vendor/tracy/tracy/examples/warning.php b/vendor/tracy/tracy/examples/warning.php new file mode 100644 index 0000000..98f2e5e --- /dev/null +++ b/vendor/tracy/tracy/examples/warning.php @@ -0,0 +1,26 @@ + + + +

Tracy Warning and StrictMode demo

+ +For security reasons, Tracy is visible only on localhost. Look into the source code to see how to enable Tracy.

'; +} diff --git a/vendor/tracy/tracy/license.md b/vendor/tracy/tracy/license.md new file mode 100644 index 0000000..5a56617 --- /dev/null +++ b/vendor/tracy/tracy/license.md @@ -0,0 +1,55 @@ +Licenses +======== + +Good news! You may use Tracy under the terms of either the New BSD License +or the GNU General Public License (GPL) version 2 or 3. + +The BSD License is recommended for most projects. It is easy to understand and it +places almost no restrictions on what you can do with the framework. If the GPL +fits better to your project, you can use the framework under this license. + +You don't have to notify anyone which license you are using. You can freely +use Tracy in commercial projects as long as the copyright header +remains intact. + + +New BSD License +--------------- + +Copyright (c) 2004, 2014 David Grudl (https://davidgrudl.com) +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + * Neither the name of "Tracy" nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +This software is provided by the copyright holders and contributors "as is" and +any express or implied warranties, including, but not limited to, the implied +warranties of merchantability and fitness for a particular purpose are +disclaimed. In no event shall the copyright owner or contributors be liable for +any direct, indirect, incidental, special, exemplary, or consequential damages +(including, but not limited to, procurement of substitute goods or services; +loss of use, data, or profits; or business interruption) however caused and on +any theory of liability, whether in contract, strict liability, or tort +(including negligence or otherwise) arising in any way out of the use of this +software, even if advised of the possibility of such damage. + + +GNU General Public License +-------------------------- + +GPL licenses are very very long, so instead of including them here we offer +you URLs with full text: + +- [GPL version 2](http://www.gnu.org/licenses/gpl-2.0.html) +- [GPL version 3](http://www.gnu.org/licenses/gpl-3.0.html) diff --git a/vendor/tracy/tracy/readme.md b/vendor/tracy/tracy/readme.md new file mode 100644 index 0000000..4abdd18 --- /dev/null +++ b/vendor/tracy/tracy/readme.md @@ -0,0 +1,425 @@ +[Tracy](https://tracy.nette.org) - PHP debugger +============================================== + +[![Downloads this Month](https://img.shields.io/packagist/dm/tracy/tracy.svg)](https://packagist.org/packages/tracy/tracy) +[![Tests](https://github.com/nette/tracy/workflows/Tests/badge.svg?branch=master)](https://github.com/nette/tracy/actions) +[![Build Status Windows](https://ci.appveyor.com/api/projects/status/github/nette/tracy?branch=master&svg=true)](https://ci.appveyor.com/project/dg/tracy/branch/master) +[![Latest Stable Version](https://poser.pugx.org/tracy/tracy/v/stable)](https://github.com/nette/tracy/releases) +[![License](https://img.shields.io/badge/license-New%20BSD-blue.svg)](https://github.com/nette/tracy/blob/master/license.md) + + +Introduction +------------ + +Tracy library is a useful helper for everyday PHP programmers. It helps you to: + +- quickly detect and correct errors +- log errors +- dump variables +- measure execution time of scripts/queries +- see memory consumption + + +PHP is a perfect language for making hardly detectable errors because it gives great flexibility to programmers. Tracy\Debugger is more valuable because of that. It is an ultimate tool among the diagnostic ones. +If you are meeting Tracy for the first time, believe me, your life starts to be divided into one before the Tracy and the one with her. Welcome to the good part! + +Documentation can be found on the [website](https://tracy.nette.org). + + +[Support Tracy](https://github.com/sponsors/dg) +----------------------------------------------- + +Do you like Tracy? Are you looking forward to the new features? + +[![Buy me a coffee](https://files.nette.org/icons/donation-3.svg)](https://github.com/sponsors/dg) + +Thank you! + + +Installation and requirements +----------------------------- + +The recommended way to is via Composer: + +```shell +composer require tracy/tracy +``` + +Alternatively, you can download the whole package or [tracy.phar](https://github.com/nette/tracy/releases) file. + +| Tracy | compatible with PHP | compatible with browsers +|-----------|---------------|---------- +| Tracy 2.8 | PHP 7.2 – 8.1 | Chrome 55+, Firefox 53+, Safari 11+ and iOS Safari 11+ +| Tracy 2.7 | PHP 7.1 – 8.0 | Chrome 55+, Firefox 53+, MS Edge 16+, Safari 11+ and iOS Safari 11+ +| Tracy 2.6 | PHP 7.1 – 8.0 | Chrome 49+, Firefox 45+, MS Edge 14+, Safari 10+ and iOS Safari 10.2+ +| Tracy 2.5 | PHP 5.4 – 7.4 | Chrome 49+, Firefox 45+, MS Edge 12+, Safari 10+ and iOS Safari 10.2+ +| Tracy 2.4 | PHP 5.4 – 7.2 | Chrome 29+, Firefox 28+, IE 11+ (except AJAX), MS Edge 12+, Safari 9+ and iOS Safari 9.2+ + + +Usage +----- + +Activating Tracy is easy. Simply add these two lines of code, preferably just after library loading (like `require 'vendor/autoload.php'`) and before any output is sent to browser: + +```php +use Tracy\Debugger; + +Debugger::enable(); +``` + +The first thing you will notice on the website is a Debugger Bar. + +(If you do not see anything, it means that Tracy is running in production mode. For security reasons, Tracy is visible only on localhost. +You may force Tracy to run in development mode by passing the `Debugger::DEVELOPMENT` as the first parameter of `enable()` method.) + +The `enable()` involves changing the error reporting level to E_ALL. + + +Debugger Bar +------------ + +The Debugger Bar is a floating panel. It is displayed in the bottom right corner of a page. You can move it using the mouse. It will remember its position after the page reloading. + +[![Debugger-Bar](https://nette.github.io/tracy/images/tracy-bar.png)](https://nette.github.io/tracy/tracy-debug-bar.html) + +You can add other useful panels to the Debugger Bar. You can find interesting ones in [addons](https://componette.org) or you can [create your own](https://tracy.nette.org/en/extensions). + +If you do not want to show Debugger Bar, set: + +```php +Debugger::$showBar = false; +``` + + +Visualization of errors and exceptions +-------------------------------------- + +Surely, you know how PHP reports errors: there is something like this in the page source code: + +```pre +Parse error: syntax error, unexpected '}' in HomepagePresenter.php on line 15 +``` + +or uncaught exception: + +```pre +Fatal error: Uncaught Nette\MemberAccessException: Call to undefined method Nette\Application\UI\Form::addTest()? in /sandbox/vendor/nette/utils/src/Utils/ObjectMixin.php:100 +Stack trace: +#0 /sandbox/vendor/nette/utils/src/Utils/Object.php(75): Nette\Utils\ObjectMixin::call(Object(Nette\Application\UI\Form), 'addTest', Array) +#1 /sandbox/app/forms/SignFormFactory.php(32): Nette\Object->__call('addTest', Array) +#2 /sandbox/app/presenters/SignPresenter.php(21): App\Forms\SignFormFactory->create() +#3 /sandbox/vendor/nette/component-model/src/ComponentModel/Container.php(181): App\Presenters\SignPresenter->createComponentSignInForm('signInForm') +#4 /sandbox/vendor/nette/component-model/src/ComponentModel/Container.php(139): Nette\ComponentModel\Container->createComponent('signInForm') +#5 /sandbox/temp/cache/latte/15206b353f351f6bfca2c36cc.php(17): Nette\ComponentModel\Co in /sandbox/vendor/nette/utils/src/Utils/ObjectMixin.php on line 100
+``` + +It is not so easy to navigate through this output. If you enable Tracy, both errors and exceptions are displayed in a completely different form: + +[![Uncaught exception rendered by Tracy](https://nette.github.io/tracy/images/tracy-exception.png)](https://nette.github.io/tracy/tracy-exception.html) + +The error message literally screams. You can see a part of the source code with the highlighted line where the error occurred. A message clearly explains an error. The entire site is [interactive, try it](https://nette.github.io/tracy/tracy-exception.html). + +And you know what? Fatal errors are captured and displayed in the same way. No need to install any extension (click for live example): + +[![Fatal error rendered by Tracy](https://nette.github.io/tracy/images/tracy-error.png)](https://nette.github.io/tracy/tracy-error.html) + +Errors like a typo in a variable name or an attempt to open a nonexistent file generate reports of E_NOTICE or E_WARNING level. These can be easily overlooked and/or can be completely hidden in a web page graphic layout. Let Tracy manage them: + +[![Notice rendered by Tracy](https://nette.github.io/tracy/images/tracy-notice2.png)](https://nette.github.io/tracy/tracy-debug-bar.html) + +Or they may be displayed like errors: + +```php +Debugger::$strictMode = true; // display all errors +Debugger::$strictMode = E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED; // all errors except deprecated notices +``` + +[![Notice rendered by Tracy](https://nette.github.io/tracy/images/tracy-notice.png)](https://nette.github.io/tracy/tracy-notice.html) + +In order to detect misspellings when assigning to an object, we use [trait Nette\SmartObject](https://doc.nette.org/en/3.0/smartobject). + + +Content Security Policy +----------------------- + +If your site uses Content Security Policy, you'll need to add `'nonce-'` to `script-src` and eventually the same nonce to `style-src` for Tracy to work properly. Some 3rd plugins may require additional directives. Avoid adding `'unsafe-inline'` & `'unsafe-eval'` in production mode, if you can. + +Configuration example for [Nette Framework](https://nette.org): + +```neon +http: + csp: + script-src: nonce + style-src: nonce +``` + + +Faster loading +-------------- + +The basic integration is straightforward, however if you have slow blocking scripts in web page, they can slow the Tracy loading. +The solution is to place `` into your template before +any scripts: + +```html + + + + ...<title> + <?php Tracy\Debugger::renderLoader() ?> + <link rel="stylesheet" href="assets/style.css"> + <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script> +</head> +``` + + +AJAX and redirected requests +---------------------------- + +Tracy is able to show Debug bar and Bluescreens for AJAX and redirected requests. You just have to start session before Tracy: + +```php +session_start(); +Debugger::enable(); +``` + +In case you use non-standard session handler, you can start Tracy immediately (in order to handle any errors), then initialize your session handler +and then inform Tracy that session is ready to use via `dispatch()`: + +```php +Debugger::enable(); + +// initialize session handler +session_start(); + +Debugger::dispatch(); +``` + + +Opening files in the editor +--------------------------- + +When the error page is displayed, you can click on file names and they will open in your editor with the cursor on the corresponding line. Files can also be created (action `create file`) or bug fixed in them (action `fix it`). In order to do this, you need to [configure the browser and the system](https://tracy.nette.org/cs/open-files-in-ide). + + +Production mode and error logging +--------------------------------- + +As you can see, Tracy is quite eloquent. It is appreciated in a development environment, but on a production server, it would cause a disaster. Any debugging information cannot be listed there. Therefore Tracy has an environment autodetection and logging functionality. Instead of showing herself, Tracy stores information into a log file and shows the visitor a user-comprehensible server error message: + +[![Server Error 500](https://nette.github.io/tracy/images/tracy-error2.png)](https://nette.github.io/tracy/tracy-production.html) + +Production output mode suppresses all debugging information which is sent out via `dump()` or `Debugger::fireLog()`, and of course all error messages generated by PHP. So, even if you forget `dump($obj)` in the source code, you do not have to worry about it on your production server. Nothing will be seen. + +The output mode is set by the first parameter of `Debugger::enable()`. You can specify either a constant `Debugger::PRODUCTION` or `Debugger::DEVELOPMENT`. Other option is to set it up in a way, that development mode will be on when the application is accessed from a defined IP address with a defined value of `tracy-debug` cookie. The syntax used to achieve this is `cookie-value@ip-address`. + +If it is not specified, the default value `Debugger::DETECT` is used. In this case, the system detects a server by IP address. The production mode is chosen if an application is accessed via a public IP address. A local IP address leads to development mode. It is not necessary to set the mode in most cases. The mode is correctly recognized when you are launching the application on your local server or in production. + +In the production mode, Tracy automatically captures all errors and exceptions into a text log. Unless you specify otherwise, it will be stored in log/error.log. This error logging is extremely useful. Imagine, that all users of your application are actually betatesters. They are doing cutting-edge work for free when hunting bugs and you would be silly if you threw away their valuable reports to a recycle bin unnoticed. + +If you need to log your own messages or caught exceptions, use the method `log()`: + +```php +Debugger::log('Unexpected error'); // text message + +try { + criticalOperation(); +} catch (Exception $e) { + Debugger::log($e); // log exception + // or + Debugger::log($e, Debugger::ERROR); // also sends an email notification +} +``` + +A directory for errors logging can be set by the second parameter of the enable() method: + +```php +Debugger::enable(Debugger::DETECT, __DIR__ . '/mylog'); +``` + +If you want Tracy to log PHP errors like `E_NOTICE` or `E_WARNING` with detailed information (HTML report), set `Debugger::$logSeverity`: + +```php +Debugger::$logSeverity = E_NOTICE | E_WARNING; +``` + +For a real professional the error log is a crucial source of information and he or she wants to be notified about any new error immediately. Tracy helps him. She is capable of sending an email for every new error record. The variable $email identifies where to send these e-mails: + +```php +Debugger::$email = 'admin@example.com'; +``` + +If you use the Nette Framework, you can set this and others in the configuration file. + +To protect your e-mail box from flood, Tracy sends **only one message** and creates a file `email-sent`. When a developer receives the e-mail notification, he checks the log, corrects his application and deletes the `email-sent` monitoring file. This activates the e-mail sending again. + + +Variable dumping +---------------- + +Every debugging developer is a good friend with the function `var_dump`, which lists all contents of any variable in detail. Unfortunately, its output is without HTML formatting and outputs the dump into a single line of HTML code, not to mention context escaping. It is necessary to replace the `var_dump` with a more handy function. That is just what `dump()` is. + +```php +$arr = [10, 20.2, true, null, 'hello']; + +dump($arr); +// or Tracy\Debugger::dump($arr); +``` + +generates the output: + +![dump](https://nette.github.io/tracy/images/tracy-dump.png) + +You can also change the nesting depth by `Debugger::$maxDepth` and displayed strings length by `Debugger::$maxLength`. Naturally, lower values accelerate Tracy rendering. + +```php +Debugger::$maxDepth = 2; // default: 7 +Debugger::$maxLength = 50; // default: 150 +Debugger::$dumpTheme = 'dark'; // default: light +``` + +The `dump()` function can display useful location information: + +```php +Debugger::$showLocation = true; // shows tooltip with path to the file, where the dump() was called, and tooltips for every dumped objects +Debugger::$showLocation = Tracy\Dumper::LOCATION_CLASS; // shows only tooltips for every dumped object containing path to the file +Debugger::$showLocation = false; // hides all location information +``` + +Very handy alternative to `dump()` is `dumpe()` (ie. dump and exit) and `bdump()`. This allows us to dump variables in Debugger Bar. This is useful, because dumps don't mess up the output and we can also add a title to the dump. + +```php +bdump([2, 4, 6, 8], 'even numbers up to ten'); +bdump([1, 3, 5, 7, 9], 'odd numbers up to ten'); +``` + +![bar dump](https://nette.github.io/tracy/images/tracy-bardump.png) + + +Timing +------ + +Another useful tool is the debugger stopwatch with a precision of microseconds: + +```php +Debugger::timer(); + +// sweet dreams my cherrie +sleep(2); + +$elapsed = Debugger::timer(); +// $elapsed = 2 +``` + +Multiple measurements at once can be achieved by an optional parameter. + +```php +Debugger::timer('page-generating'); +// some code + +Debugger::timer('rss-generating'); +// some code + +$rssElapsed = Debugger::timer('rss-generating'); +$pageElapsed = Debugger::timer('page-generating'); +``` + +```php +Debugger::timer(); // runs the timer + +... // some time-consuming operation + +echo Debugger::timer(); // elapsed time in seconds +``` + + +FireLogger +---------- + +You cannot always send debugging information to the browser window. This applies to AJAX requests or generating XML files to output. In such cases, you can send the messages by a separate channel into FireLogger. Error, Notice and Warning levels are sent to FireLogger window automatically. It is also possible to log suppressed exceptions in running application when attention to them is important. + +How to do it? + +- install extension [FireLogger for Chrome](https://chrome.google.com/webstore/detail/firelogger-for-chrome/hmagilfopmdjkeomnjpchokglfdfjfeh) +- turn on Chrome DevTools (using Ctrl-Shift-I key) and open Console + +Navigate to the [demo page](https://examples.nette.org/tracy/) and you will see messages sent from PHP. + +Because Tracy\Debugger communicates with FireLogger via HTTP headers, you must call the logging function before the PHP script sends anything to output. It is also possible to enable output buffering and delay the output. + +```php +use Tracy\Debugger; + +Debugger::fireLog('Hello World'); // send string into FireLogger console + +Debugger::fireLog($_SERVER); // or even arrays and objects + +Debugger::fireLog(new Exception('Test Exception')); // or exceptions +``` + +The result looks like this: + +![FireLogger](https://nette.github.io/tracy/images/tracy-firelogger.png) + + +Custom Logger +------------- + +We can create a custom logger to log errors, uncatched exceptions, and also be called by `Tracy\Debugger::log()`. Logger implements the interface Tracy\ILogger. + +```php +use Tracy\ILogger; + +class SlackLogger implements ILogger +{ + public function log($value, $priority = ILogger::INFO) + { + // sends a request to Slack + } +} +``` + +And then we activate it: + +```php +Tracy\Debugger::setLogger(new SlackLogger); +``` + +If we use the full Nette Framework, we can set it in the NEON configuration file: + +```neon +services: + tracy.logger: SlackLogger +``` + + +nginx +----- + +If Tracy does not work on nginx, it is probably misconfigured. If there is something like + +```nginx +try_files $uri $uri/ /index.php; +``` + +change it to + +```nginx +try_files $uri $uri/ /index.php$is_args$args; +``` + + +Integrations +------------ + +This is a list of unofficial integrations to other frameworks and CMS: + +- [Drupal 7](http://drupal.org/project/traced) +- Laravel framework: [recca0120/laravel-tracy](https://github.com/recca0120/laravel-tracy), [whipsterCZ/laravel-tracy](https://github.com/whipsterCZ/laravel-tracy) +- [OpenCart](https://github.com/BurdaPraha/oc_tracy) +- [ProcessWire CMS/CMF](https://github.com/adrianbj/TracyDebugger) +- [Slim Framework](https://github.com/runcmf/runtracy) +- Symfony framework: [kutny/tracy-bundle](https://github.com/kutny/tracy-bundle), [VasekPurchart/Tracy-Blue-Screen-Bundle](https://github.com/VasekPurchart/Tracy-Blue-Screen-Bundle) +- [Wordpress](https://github.com/ktstudio/WP-Tracy) + +... feel free to be famous, create an integration for your favourite platform! diff --git a/vendor/tracy/tracy/src/Bridges/Nette/Bridge.php b/vendor/tracy/tracy/src/Bridges/Nette/Bridge.php new file mode 100644 index 0000000..f9eeb9a --- /dev/null +++ b/vendor/tracy/tracy/src/Bridges/Nette/Bridge.php @@ -0,0 +1,137 @@ +<?php + +/** + * This file is part of the Tracy (https://tracy.nette.org) + * Copyright (c) 2004 David Grudl (https://davidgrudl.com) + */ + +declare(strict_types=1); + +namespace Tracy\Bridges\Nette; + +use Latte; +use Nette; +use Tracy; +use Tracy\BlueScreen; +use Tracy\Helpers; + + +/** + * Bridge for NEON & Latte. + */ +class Bridge +{ + public static function initialize(): void + { + $blueScreen = Tracy\Debugger::getBlueScreen(); + $blueScreen->addPanel([self::class, 'renderLatteError']); + $blueScreen->addAction([self::class, 'renderLatteUnknownMacro']); + $blueScreen->addAction([self::class, 'renderMemberAccessException']); + $blueScreen->addPanel([self::class, 'renderNeonError']); + } + + + public static function renderLatteError(?\Throwable $e): ?array + { + if ($e instanceof Latte\CompileException && $e->sourceName) { + return [ + 'tab' => 'Template', + 'panel' => (preg_match('#\n|\?#', $e->sourceName) + ? '' + : '<p>' + . (@is_file($e->sourceName) // @ - may trigger error + ? '<b>File:</b> ' . Helpers::editorLink($e->sourceName, $e->sourceLine) + : '<b>' . htmlspecialchars($e->sourceName . ($e->sourceLine ? ':' . $e->sourceLine : '')) . '</b>') + . '</p>') + . '<pre class=code><div>' + . BlueScreen::highlightLine(htmlspecialchars($e->sourceCode, ENT_IGNORE, 'UTF-8'), $e->sourceLine) + . '</div></pre>', + ]; + + } elseif ($e && strpos($file = $e->getFile(), '.latte--')) { + $lines = file($file); + if (preg_match('#// source: (\S+\.latte)#', $lines[1], $m) && @is_file($m[1])) { // @ - may trigger error + $templateFile = $m[1]; + $templateLine = $e->getLine() && preg_match('#/\* line (\d+) \*/#', $lines[$e->getLine() - 1], $m) ? (int) $m[1] : 0; + return [ + 'tab' => 'Template', + 'panel' => '<p><b>File:</b> ' . Helpers::editorLink($templateFile, $templateLine) . '</p>' + . ($templateLine === null + ? '' + : BlueScreen::highlightFile($templateFile, $templateLine)), + ]; + } + } + return null; + } + + + public static function renderLatteUnknownMacro(?\Throwable $e): ?array + { + if ( + $e instanceof Latte\CompileException + && $e->sourceName + && @is_file($e->sourceName) // @ - may trigger error + && (preg_match('#Unknown macro (\{\w+)\}, did you mean (\{\w+)\}\?#A', $e->getMessage(), $m) + || preg_match('#Unknown attribute (n:\w+), did you mean (n:\w+)\?#A', $e->getMessage(), $m)) + ) { + return [ + 'link' => Helpers::editorUri($e->sourceName, $e->sourceLine, 'fix', $m[1], $m[2]), + 'label' => 'fix it', + ]; + } + return null; + } + + + public static function renderMemberAccessException(?\Throwable $e): ?array + { + if (!$e instanceof Nette\MemberAccessException && !$e instanceof \LogicException) { + return null; + } + $loc = $e->getTrace()[$e instanceof Nette\MemberAccessException ? 1 : 0]; + if (preg_match('#Cannot (?:read|write to) an undeclared property .+::\$(\w+), did you mean \$(\w+)\?#A', $e->getMessage(), $m)) { + return [ + 'link' => Helpers::editorUri($loc['file'], $loc['line'], 'fix', '->' . $m[1], '->' . $m[2]), + 'label' => 'fix it', + ]; + } elseif (preg_match('#Call to undefined (static )?method .+::(\w+)\(\), did you mean (\w+)\(\)?#A', $e->getMessage(), $m)) { + $operator = $m[1] ? '::' : '->'; + return [ + 'link' => Helpers::editorUri($loc['file'], $loc['line'], 'fix', $operator . $m[2] . '(', $operator . $m[3] . '('), + 'label' => 'fix it', + ]; + } + return null; + } + + + public static function renderNeonError(?\Throwable $e): ?array + { + if ( + $e instanceof Nette\Neon\Exception + && preg_match('#line (\d+)#', $e->getMessage(), $m) + && ($trace = Helpers::findTrace($e->getTrace(), [Nette\Neon\Decoder::class, 'decode'])) + ) { + return [ + 'tab' => 'NEON', + 'panel' => ($trace2 = Helpers::findTrace($e->getTrace(), [Nette\DI\Config\Adapters\NeonAdapter::class, 'load'])) + ? '<p><b>File:</b> ' . Helpers::editorLink($trace2['args'][0], (int) $m[1]) . '</p>' + . self::highlightNeon(file_get_contents($trace2['args'][0]), (int) $m[1]) + : self::highlightNeon($trace['args'][0], (int) $m[1]), + ]; + } + return null; + } + + + private static function highlightNeon(string $code, int $line): string + { + $code = htmlspecialchars($code, ENT_IGNORE, 'UTF-8'); + $code = str_replace(' ', "<span class='tracy-dump-whitespace'>·</span>", $code); + $code = str_replace("\t", "<span class='tracy-dump-whitespace'>→ </span>", $code); + return '<pre class=code><div>' + . BlueScreen::highlightLine($code, $line) + . '</div></pre>'; + } +} diff --git a/vendor/tracy/tracy/src/Bridges/Nette/MailSender.php b/vendor/tracy/tracy/src/Bridges/Nette/MailSender.php new file mode 100644 index 0000000..53dde00 --- /dev/null +++ b/vendor/tracy/tracy/src/Bridges/Nette/MailSender.php @@ -0,0 +1,57 @@ +<?php + +/** + * This file is part of the Tracy (https://tracy.nette.org) + * Copyright (c) 2004 David Grudl (https://davidgrudl.com) + */ + +declare(strict_types=1); + +namespace Tracy\Bridges\Nette; + +use Nette; +use Tracy; + + +/** + * Tracy logger bridge for Nette Mail. + */ +class MailSender +{ + use Nette\SmartObject; + + /** @var Nette\Mail\IMailer */ + private $mailer; + + /** @var string|null sender of email notifications */ + private $fromEmail; + + + public function __construct(Nette\Mail\IMailer $mailer, string $fromEmail = null) + { + $this->mailer = $mailer; + $this->fromEmail = $fromEmail; + } + + + /** + * @param mixed $message + */ + public function send($message, string $email): void + { + $host = preg_replace('#[^\w.-]+#', '', $_SERVER['SERVER_NAME'] ?? php_uname('n')); + + $mail = new Nette\Mail\Message; + $mail->setHeader('X-Mailer', 'Tracy'); + if ($this->fromEmail || Nette\Utils\Validators::isEmail("noreply@$host")) { + $mail->setFrom($this->fromEmail ?: "noreply@$host"); + } + foreach (explode(',', $email) as $item) { + $mail->addTo(trim($item)); + } + $mail->setSubject('PHP: An error occurred on the server ' . $host); + $mail->setBody(Tracy\Logger::formatMessage($message) . "\n\nsource: " . Tracy\Helpers::getSource()); + + $this->mailer->send($mail); + } +} diff --git a/vendor/tracy/tracy/src/Bridges/Nette/TracyExtension.php b/vendor/tracy/tracy/src/Bridges/Nette/TracyExtension.php new file mode 100644 index 0000000..38f5d23 --- /dev/null +++ b/vendor/tracy/tracy/src/Bridges/Nette/TracyExtension.php @@ -0,0 +1,153 @@ +<?php + +/** + * This file is part of the Tracy (https://tracy.nette.org) + * Copyright (c) 2004 David Grudl (https://davidgrudl.com) + */ + +declare(strict_types=1); + +namespace Tracy\Bridges\Nette; + +use Nette; +use Nette\Schema\Expect; +use Tracy; + + +/** + * Tracy extension for Nette DI. + */ +class TracyExtension extends Nette\DI\CompilerExtension +{ + /** @var bool */ + private $debugMode; + + /** @var bool */ + private $cliMode; + + + public function __construct(bool $debugMode = false, bool $cliMode = false) + { + $this->debugMode = $debugMode; + $this->cliMode = $cliMode; + } + + + public function getConfigSchema(): Nette\Schema\Schema + { + return Expect::structure([ + 'email' => Expect::anyOf(Expect::email(), Expect::listOf('email'))->dynamic(), + 'fromEmail' => Expect::email()->dynamic(), + 'logSeverity' => Expect::anyOf(Expect::scalar(), Expect::listOf('scalar')), + 'editor' => Expect::string()->dynamic(), + 'browser' => Expect::string()->dynamic(), + 'errorTemplate' => Expect::string()->dynamic(), + 'strictMode' => Expect::bool()->dynamic(), + 'showBar' => Expect::bool()->dynamic(), + 'maxLength' => Expect::int()->dynamic(), + 'maxDepth' => Expect::int()->dynamic(), + 'keysToHide' => Expect::array(null)->dynamic(), + 'dumpTheme' => Expect::string()->dynamic(), + 'showLocation' => Expect::bool()->dynamic(), + 'scream' => Expect::bool()->dynamic(), + 'bar' => Expect::listOf('string|Nette\DI\Definitions\Statement'), + 'blueScreen' => Expect::listOf('callable'), + 'editorMapping' => Expect::arrayOf('string')->dynamic()->default(null), + 'netteMailer' => Expect::bool(true), + ]); + } + + + public function loadConfiguration() + { + $builder = $this->getContainerBuilder(); + + $builder->addDefinition($this->prefix('logger')) + ->setClass(Tracy\ILogger::class) + ->setFactory([Tracy\Debugger::class, 'getLogger']); + + $builder->addDefinition($this->prefix('blueScreen')) + ->setFactory([Tracy\Debugger::class, 'getBlueScreen']); + + $builder->addDefinition($this->prefix('bar')) + ->setFactory([Tracy\Debugger::class, 'getBar']); + } + + + public function afterCompile(Nette\PhpGenerator\ClassType $class) + { + $initialize = $this->initialization ?? new Nette\PhpGenerator\Closure; + $initialize->addBody('if (!Tracy\Debugger::isEnabled()) { return; }'); + + $builder = $this->getContainerBuilder(); + + $options = (array) $this->config; + unset($options['bar'], $options['blueScreen'], $options['netteMailer']); + if (isset($options['logSeverity'])) { + $res = 0; + foreach ((array) $options['logSeverity'] as $level) { + $res |= is_int($level) ? $level : constant($level); + } + $options['logSeverity'] = $res; + } + foreach ($options as $key => $value) { + if ($value !== null) { + static $tbl = [ + 'keysToHide' => 'array_push(Tracy\Debugger::getBlueScreen()->keysToHide, ... ?)', + 'fromEmail' => 'Tracy\Debugger::getLogger()->fromEmail = ?', + ]; + $initialize->addBody($builder->formatPhp( + ($tbl[$key] ?? 'Tracy\Debugger::$' . $key . ' = ?') . ';', + Nette\DI\Helpers::filterArguments([$value]) + )); + } + } + + $logger = $builder->getDefinition($this->prefix('logger')); + if ( + !$logger instanceof Nette\DI\ServiceDefinition + || $logger->getFactory()->getEntity() !== [Tracy\Debugger::class, 'getLogger'] + ) { + $initialize->addBody($builder->formatPhp('Tracy\Debugger::setLogger(?);', [$logger])); + } + if ($this->config->netteMailer && $builder->getByType(Nette\Mail\IMailer::class)) { + $initialize->addBody($builder->formatPhp('Tracy\Debugger::getLogger()->mailer = ?;', [ + [new Nette\DI\Statement(Tracy\Bridges\Nette\MailSender::class, ['fromEmail' => $this->config->fromEmail]), 'send'], + ])); + } + + if ($this->debugMode) { + foreach ($this->config->bar as $item) { + if (is_string($item) && substr($item, 0, 1) === '@') { + $item = new Nette\DI\Statement(['@' . $builder::THIS_CONTAINER, 'getService'], [substr($item, 1)]); + } elseif (is_string($item)) { + $item = new Nette\DI\Statement($item); + } + $initialize->addBody($builder->formatPhp( + '$this->getService(?)->addPanel(?);', + Nette\DI\Helpers::filterArguments([$this->prefix('bar'), $item]) + )); + } + + if (!$this->cliMode && ($name = $builder->getByType(Nette\Http\Session::class))) { + $initialize->addBody('$this->getService(?)->start();', [$name]); + $initialize->addBody('Tracy\Debugger::dispatch();'); + } + } + + foreach ($this->config->blueScreen as $item) { + $initialize->addBody($builder->formatPhp( + '$this->getService(?)->addPanel(?);', + Nette\DI\Helpers::filterArguments([$this->prefix('blueScreen'), $item]) + )); + } + + if (empty($this->initialization)) { + $class->getMethod('initialize')->addBody("($initialize)();"); + } + + if (($dir = Tracy\Debugger::$logDirectory) && !is_writable($dir)) { + throw new Nette\InvalidStateException("Make directory '$dir' writable."); + } + } +} diff --git a/vendor/tracy/tracy/src/Bridges/Psr/PsrToTracyLoggerAdapter.php b/vendor/tracy/tracy/src/Bridges/Psr/PsrToTracyLoggerAdapter.php new file mode 100644 index 0000000..3feedd6 --- /dev/null +++ b/vendor/tracy/tracy/src/Bridges/Psr/PsrToTracyLoggerAdapter.php @@ -0,0 +1,62 @@ +<?php + +/** + * This file is part of the Tracy (https://tracy.nette.org) + * Copyright (c) 2004 David Grudl (https://davidgrudl.com) + */ + +declare(strict_types=1); + +namespace Tracy\Bridges\Psr; + +use Psr; +use Tracy; + + +/** + * Psr\Log\LoggerInterface to Tracy\ILogger adapter. + */ +class PsrToTracyLoggerAdapter implements Tracy\ILogger +{ + /** Tracy logger level to PSR-3 log level mapping */ + private const LEVEL_MAP = [ + Tracy\ILogger::DEBUG => Psr\Log\LogLevel::DEBUG, + Tracy\ILogger::INFO => Psr\Log\LogLevel::INFO, + Tracy\ILogger::WARNING => Psr\Log\LogLevel::WARNING, + Tracy\ILogger::ERROR => Psr\Log\LogLevel::ERROR, + Tracy\ILogger::EXCEPTION => Psr\Log\LogLevel::ERROR, + Tracy\ILogger::CRITICAL => Psr\Log\LogLevel::CRITICAL, + ]; + + /** @var Psr\Log\LoggerInterface */ + private $psrLogger; + + + public function __construct(Psr\Log\LoggerInterface $psrLogger) + { + $this->psrLogger = $psrLogger; + } + + + public function log($value, $level = self::INFO) + { + if ($value instanceof \Throwable) { + $message = Tracy\Helpers::getClass($value) . ': ' . $value->getMessage() . ($value->getCode() ? ' #' . $value->getCode() : '') . ' in ' . $value->getFile() . ':' . $value->getLine(); + $context = ['exception' => $value]; + + } elseif (!is_string($value)) { + $message = trim(Tracy\Dumper::toText($value)); + $context = []; + + } else { + $message = $value; + $context = []; + } + + $this->psrLogger->log( + self::LEVEL_MAP[$level] ?? Psr\Log\LogLevel::ERROR, + $message, + $context + ); + } +} diff --git a/vendor/tracy/tracy/src/Bridges/Psr/TracyToPsrLoggerAdapter.php b/vendor/tracy/tracy/src/Bridges/Psr/TracyToPsrLoggerAdapter.php new file mode 100644 index 0000000..32d5747 --- /dev/null +++ b/vendor/tracy/tracy/src/Bridges/Psr/TracyToPsrLoggerAdapter.php @@ -0,0 +1,61 @@ +<?php + +/** + * This file is part of the Tracy (https://tracy.nette.org) + * Copyright (c) 2004 David Grudl (https://davidgrudl.com) + */ + +declare(strict_types=1); + +namespace Tracy\Bridges\Psr; + +use Psr; +use Tracy; + + +/** + * Tracy\ILogger to Psr\Log\LoggerInterface adapter. + */ +class TracyToPsrLoggerAdapter extends Psr\Log\AbstractLogger +{ + /** PSR-3 log level to Tracy logger level mapping */ + private const LEVEL_MAP = [ + Psr\Log\LogLevel::EMERGENCY => Tracy\ILogger::CRITICAL, + Psr\Log\LogLevel::ALERT => Tracy\ILogger::CRITICAL, + Psr\Log\LogLevel::CRITICAL => Tracy\ILogger::CRITICAL, + Psr\Log\LogLevel::ERROR => Tracy\ILogger::ERROR, + Psr\Log\LogLevel::WARNING => Tracy\ILogger::WARNING, + Psr\Log\LogLevel::NOTICE => Tracy\ILogger::WARNING, + Psr\Log\LogLevel::INFO => Tracy\ILogger::INFO, + Psr\Log\LogLevel::DEBUG => Tracy\ILogger::DEBUG, + ]; + + /** @var Tracy\ILogger */ + private $tracyLogger; + + + public function __construct(Tracy\ILogger $tracyLogger) + { + $this->tracyLogger = $tracyLogger; + } + + + public function log($level, $message, array $context = []) + { + $level = self::LEVEL_MAP[$level] ?? Tracy\ILogger::ERROR; + + if (isset($context['exception']) && $context['exception'] instanceof \Throwable) { + $this->tracyLogger->log($context['exception'], $level); + unset($context['exception']); + } + + if ($context) { + $message = [ + 'message' => $message, + 'context' => $context, + ]; + } + + $this->tracyLogger->log($message, $level); + } +} diff --git a/vendor/tracy/tracy/src/Tracy/Bar/Bar.php b/vendor/tracy/tracy/src/Tracy/Bar/Bar.php new file mode 100644 index 0000000..8c6cbe7 --- /dev/null +++ b/vendor/tracy/tracy/src/Tracy/Bar/Bar.php @@ -0,0 +1,246 @@ +<?php + +/** + * This file is part of the Tracy (https://tracy.nette.org) + * Copyright (c) 2004 David Grudl (https://davidgrudl.com) + */ + +declare(strict_types=1); + +namespace Tracy; + + +/** + * Debug Bar. + */ +class Bar +{ + /** @var IBarPanel[] */ + private $panels = []; + + /** @var bool initialized by dispatchAssets() */ + private $useSession = false; + + /** @var string|null generated by renderLoader() */ + private $contentId; + + + /** + * Add custom panel. + * @return static + */ + public function addPanel(IBarPanel $panel, string $id = null): self + { + if ($id === null) { + $c = 0; + do { + $id = get_class($panel) . ($c++ ? "-$c" : ''); + } while (isset($this->panels[$id])); + } + $this->panels[$id] = $panel; + return $this; + } + + + /** + * Returns panel with given id + */ + public function getPanel(string $id): ?IBarPanel + { + return $this->panels[$id] ?? null; + } + + + /** + * Renders loading <script> + * @internal + */ + public function renderLoader(): void + { + if (!$this->useSession) { + throw new \LogicException('Start session before Tracy is enabled.'); + } + $contentId = $this->contentId = $this->contentId ?: substr(md5(uniqid('', true)), 0, 10); + $nonce = Helpers::getNonce(); + $async = true; + require __DIR__ . '/assets/loader.phtml'; + } + + + /** + * Renders debug bar. + */ + public function render(): void + { + $useSession = $this->useSession && session_status() === PHP_SESSION_ACTIVE; + $redirectQueue = &$_SESSION['_tracy']['redirect']; + + foreach (['bar', 'redirect', 'bluescreen'] as $key) { + $queue = &$_SESSION['_tracy'][$key]; + $queue = array_slice((array) $queue, -10, null, true); + $queue = array_filter($queue, function ($item) { + return isset($item['time']) && $item['time'] > time() - 60; + }); + } + + if (Helpers::isAjax()) { + if ($useSession) { + $contentId = $_SERVER['HTTP_X_TRACY_AJAX']; + $_SESSION['_tracy']['bar'][$contentId] = ['content' => $this->renderHtml('ajax', '-ajax:' . $contentId), 'time' => time()]; + } + + } elseif (preg_match('#^Location:#im', implode("\n", headers_list()))) { // redirect + if ($useSession) { + $redirectQueue[] = ['content' => $this->renderHtml('redirect', '-r' . count($redirectQueue)), 'time' => time()]; + } + + } elseif (Helpers::isHtmlMode()) { + $content = $this->renderHtml('main'); + + foreach (array_reverse((array) $redirectQueue) as $item) { + $content['bar'] .= $item['content']['bar']; + $content['panels'] .= $item['content']['panels']; + } + $redirectQueue = null; + + $content = '<div id=tracy-debug-bar>' . $content['bar'] . '</div>' . $content['panels']; + + if ($this->contentId) { + $_SESSION['_tracy']['bar'][$this->contentId] = ['content' => $content, 'time' => time()]; + } else { + $contentId = substr(md5(uniqid('', true)), 0, 10); + $nonce = Helpers::getNonce(); + $async = false; + require __DIR__ . '/assets/loader.phtml'; + } + } + } + + + private function renderHtml(string $type, string $suffix = ''): array + { + $panels = $this->renderPanels($suffix); + + return [ + 'bar' => Helpers::capture(function () use ($type, $panels) { + require __DIR__ . '/assets/bar.phtml'; + }), + 'panels' => Helpers::capture(function () use ($type, $panels) { + require __DIR__ . '/assets/panels.phtml'; + }), + ]; + } + + + private function renderPanels(string $suffix = ''): array + { + set_error_handler(function (int $severity, string $message, string $file, int $line) { + if (error_reporting() & $severity) { + throw new \ErrorException($message, 0, $severity, $file, $line); + } + }); + + $obLevel = ob_get_level(); + $panels = []; + + foreach ($this->panels as $id => $panel) { + $idHtml = preg_replace('#[^a-z0-9]+#i', '-', $id) . $suffix; + try { + $tab = (string) $panel->getTab(); + $panelHtml = $tab ? $panel->getPanel() : null; + + } catch (\Throwable $e) { + while (ob_get_level() > $obLevel) { // restore ob-level if broken + ob_end_clean(); + } + $idHtml = "error-$idHtml"; + $tab = "Error in $id"; + $panelHtml = "<h1>Error: $id</h1><div class='tracy-inner'>" . nl2br(Helpers::escapeHtml($e)) . '</div>'; + unset($e); + } + $panels[] = (object) ['id' => $idHtml, 'tab' => $tab, 'panel' => $panelHtml]; + } + + restore_error_handler(); + return $panels; + } + + + /** + * Renders debug bar assets. + * @internal + */ + public function dispatchAssets(): bool + { + $asset = $_GET['_tracy_bar'] ?? null; + if ($asset === 'js') { + header('Content-Type: application/javascript; charset=UTF-8'); + header('Cache-Control: max-age=864000'); + header_remove('Pragma'); + header_remove('Set-Cookie'); + $this->renderAssets(); + return true; + } + + $this->useSession = session_status() === PHP_SESSION_ACTIVE; + + if ($this->useSession && Helpers::isAjax()) { + header('X-Tracy-Ajax: 1'); // session must be already locked + } + + if ($this->useSession && is_string($asset) && preg_match('#^content(-ajax)?\.(\w+)$#', $asset, $m)) { + $session = &$_SESSION['_tracy']['bar'][$m[2]]; + header('Content-Type: application/javascript; charset=UTF-8'); + header('Cache-Control: max-age=60'); + header_remove('Set-Cookie'); + if (!$m[1]) { + $this->renderAssets(); + } + if ($session) { + $method = $m[1] ? 'loadAjax' : 'init'; + echo "Tracy.Debug.$method(", json_encode($session['content'], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_INVALID_UTF8_SUBSTITUTE), ');'; + $session = null; + } + $session = &$_SESSION['_tracy']['bluescreen'][$m[2]]; + if ($session) { + echo 'Tracy.BlueScreen.loadAjax(', json_encode($session['content'], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_INVALID_UTF8_SUBSTITUTE), ');'; + $session = null; + } + return true; + } + + return false; + } + + + private function renderAssets(): void + { + $css = array_map('file_get_contents', array_merge([ + __DIR__ . '/assets/bar.css', + __DIR__ . '/../Toggle/toggle.css', + __DIR__ . '/../TableSort/table-sort.css', + __DIR__ . '/../Dumper/assets/dumper-light.css', + __DIR__ . '/../Dumper/assets/dumper-dark.css', + __DIR__ . '/../BlueScreen/assets/bluescreen.css', + ], Debugger::$customCssFiles)); + + echo +"'use strict'; +(function(){ + var el = document.createElement('style'); + el.setAttribute('nonce', document.currentScript.getAttribute('nonce') || document.currentScript.nonce); + el.className='tracy-debug'; + el.textContent=" . json_encode(Helpers::minifyCss(implode($css))) . "; + document.head.appendChild(el);}) +();\n"; + + array_map(function ($file) { echo '(function() {', file_get_contents($file), '})();'; }, [ + __DIR__ . '/assets/bar.js', + __DIR__ . '/../Toggle/toggle.js', + __DIR__ . '/../TableSort/table-sort.js', + __DIR__ . '/../Dumper/assets/dumper.js', + __DIR__ . '/../BlueScreen/assets/bluescreen.js', + ]); + array_map('readfile', Debugger::$customJsFiles); + } +} diff --git a/vendor/tracy/tracy/src/Tracy/Bar/DefaultBarPanel.php b/vendor/tracy/tracy/src/Tracy/Bar/DefaultBarPanel.php new file mode 100644 index 0000000..3c7403b --- /dev/null +++ b/vendor/tracy/tracy/src/Tracy/Bar/DefaultBarPanel.php @@ -0,0 +1,54 @@ +<?php + +/** + * This file is part of the Tracy (https://tracy.nette.org) + * Copyright (c) 2004 David Grudl (https://davidgrudl.com) + */ + +declare(strict_types=1); + +namespace Tracy; + + +/** + * IBarPanel implementation helper. + * @internal + */ +class DefaultBarPanel implements IBarPanel +{ + public $data; + + private $id; + + + public function __construct(string $id) + { + $this->id = $id; + } + + + /** + * Renders HTML code for custom tab. + */ + public function getTab(): string + { + return Helpers::capture(function () { + $data = $this->data; + require __DIR__ . "/panels/{$this->id}.tab.phtml"; + }); + } + + + /** + * Renders HTML code for custom panel. + */ + public function getPanel(): string + { + return Helpers::capture(function () { + if (is_file(__DIR__ . "/panels/{$this->id}.panel.phtml")) { + $data = $this->data; + require __DIR__ . "/panels/{$this->id}.panel.phtml"; + } + }); + } +} diff --git a/vendor/tracy/tracy/src/Tracy/Bar/IBarPanel.php b/vendor/tracy/tracy/src/Tracy/Bar/IBarPanel.php new file mode 100644 index 0000000..f162d66 --- /dev/null +++ b/vendor/tracy/tracy/src/Tracy/Bar/IBarPanel.php @@ -0,0 +1,29 @@ +<?php + +/** + * This file is part of the Tracy (https://tracy.nette.org) + * Copyright (c) 2004 David Grudl (https://davidgrudl.com) + */ + +declare(strict_types=1); + +namespace Tracy; + + +/** + * Custom output for Debugger. + */ +interface IBarPanel +{ + /** + * Renders HTML code for custom tab. + * @return string + */ + function getTab(); + + /** + * Renders HTML code for custom panel. + * @return string + */ + function getPanel(); +} diff --git a/vendor/tracy/tracy/src/Tracy/Bar/assets/bar.css b/vendor/tracy/tracy/src/Tracy/Bar/assets/bar.css new file mode 100644 index 0000000..ea1d132 --- /dev/null +++ b/vendor/tracy/tracy/src/Tracy/Bar/assets/bar.css @@ -0,0 +1,515 @@ +/** + * This file is part of the Tracy (https://tracy.nette.org) + */ + +/* common styles */ +#tracy-debug, +#tracy-debug * { + font: inherit; + line-height: inherit; + color: inherit; + background: transparent; + margin: 0; + padding: 0; + border: none; + text-align: inherit; + list-style: inherit; + opacity: 1; + border-radius: 0; + box-shadow: none; + text-shadow: none; + box-sizing: border-box; + text-decoration: none; + text-transform: inherit; + white-space: inherit; + float: none; + clear: none; + max-width: initial; + min-width: initial; + max-height: initial; + min-height: initial; +} + +#tracy-debug *:not(svg):not(img):not(table) { + width: initial; + height: initial; +} + +#tracy-debug:before, +#tracy-debug:after, +#tracy-debug *:before, +#tracy-debug *:after { + all: unset; +} + +#tracy-debug { + display: none; + direction: ltr; +} + +body#tracy-debug { /* in popup window */ + display: block; +} + +#tracy-debug:not(body) { + position: absolute; + left: 0; + top: 0; +} + +#tracy-debug b, +#tracy-debug strong { + font-weight: bold; +} + +#tracy-debug small { + font-size: smaller; +} + +#tracy-debug i, +#tracy-debug em { + font-style: italic; +} + +#tracy-debug a { + color: #125EAE; + text-decoration: none; +} + +#tracy-debug a:hover, +#tracy-debug a:focus { + background-color: #125EAE; + color: white; +} + +#tracy-debug h2, +#tracy-debug h3, +#tracy-debug p { + margin: .4em 0; +} + +#tracy-debug table { + border-collapse: collapse; + background: #FDF5CE; + width: 100%; +} + +#tracy-debug tr:nth-child(2n) td { + background: rgba(0, 0, 0, 0.02); +} + +#tracy-debug td, +#tracy-debug th { + border: 1px solid #E6DFBF; + padding: 2px 5px; + vertical-align: top; + text-align: left; +} + +#tracy-debug th { + background: #F4F3F1; + color: #655E5E; + font-size: 90%; + font-weight: bold; +} + +/* TableSort */ +#tracy-debug .tracy-sortable > :first-child > tr:first-child > * { + position: relative; +} + +#tracy-debug .tracy-sortable > :first-child > tr:first-child > *:hover:before { + position: absolute; + right: .3em; + content: "\21C5"; + opacity: .4; + font-weight: normal; +} + +#tracy-debug pre, +#tracy-debug code { + font: 9pt/1.5 Consolas, monospace; +} + +#tracy-debug pre { + white-space: pre; +} + +#tracy-debug table .tracy-right { + text-align: right; +} + +#tracy-debug svg { + display: inline; +} + + +/* bar */ +#tracy-debug-bar { + font: normal normal 13px/1.55 Tahoma, sans-serif; + color: #333; + border: 1px solid #c9c9c9; + background: #EDEAE0 url('data:image/png;base64,R0lGODlhAQAUALMAAOzq4e/t5e7s4/Dt5vDu5e3r4vDu5uvp4O/t5AAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAAAAAAALAAAAAABABQAAAQM0EgySEAYi1LA+UcEADs=') top; + background-size: 1em; + position: fixed; + + min-width: 50px; + white-space: nowrap; + + z-index: 30000; + opacity: .9; + transition: opacity 0.2s; + will-change: opacity, top, left; + + border-radius: 3px; + box-shadow: 1px 1px 10px rgba(0, 0, 0, .15); +} + +#tracy-debug-bar:hover { + opacity: 1; + transition: opacity 0.1s; +} + +#tracy-debug-bar .tracy-row { + list-style: none none; + display: flex; +} + +#tracy-debug-bar .tracy-row:not(:first-child) { + background: #d5d2c6; + opacity: .8; +} + +#tracy-debug-bar .tracy-row[data-tracy-group="ajax"] { + animation: tracy-row-flash .2s ease; +} + +@keyframes tracy-row-flash { + 0% { + background: #c9c0a0; + } +} + +#tracy-debug-bar .tracy-row:not(:first-child) li:first-child { + width: 4.1em; + text-align: center; +} + +#tracy-debug-bar img { + vertical-align: bottom; + position: relative; + top: -2px; +} + +#tracy-debug-bar svg { + vertical-align: bottom; + width: 1.23em; + height: 1.55em; +} + +#tracy-debug-bar .tracy-label { + margin-left: .2em; +} + +#tracy-debug-bar li > a, +#tracy-debug-bar li > span { + color: #000; + display: block; + padding: 0 .4em; +} + +#tracy-debug-bar li > a:hover { + color: black; + background: #c3c1b8; +} + +#tracy-debug-bar li:first-child { + cursor: move; +} + +#tracy-debug-logo svg { + width: 3.4em; + margin: 0 .2em 0 .5em; +} + + +/* panels */ +#tracy-debug .tracy-panel { + display: none; + font: normal normal 12px/1.5 sans-serif; + background: white; + color: #333; + text-align: left; +} + +body#tracy-debug .tracy-panel { /* in popup window */ + display: block; +} + +#tracy-debug h1 { + font: normal normal 23px/1.4 Tahoma, sans-serif; + color: #575753; + margin: -5px -5px 5px; + padding: 0 5px 0 5px; + word-wrap: break-word; +} + +#tracy-debug .tracy-inner { + overflow: auto; + flex: 1; +} + +#tracy-debug .tracy-panel .tracy-icons { + display: none; +} + +#tracy-debug .tracy-panel-ajax h1::after, +#tracy-debug .tracy-panel-redirect h1::after { + content: 'ajax'; + float: right; + font-size: 65%; + margin: 0 .3em; +} + +#tracy-debug .tracy-panel-redirect h1::after { + content: 'redirect'; +} + +#tracy-debug .tracy-mode-peek, +#tracy-debug .tracy-mode-float { + position: fixed; + flex-direction: column; + padding: 10px; + min-width: 200px; + min-height: 80px; + border-radius: 5px; + box-shadow: 1px 1px 20px rgba(102, 102, 102, 0.36); + border: 1px solid rgba(0, 0, 0, 0.1); +} + +#tracy-debug .tracy-mode-peek, +#tracy-debug .tracy-mode-float:not(.tracy-panel-resized) { + max-width: 700px; + max-height: 500px; +} + +@media (max-height: 555px) { + #tracy-debug .tracy-mode-peek, + #tracy-debug .tracy-mode-float:not(.tracy-panel-resized) { + max-height: 100vh; + } +} + +#tracy-debug .tracy-mode-peek h1 { + cursor: move; +} + +#tracy-debug .tracy-mode-float { + display: flex; + opacity: .95; + transition: opacity 0.2s; + will-change: opacity, top, left; + overflow: auto; + resize: both; +} + +#tracy-debug .tracy-focused { + display: flex; + opacity: 1; + transition: opacity 0.1s; +} + +#tracy-debug .tracy-mode-float h1 { + cursor: move; + padding-right: 25px; +} + +#tracy-debug .tracy-mode-float .tracy-icons { + display: block; + position: absolute; + top: 0; + right: 5px; + font-size: 18px; +} + +#tracy-debug .tracy-mode-window { + padding: 10px; +} + +#tracy-debug .tracy-icons a { + color: #575753; +} + +#tracy-debug .tracy-icons a:hover { + color: white; +} + + +#tracy-debug .tracy-inner-container { + min-width: 100%; + float: left; +} + + +/* dump */ +#tracy-debug .tracy-dump div { + padding-left: 3ex; +} + +#tracy-debug .tracy-dump div div { + border-left: 1px solid rgba(0, 0, 0, .1); + margin-left: .5ex; +} + +#tracy-debug .tracy-dump div div:hover { + border-left-color: rgba(0, 0, 0, .25); +} + +#tracy-debug .tracy-dump { + background: #FDF5CE; + padding: .4em .7em; + border: 1px dotted silver; + overflow: auto; +} + +#tracy-debug table .tracy-dump { + padding: 0; + margin: 0; + border: none; +} + +#tracy-debug .tracy-dump-location { + color: gray; + font-size: 80%; + text-decoration: none; + background: none; + opacity: .5; + float: right; + cursor: pointer; +} + +#tracy-debug .tracy-dump-location:hover, +#tracy-debug .tracy-dump-location:focus { + color: gray; + background: none; + opacity: 1; +} + +#tracy-debug .tracy-dump-array, +#tracy-debug .tracy-dump-object { + color: #C22; +} + +#tracy-debug .tracy-dump-string { + color: #35D; + white-space: break-spaces; +} + +#tracy-debug div.tracy-dump-string { + position: relative; + padding-left: 3.5ex; +} + +#tracy-debug .tracy-dump-lq { + margin-left: calc(-1ex - 1px); +} + +#tracy-debug div.tracy-dump-string:before { + content: ''; + position: absolute; + left: calc(3ex - 1px); + top: 1.5em; + bottom: 0; + border-left: 1px solid rgba(0, 0, 0, .1); +} + +#tracy-debug .tracy-dump-virtual span, +#tracy-debug .tracy-dump-dynamic span, +#tracy-debug .tracy-dump-string span { + color: rgba(0, 0, 0, 0.5); +} + +#tracy-debug .tracy-dump-virtual i, +#tracy-debug .tracy-dump-dynamic i, +#tracy-debug .tracy-dump-string i { + font-size: 80%; + font-style: normal; + color: rgba(0, 0, 0, 0.5); + user-select: none; +} + +#tracy-debug .tracy-dump-number { + color: #090; +} + +#tracy-debug .tracy-dump-null, +#tracy-debug .tracy-dump-bool { + color: #850; +} + +#tracy-debug .tracy-dump-virtual { + font-style: italic; +} + +#tracy-debug .tracy-dump-public::after { + content: ' pub'; +} + +#tracy-debug .tracy-dump-protected::after { + content: ' pro'; +} + +#tracy-debug .tracy-dump-private::after { + content: ' pri'; +} + +#tracy-debug .tracy-dump-public::after, +#tracy-debug .tracy-dump-protected::after, +#tracy-debug .tracy-dump-private::after, +#tracy-debug .tracy-dump-hash { + font-size: 85%; + color: rgba(0, 0, 0, 0.5); +} + +#tracy-debug .tracy-dump-indent { + display: none; +} + +#tracy-debug .tracy-dump-highlight { + background: #C22; + color: white; + border-radius: 2px; + padding: 0 2px; + margin: 0 -2px; +} + +#tracy-debug span[data-tracy-href] { + border-bottom: 1px dotted rgba(0, 0, 0, .2); +} + + +/* toggle */ +#tracy-debug .tracy-toggle:after { + content: ''; + display: inline-block; + vertical-align: middle; + line-height: 0; + border-top: .6ex solid; + border-right: .6ex solid transparent; + border-left: .6ex solid transparent; + transform: scale(1, 1.5); + margin: 0 .2ex 0 .7ex; + transition: .1s transform; + opacity: .5; +} + +#tracy-debug .tracy-toggle.tracy-collapsed:after { + transform: rotate(-90deg) scale(1, 1.5) translate(.1ex, 0); +} + + +@media print { + #tracy-debug * { + display: none; + } +} diff --git a/vendor/tracy/tracy/src/Tracy/Bar/assets/bar.js b/vendor/tracy/tracy/src/Tracy/Bar/assets/bar.js new file mode 100644 index 0000000..374e4e8 --- /dev/null +++ b/vendor/tracy/tracy/src/Tracy/Bar/assets/bar.js @@ -0,0 +1,695 @@ +/** + * This file is part of the Tracy (https://tracy.nette.org) + */ + +let panelZIndex = 20000, + maxAjaxRows = 3, + autoRefresh = true, + nonce = document.currentScript.getAttribute('nonce') || document.currentScript.nonce, + contentId = document.currentScript.dataset.id, + ajaxCounter = 1, + baseUrl = location.href.split('#')[0]; + +baseUrl += (baseUrl.indexOf('?') < 0 ? '?' : '&'); + +class Panel +{ + constructor(id) { + this.id = id; + this.elem = document.getElementById(this.id); + this.elem.Tracy = this.elem.Tracy || {}; + } + + + init() { + let elem = this.elem; + + this.init = function() {}; + elem.innerHTML = addNonces(elem.dataset.tracyContent); + Tracy.Dumper.init(Debug.layer); + delete elem.dataset.tracyContent; + evalScripts(elem); + + draggable(elem, { + handles: elem.querySelectorAll('h1'), + start: () => { + if (!this.is(Panel.FLOAT)) { + this.toFloat(); + } + this.focus(); + this.peekPosition = false; + } + }); + + elem.addEventListener('mousedown', () => { + this.focus(); + }); + + elem.addEventListener('mouseenter', () => { + clearTimeout(elem.Tracy.displayTimeout); + }); + + elem.addEventListener('mouseleave', () => { + this.blur(); + }); + + elem.addEventListener('mousemove', (e) => { + if (e.buttons && !this.is(Panel.RESIZED) && (elem.style.width || elem.style.height)) { + elem.classList.add(Panel.RESIZED); + } + }); + + elem.addEventListener('tracy-toggle', () => { + this.reposition(); + }); + + elem.querySelectorAll('.tracy-icons a').forEach((link) => { + link.addEventListener('click', (e) => { + if (link.dataset.tracyAction === 'close') { + this.toPeek(); + } else if (link.dataset.tracyAction === 'window') { + this.toWindow(); + } + e.preventDefault(); + e.stopImmediatePropagation(); + }); + }); + + if (this.is('tracy-panel-persist')) { + Tracy.Toggle.persist(elem); + } + } + + + is(mode) { + return this.elem.classList.contains(mode); + } + + + focus() { + let elem = this.elem; + if (this.is(Panel.WINDOW)) { + elem.Tracy.window.focus(); + + } else if (!this.is(Panel.FOCUSED)) { + for (let id in Debug.panels) { + Debug.panels[id].elem.classList.remove(Panel.FOCUSED); + } + elem.classList.add(Panel.FOCUSED); + elem.style.zIndex = panelZIndex + Panel.zIndexCounter++; + } + } + + + blur() { + let elem = this.elem; + if (this.is(Panel.PEEK)) { + clearTimeout(elem.Tracy.displayTimeout); + elem.Tracy.displayTimeout = setTimeout(() => { + elem.classList.remove(Panel.FOCUSED); + }, 50); + } + } + + + toFloat() { + this.elem.classList.remove(Panel.WINDOW); + this.elem.classList.remove(Panel.PEEK); + this.elem.classList.add(Panel.FLOAT); + this.elem.classList.remove(Panel.RESIZED); + this.reposition(); + } + + + toPeek() { + this.elem.classList.remove(Panel.WINDOW); + this.elem.classList.remove(Panel.FLOAT); + this.elem.classList.remove(Panel.FOCUSED); + this.elem.classList.add(Panel.PEEK); + this.elem.style.width = ''; + this.elem.style.height = ''; + this.elem.classList.remove(Panel.RESIZED); + } + + + toWindow() { + let offset = getOffset(this.elem); + offset.left += typeof window.screenLeft === 'number' ? window.screenLeft : (window.screenX + 10); + offset.top += typeof window.screenTop === 'number' ? window.screenTop : (window.screenY + 50); + + let win = window.open('', this.id.replace(/-/g, '_'), 'left=' + offset.left + ',top=' + offset.top + + ',width=' + this.elem.offsetWidth + ',height=' + this.elem.offsetHeight + ',resizable=yes,scrollbars=yes'); + if (!win) { + return false; + } + + let doc = win.document; + doc.write('<!DOCTYPE html><meta charset="utf-8">' + + '<script src="' + (baseUrl.replace(/&/g, '&').replace(/"/g, '"')) + '_tracy_bar=js&XDEBUG_SESSION_STOP=1" onload="Tracy.Dumper.init()" async></script>' + + '<body id="tracy-debug">' + ); + doc.body.innerHTML = '<div class="tracy-panel tracy-mode-window" id="' + this.elem.id + '">' + this.elem.innerHTML + '</div>'; + evalScripts(doc.body); + if (this.elem.querySelector('h1')) { + doc.title = this.elem.querySelector('h1').textContent; + } + + win.addEventListener('beforeunload', () => { + this.toPeek(); + win.close(); // forces closing, can be invoked by F5 + }); + + doc.addEventListener('keyup', (e) => { + if (e.keyCode === 27 && !e.shiftKey && !e.altKey && !e.ctrlKey && !e.metaKey) { + win.close(); + } + }); + + this.elem.classList.remove(Panel.FLOAT); + this.elem.classList.remove(Panel.PEEK); + this.elem.classList.remove(Panel.FOCUSED); + this.elem.classList.remove(Panel.RESIZED); + this.elem.classList.add(Panel.WINDOW); + this.elem.Tracy.window = win; + return true; + } + + + reposition(deltaX, deltaY) { + let pos = getPosition(this.elem); + if (pos.width) { // is visible? + setPosition(this.elem, {left: pos.left + (deltaX || 0), top: pos.top + (deltaY || 0)}); + if (this.is(Panel.RESIZED)) { + let size = getWindowSize(); + this.elem.style.width = Math.min(size.width, pos.width) + 'px'; + this.elem.style.height = Math.min(size.height, pos.height) + 'px'; + } + } + } + + + savePosition() { + let key = this.id.split(':')[0]; // remove :contentId part + let pos = getPosition(this.elem); + if (this.is(Panel.WINDOW)) { + localStorage.setItem(key, JSON.stringify({window: true})); + } else if (pos.width) { // is visible? + localStorage.setItem(key, JSON.stringify({right: pos.right, bottom: pos.bottom, width: pos.width, height: pos.height, zIndex: this.elem.style.zIndex - panelZIndex, resized: this.is(Panel.RESIZED)})); + } else { + localStorage.removeItem(key); + } + } + + + restorePosition() { + let key = this.id.split(':')[0]; + let pos = JSON.parse(localStorage.getItem(key)); + if (!pos) { + this.elem.classList.add(Panel.PEEK); + } else if (pos.window) { + this.init(); + this.toWindow() || this.toFloat(); + } else if (this.elem.dataset.tracyContent) { + this.init(); + this.toFloat(); + if (pos.resized) { + this.elem.classList.add(Panel.RESIZED); + this.elem.style.width = pos.width + 'px'; + this.elem.style.height = pos.height + 'px'; + } + setPosition(this.elem, pos); + this.elem.style.zIndex = panelZIndex + (pos.zIndex || 1); + Panel.zIndexCounter = Math.max(Panel.zIndexCounter, (pos.zIndex || 1)) + 1; + } + } +} + +Panel.PEEK = 'tracy-mode-peek'; +Panel.FLOAT = 'tracy-mode-float'; +Panel.WINDOW = 'tracy-mode-window'; +Panel.FOCUSED = 'tracy-focused'; +Panel.RESIZED = 'tracy-panel-resized'; +Panel.zIndexCounter = 1; + + +class Bar +{ + init() { + this.id = 'tracy-debug-bar'; + this.elem = document.getElementById(this.id); + + draggable(this.elem, { + handles: this.elem.querySelectorAll('li:first-child'), + draggedClass: 'tracy-dragged', + stop: () => { + this.savePosition(); + } + }); + + this.elem.addEventListener('mousedown', (e) => { + e.preventDefault(); + }); + + this.initTabs(this.elem); + this.restorePosition(); + + (new MutationObserver(() => { + this.restorePosition(); + })).observe(this.elem, {childList: true, characterData: true, subtree: true}); + } + + + initTabs(elem) { + elem.querySelectorAll('a').forEach((link) => { + link.addEventListener('click', (e) => { + if (link.dataset.tracyAction === 'close') { + this.close(); + + } else if (link.rel) { + let panel = Debug.panels[link.rel]; + panel.init(); + + if (e.shiftKey) { + panel.toFloat(); + panel.toWindow(); + + } else if (panel.is(Panel.FLOAT)) { + panel.toPeek(); + + } else { + panel.toFloat(); + if (panel.peekPosition) { + panel.reposition(-Math.round(Math.random() * 100) - 20, (Math.round(Math.random() * 100) + 20) * (this.isAtTop() ? 1 : -1)); + panel.peekPosition = false; + } + } + } + e.preventDefault(); + e.stopImmediatePropagation(); + }); + + link.addEventListener('mouseenter', (e) => { + if (e.buttons || !link.rel || elem.classList.contains('tracy-dragged')) { + return; + } + + clearTimeout(this.displayTimeout); + this.displayTimeout = setTimeout(() => { + let panel = Debug.panels[link.rel]; + panel.focus(); + + if (panel.is(Panel.PEEK)) { + panel.init(); + + let pos = getPosition(panel.elem); + setPosition(panel.elem, { + left: getOffset(link).left + getPosition(link).width + 4 - pos.width, + top: this.isAtTop() + ? getOffset(this.elem).top + getPosition(this.elem).height + 4 + : getOffset(this.elem).top - pos.height - 4 + }); + panel.peekPosition = true; + } + }, 50); + }); + + link.addEventListener('mouseleave', () => { + clearTimeout(this.displayTimeout); + + if (link.rel && !elem.classList.contains('tracy-dragged')) { + Debug.panels[link.rel].blur(); + } + }); + }); + this.autoHideLabels(); + } + + + autoHideLabels() { + let width = getWindowSize().width; + this.elem.querySelectorAll('.tracy-row').forEach((row) => { + let i, labels = row.querySelectorAll('.tracy-label'); + for (i = 0; i < labels.length && row.clientWidth < width; i++) { + labels.item(i).hidden = false; + } + for (i = labels.length - 1; i >= 0 && row.clientWidth >= width; i--) { + labels.item(i).hidden = true; + } + }); + } + + + close() { + document.getElementById('tracy-debug').style.display = 'none'; + } + + + reposition(deltaX, deltaY) { + let pos = getPosition(this.elem); + if (pos.width) { // is visible? + setPosition(this.elem, {left: pos.left + (deltaX || 0), top: pos.top + (deltaY || 0)}); + this.savePosition(); + } + } + + + savePosition() { + let pos = getPosition(this.elem); + if (pos.width) { // is visible? + localStorage.setItem(this.id, JSON.stringify(this.isAtTop() ? {right: pos.right, top: pos.top} : {right: pos.right, bottom: pos.bottom})); + } + } + + + restorePosition() { + let pos = JSON.parse(localStorage.getItem(this.id)); + setPosition(this.elem, pos || {right: 0, bottom: 0}); + this.savePosition(); + } + + + isAtTop() { + let pos = getPosition(this.elem); + return pos.top < 100 && pos.bottom > pos.top; + } +} + + +class Debug +{ + static init(content) { + Debug.bar = new Bar; + Debug.panels = {}; + Debug.layer = document.createElement('div'); + Debug.layer.setAttribute('id', 'tracy-debug'); + Debug.layer.innerHTML = addNonces(content); + (document.body || document.documentElement).appendChild(Debug.layer); + evalScripts(Debug.layer); + Debug.layer.style.display = 'block'; + Debug.bar.init(); + + Debug.layer.querySelectorAll('.tracy-panel').forEach((panel) => { + Debug.panels[panel.id] = new Panel(panel.id); + Debug.panels[panel.id].restorePosition(); + }); + + Debug.captureWindow(); + Debug.captureAjax(); + + Tracy.TableSort.init(); + } + + + static loadAjax(content) { + let rows = Debug.bar.elem.querySelectorAll('.tracy-row[data-tracy-group=ajax]'); + rows = Array.from(rows).reverse(); + let max = maxAjaxRows; + rows.forEach((row) => { + if (--max > 0) { + return; + } + row.querySelectorAll('a[rel]').forEach((tab) => { + let panel = Debug.panels[tab.rel]; + if (panel.is(Panel.PEEK)) { + delete Debug.panels[tab.rel]; + panel.elem.remove(); + } + }); + row.remove(); + }); + + if (rows[0]) { // update content in first-row panels + rows[0].querySelectorAll('a[rel]').forEach((tab) => { + Debug.panels[tab.rel].savePosition(); + Debug.panels[tab.rel].toPeek(); + }); + } + + Debug.layer.insertAdjacentHTML('beforeend', content.panels); + evalScripts(Debug.layer); + Debug.bar.elem.insertAdjacentHTML('beforeend', content.bar); + let ajaxBar = Debug.bar.elem.querySelector('.tracy-row:last-child'); + + Debug.layer.querySelectorAll('.tracy-panel').forEach((panel) => { + if (!Debug.panels[panel.id]) { + Debug.panels[panel.id] = new Panel(panel.id); + Debug.panels[panel.id].restorePosition(); + } + }); + + Debug.bar.initTabs(ajaxBar); + } + + + static captureWindow() { + let size = getWindowSize(); + + window.addEventListener('resize', () => { + let newSize = getWindowSize(); + + Debug.bar.reposition(newSize.width - size.width, newSize.height - size.height); + Debug.bar.autoHideLabels(); + + for (let id in Debug.panels) { + Debug.panels[id].reposition(newSize.width - size.width, newSize.height - size.height); + } + + size = newSize; + }); + + window.addEventListener('unload', () => { + for (let id in Debug.panels) { + Debug.panels[id].savePosition(); + } + }); + } + + + static captureAjax() { + let header = Tracy.getAjaxHeader(); + if (!header) { + return; + } + let oldOpen = XMLHttpRequest.prototype.open; + + XMLHttpRequest.prototype.open = function() { + oldOpen.apply(this, arguments); + if (autoRefresh && new URL(arguments[1], location.origin).host === location.host) { + let reqId = header + '_' + ajaxCounter++; + this.setRequestHeader('X-Tracy-Ajax', reqId); + this.addEventListener('load', function() { + if (this.getAllResponseHeaders().match(/^X-Tracy-Ajax: 1/mi)) { + Debug.loadScript(baseUrl + '_tracy_bar=content-ajax.' + reqId + '&XDEBUG_SESSION_STOP=1&v=' + Math.random()); + } + }); + } + }; + + let oldFetch = window.fetch; + window.fetch = function(request, options) { + request = request instanceof Request ? request : new Request(request, options || {}); + + if (autoRefresh && new URL(request.url, location.origin).host === location.host) { + let reqId = header + '_' + ajaxCounter++; + request.headers.set('X-Tracy-Ajax', reqId); + return oldFetch(request).then((response) => { + if (response instanceof Response && response.headers.has('X-Tracy-Ajax') && response.headers.get('X-Tracy-Ajax')[0] === '1') { + Debug.loadScript(baseUrl + '_tracy_bar=content-ajax.' + reqId + '&XDEBUG_SESSION_STOP=1&v=' + Math.random()); + } + + return response; + }); + } + + return oldFetch(request); + }; + } + + + static loadScript(url) { + if (Debug.scriptElem) { + Debug.scriptElem.remove(); + } + Debug.scriptElem = document.createElement('script'); + Debug.scriptElem.src = url; + Debug.scriptElem.setAttribute('nonce', nonce); + (document.body || document.documentElement).appendChild(Debug.scriptElem); + } + + + static setOptions(options) { + maxAjaxRows = options.maxAjaxRows || maxAjaxRows; + autoRefresh = typeof options.autoRefresh !== 'undefined' ? options.autoRefresh : autoRefresh; + panelZIndex = options.panelZIndex || panelZIndex; + } +} + + +function evalScripts(elem) { + elem.querySelectorAll('script').forEach((script) => { + if ((!script.hasAttribute('type') || script.type === 'text/javascript' || script.type === 'application/javascript') && !script.tracyEvaluated) { + let document = script.ownerDocument; + let dolly = document.createElement('script'); + dolly.textContent = script.textContent; + dolly.setAttribute('nonce', nonce); + (document.body || document.documentElement).appendChild(dolly); + script.tracyEvaluated = true; + } + }); +} + + +let dragging; + +function draggable(elem, options) { + let dE = document.documentElement, started, deltaX, deltaY, clientX, clientY; + options = options || {}; + + let redraw = function () { + if (dragging) { + setPosition(elem, {left: clientX + deltaX, top: clientY + deltaY}); + requestAnimationFrame(redraw); + } + }; + + let onMove = function(e) { + if (e.buttons === 0) { + return onEnd(e); + } + if (!started) { + if (options.draggedClass) { + elem.classList.add(options.draggedClass); + } + if (options.start) { + options.start(e, elem); + } + started = true; + } + + clientX = e.touches ? e.touches[0].clientX : e.clientX; + clientY = e.touches ? e.touches[0].clientY : e.clientY; + return false; + }; + + let onEnd = function(e) { + if (started) { + if (options.draggedClass) { + elem.classList.remove(options.draggedClass); + } + if (options.stop) { + options.stop(e, elem); + } + } + dragging = null; + dE.removeEventListener('mousemove', onMove); + dE.removeEventListener('mouseup', onEnd); + dE.removeEventListener('touchmove', onMove); + dE.removeEventListener('touchend', onEnd); + return false; + }; + + let onStart = function(e) { + e.preventDefault(); + e.stopPropagation(); + + if (dragging) { // missed mouseup out of window? + return onEnd(e); + } + + let pos = getPosition(elem); + clientX = e.touches ? e.touches[0].clientX : e.clientX; + clientY = e.touches ? e.touches[0].clientY : e.clientY; + deltaX = pos.left - clientX; + deltaY = pos.top - clientY; + dragging = true; + started = false; + dE.addEventListener('mousemove', onMove); + dE.addEventListener('mouseup', onEnd); + dE.addEventListener('touchmove', onMove); + dE.addEventListener('touchend', onEnd); + requestAnimationFrame(redraw); + if (options.start) { + options.start(e, elem); + } + }; + + options.handles.forEach((handle) => { + handle.addEventListener('mousedown', onStart); + handle.addEventListener('touchstart', onStart); + + handle.addEventListener('click', (e) => { + if (started) { + e.stopImmediatePropagation(); + } + }); + }); +} + + +// returns total offset for element +function getOffset(elem) { + let res = {left: elem.offsetLeft, top: elem.offsetTop}; + while (elem = elem.offsetParent) { // eslint-disable-line no-cond-assign + res.left += elem.offsetLeft; res.top += elem.offsetTop; + } + return res; +} + + +function getWindowSize() { + return { + width: document.documentElement.clientWidth, + height: document.compatMode === 'BackCompat' ? window.innerHeight : document.documentElement.clientHeight + }; +} + + +// move to new position +function setPosition(elem, coords) { + let win = getWindowSize(); + if (typeof coords.right !== 'undefined') { + coords.left = win.width - elem.offsetWidth - coords.right; + } + if (typeof coords.bottom !== 'undefined') { + coords.top = win.height - elem.offsetHeight - coords.bottom; + } + elem.style.left = Math.max(0, Math.min(coords.left, win.width - elem.offsetWidth)) + 'px'; + elem.style.top = Math.max(0, Math.min(coords.top, win.height - elem.offsetHeight)) + 'px'; +} + + +// returns current position +function getPosition(elem) { + let win = getWindowSize(); + return { + left: elem.offsetLeft, + top: elem.offsetTop, + right: win.width - elem.offsetWidth - elem.offsetLeft, + bottom: win.height - elem.offsetHeight - elem.offsetTop, + width: elem.offsetWidth, + height: elem.offsetHeight + }; +} + + +function addNonces(html) { + let el = document.createElement('div'); + el.innerHTML = html; + el.querySelectorAll('style').forEach((style) => { + style.setAttribute('nonce', nonce); + }); + return el.innerHTML; +} + + +let Tracy = window.Tracy = window.Tracy || {}; +Tracy.DebugPanel = Panel; +Tracy.DebugBar = Bar; +Tracy.Debug = Debug; +Tracy.getAjaxHeader = () => contentId; + +Debug.setOptions({ + panelZIndex: Tracy.panelZIndex, + maxAjaxRows: window.TracyMaxAjaxRows, + autoRefresh: window.TracyAutoRefresh, +}); diff --git a/vendor/tracy/tracy/src/Tracy/Bar/assets/bar.phtml b/vendor/tracy/tracy/src/Tracy/Bar/assets/bar.phtml new file mode 100644 index 0000000..8fa3a86 --- /dev/null +++ b/vendor/tracy/tracy/src/Tracy/Bar/assets/bar.phtml @@ -0,0 +1,37 @@ +<?php + +/** + * Debug Bar template. + * + * This file is part of the Tracy (http://tracy.nette.org) + * Copyright (c) 2004 David Grudl (http://davidgrudl.com) + * + * @param string $type + * @param array $panels + */ + +declare(strict_types=1); + +namespace Tracy; + +?> + +<ul class="tracy-row" data-tracy-group="<?= Helpers::escapeHtml($type) ?>"> +<?php if ($type === 'main'): ?> + <li id="tracy-debug-logo" title="Tracy Debugger <?= Debugger::VERSION, " \nhttps://tracy.nette.org" ?>"> + <svg viewBox="0 -10 1561 333"><path fill="#585755" d="m176 327h-57v-269h-119v-57h291v57h-115v269zm208-191h114c50 0 47-78 0-78h-114v78zm106-135c17 0 33 2 46 7 75 30 75 144 1 175-13 6-29 8-47 8h-27l132 74v68l-211-128v122h-57v-326h163zm300 57c-5 0-9 3-11 9l-56 156h135l-55-155c-2-7-6-10-13-10zm-86 222l-17 47h-61l102-285c20-56 107-56 126 0l102 285h-61l-17-47h-174zm410 47c-98 0-148-55-148-163v-2c0-107 50-161 149-161h118v57h-133c-26 0-45 8-58 25-12 17-19 44-19 81 0 71 26 106 77 106h133v57h-119zm270-145l-121-181h68l81 130 81-130h68l-121 178v148h-56v-145z"/></svg> + </li> +<?php endif; if ($type === 'redirect'): ?> + <li><span title="Previous request before redirect">redirect</span></li> +<?php endif; if ($type === 'ajax'): ?> + <li>AJAX</li> +<?php endif ?> + +<?php foreach ($panels as $panel): if ($panel->tab) { ?> + <li><?php if ($panel->panel): ?><a href="#" rel="tracy-debug-panel-<?= $panel->id ?>"><?= trim($panel->tab) ?></a><?php else: echo '<span>', trim($panel->tab), '</span>'; endif ?></li> +<?php } endforeach ?> + +<?php if ($type === 'main'): ?> + <li><a href="#" data-tracy-action="close" title="close debug bar">×</a></li> +<?php endif ?> +</ul> diff --git a/vendor/tracy/tracy/src/Tracy/Bar/assets/loader.phtml b/vendor/tracy/tracy/src/Tracy/Bar/assets/loader.phtml new file mode 100644 index 0000000..335562a --- /dev/null +++ b/vendor/tracy/tracy/src/Tracy/Bar/assets/loader.phtml @@ -0,0 +1,33 @@ +<?php + +/** + * Debug Bar loader template. + * + * It uses Font Awesome by Dave Gandy - http://fontawesome.io + * + * This file is part of the Tracy (https://tracy.nette.org) + * Copyright (c) 2004 David Grudl (https://davidgrudl.com) + */ + +declare(strict_types=1); + +namespace Tracy; + +$baseUrl = $_SERVER['REQUEST_URI'] ?? ''; +$baseUrl .= strpos($baseUrl, '?') === false ? '?' : '&'; +$nonceAttr = $nonce ? ' nonce="' . Helpers::escapeHtml($nonce) . '"' : ''; +$asyncAttr = $async ? ' async' : ''; +?> +<?php if (empty($content)): ?> +<script src="<?= Helpers::escapeHtml($baseUrl) ?>_tracy_bar=<?= urlencode("content.$contentId") ?>&XDEBUG_SESSION_STOP=1" data-id="<?= Helpers::escapeHtml($contentId) ?>"<?= $asyncAttr, $nonceAttr ?>></script> +<?php else: ?> + + + + +<!-- Tracy Debug Bar --> +<script src="<?= Helpers::escapeHtml($baseUrl) ?>_tracy_bar=js&v=<?= urlencode(Debugger::VERSION) ?>&XDEBUG_SESSION_STOP=1" data-id="<?= Helpers::escapeHtml($contentId) ?>"<?= $nonceAttr ?>></script> +<script<?= $nonceAttr ?>> +Tracy.Debug.init(<?= str_replace(['<!--', '</s'], ['<\!--', '<\/s'], json_encode($content, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_INVALID_UTF8_SUBSTITUTE)) ?>); +</script> +<?php endif ?> diff --git a/vendor/tracy/tracy/src/Tracy/Bar/assets/panels.phtml b/vendor/tracy/tracy/src/Tracy/Bar/assets/panels.phtml new file mode 100644 index 0000000..6286425 --- /dev/null +++ b/vendor/tracy/tracy/src/Tracy/Bar/assets/panels.phtml @@ -0,0 +1,35 @@ +<?php + +/** + * Debug Bar panels template. + * + * This file is part of the Tracy (http://tracy.nette.org) + * Copyright (c) 2004 David Grudl (http://davidgrudl.com) + * + * @param string $type + * @param array $panels + */ + +declare(strict_types=1); + +namespace Tracy; + +use Tracy\Helpers; + +$icons = ' + <div class="tracy-icons"> + <a href="#" data-tracy-action="window" title="open in window">¤</a> + <a href="#" data-tracy-action="close" title="close window">×</a> + </div> +'; + +echo '<div itemscope>'; + +foreach ($panels as $panel) { + $content = $panel->panel ? ($panel->panel . "\n" . $icons) : ''; + $class = 'tracy-panel ' . ($type === 'ajax' ? '' : 'tracy-panel-persist') . ' tracy-panel-' . $type; ?> + <div class="<?= $class ?>" id="tracy-debug-panel-<?= $panel->id ?>" data-tracy-content='<?= str_replace(['&', "'"], ['&', '''], $content) ?>'></div><?php +} + +echo '<meta itemprop=tracy-snapshot content=', Dumper::formatSnapshotAttribute(Dumper::$liveSnapshot), '>'; +echo '</div>'; diff --git a/vendor/tracy/tracy/src/Tracy/Bar/panels/dumps.panel.phtml b/vendor/tracy/tracy/src/Tracy/Bar/panels/dumps.panel.phtml new file mode 100644 index 0000000..8f04738 --- /dev/null +++ b/vendor/tracy/tracy/src/Tracy/Bar/panels/dumps.panel.phtml @@ -0,0 +1,35 @@ +<?php + +/** + * Debug Bar: panel "dumps" template. + * + * This file is part of the Tracy (https://tracy.nette.org) + * Copyright (c) 2004 David Grudl (https://davidgrudl.com) + */ + +declare(strict_types=1); + +namespace Tracy; + +?> +<style class="tracy-debug"> + #tracy-debug .tracy-DumpPanel h2 { + font: 11pt/1.5 sans-serif; + margin: 0; + padding: 2px 8px; + background: #3484d2; + color: white; + } +</style> + +<h1>Dumps</h1> + +<div class="tracy-inner tracy-DumpPanel"> +<?php foreach ($data as $item): ?> + <?php if ($item['title']):?> + <h2><?= Helpers::escapeHtml($item['title']) ?></h2> + <?php endif ?> + + <?= $item['dump'] ?> +<?php endforeach ?> +</div> diff --git a/vendor/tracy/tracy/src/Tracy/Bar/panels/dumps.tab.phtml b/vendor/tracy/tracy/src/Tracy/Bar/panels/dumps.tab.phtml new file mode 100644 index 0000000..399a641 --- /dev/null +++ b/vendor/tracy/tracy/src/Tracy/Bar/panels/dumps.tab.phtml @@ -0,0 +1,19 @@ +<?php + +/** + * Debug Bar: tab "dumps" template. + * + * This file is part of the Tracy (https://tracy.nette.org) + * Copyright (c) 2004 David Grudl (https://davidgrudl.com) + */ + +declare(strict_types=1); + +namespace Tracy; + +if (empty($data)) { + return; +} +?> +<svg viewBox="0 0 2048 2048"><path fill="#154ABD" d="m1084 540c-110-1-228-2-325 58-54 35-87 94-126 143-94 162-71 383 59 519 83 94 207 151 333 149 132 3 261-60 344-160 122-138 139-355 44-511-73-66-133-158-234-183-31-9-65-9-95-14zm-60 116c73 0 53 115-16 97-105 5-195 102-192 207-2 78-122 48-95-23 8-153 151-285 304-280l-1-1zM1021 511"/><path fill="#4B6193" d="m1021 511c-284-2-560 131-746 344-53 64-118 125-145 206-16 86 59 152 103 217 219 267 575 428 921 377 312-44 600-241 755-515 39-81-30-156-74-217-145-187-355-327-581-384-77-19-156-29-234-28zm0 128c263-4 512 132 679 330 33 52 132 110 58 168-170 237-449 409-747 399-309 0-590-193-752-447 121-192 305-346 526-407 75-25 170-38 237-43z"/> +</svg><span class="tracy-label">dumps</span> diff --git a/vendor/tracy/tracy/src/Tracy/Bar/panels/errors.panel.phtml b/vendor/tracy/tracy/src/Tracy/Bar/panels/errors.panel.phtml new file mode 100644 index 0000000..3bc97a2 --- /dev/null +++ b/vendor/tracy/tracy/src/Tracy/Bar/panels/errors.panel.phtml @@ -0,0 +1,27 @@ +<?php + +/** + * Debug Bar: panel "error" template. + * + * This file is part of the Tracy (https://tracy.nette.org) + * Copyright (c) 2004 David Grudl (https://davidgrudl.com) + */ + +declare(strict_types=1); + +namespace Tracy; + +?> +<h1>Errors</h1> + +<div class="tracy-inner"> +<table class="tracy-sortable"> +<tr><th>Count</th><th>Error</th></tr> +<?php foreach ($data as $item => $count): list($file, $line, $message) = explode('|', $item, 3) ?> +<tr> + <td class="tracy-right"><?= $count ? "$count\xC3\x97" : '' ?></td> + <td><pre><?= Helpers::escapeHtml($message), ' in ', Helpers::editorLink($file, (int) $line) ?></pre></td> +</tr> +<?php endforeach ?> +</table> +</div> diff --git a/vendor/tracy/tracy/src/Tracy/Bar/panels/errors.tab.phtml b/vendor/tracy/tracy/src/Tracy/Bar/panels/errors.tab.phtml new file mode 100644 index 0000000..75a15b2 --- /dev/null +++ b/vendor/tracy/tracy/src/Tracy/Bar/panels/errors.tab.phtml @@ -0,0 +1,31 @@ +<?php + +/** + * Debug Bar: tab "error" template. + * + * This file is part of the Tracy (https://tracy.nette.org) + * Copyright (c) 2004 David Grudl (https://davidgrudl.com) + */ + +declare(strict_types=1); + +namespace Tracy; + +if (empty($data)) { + return; +} +?> +<style class="tracy-debug"> + #tracy-debug .tracy-ErrorTab { + display: block; + background: #D51616; + color: white; + font-weight: bold; + margin: -1px -.4em; + padding: 1px .4em; + } +</style> +<span class="tracy-ErrorTab"> +<svg viewBox="0 0 2048 2048"><path fill="#fff" d="M1152 1503v-190q0-14-9.5-23.5t-22.5-9.5h-192q-13 0-22.5 9.5t-9.5 23.5v190q0 14 9.5 23.5t22.5 9.5h192q13 0 22.5-9.5t9.5-23.5zm-2-374l18-459q0-12-10-19-13-11-24-11h-220q-11 0-24 11-10 7-10 21l17 457q0 10 10 16.5t24 6.5h185q14 0 23.5-6.5t10.5-16.5zm-14-934l768 1408q35 63-2 126-17 29-46.5 46t-63.5 17h-1536q-34 0-63.5-17t-46.5-46q-37-63-2-126l768-1408q17-31 47-49t65-18 65 18 47 49z"/> +</svg><span class="tracy-label"><?= $sum = array_sum($data), $sum > 1 ? ' errors' : ' error' ?></span> +</span> diff --git a/vendor/tracy/tracy/src/Tracy/Bar/panels/info.panel.phtml b/vendor/tracy/tracy/src/Tracy/Bar/panels/info.panel.phtml new file mode 100644 index 0000000..5735735 --- /dev/null +++ b/vendor/tracy/tracy/src/Tracy/Bar/panels/info.panel.phtml @@ -0,0 +1,129 @@ +<?php + +/** + * Debug Bar: panel "info" template. + * + * This file is part of the Tracy (https://tracy.nette.org) + * Copyright (c) 2004 David Grudl (https://davidgrudl.com) + */ + +declare(strict_types=1); + +namespace Tracy; + +if (isset($this->cpuUsage) && $this->time) { + foreach (getrusage() as $key => $val) { + $this->cpuUsage[$key] -= $val; + } + $userUsage = -round(($this->cpuUsage['ru_utime.tv_sec'] * 1e6 + $this->cpuUsage['ru_utime.tv_usec']) / $this->time / 10000); + $systemUsage = -round(($this->cpuUsage['ru_stime.tv_sec'] * 1e6 + $this->cpuUsage['ru_stime.tv_usec']) / $this->time / 10000); +} + +$countClasses = function (array $list): int { + return count(array_filter($list, function (string $name): bool { + return (new \ReflectionClass($name))->isUserDefined(); + })); +}; + +$ipFormatter = static function (?string $ip): ?string { + if ($ip === '127.0.0.1' || $ip === '::1') { + $ip .= ' (localhost)'; + } + return $ip; +}; + +$opcache = function_exists('opcache_get_status') ? @opcache_get_status() : null; // @ can be restricted +$cachedFiles = isset($opcache['scripts']) ? array_intersect(array_keys($opcache['scripts']), get_included_files()) : []; +$jit = $opcache['jit'] ?? null; + +$info = [ + 'Execution time' => number_format($this->time * 1000, 1, '.', ' ') . ' ms', + 'CPU usage user + system' => isset($userUsage) ? (int) $userUsage . ' % + ' . (int) $systemUsage . ' %' : null, + 'Peak of allocated memory' => number_format(memory_get_peak_usage() / 1000000, 2, '.', ' ') . ' MB', + 'Included files' => count(get_included_files()), + 'Classes + interfaces + traits' => $countClasses(get_declared_classes()) . ' + ' + . $countClasses(get_declared_interfaces()) . ' + ' . $countClasses(get_declared_traits()), + 'OPcache' => $opcache ? round(count($cachedFiles) * 100 / count(get_included_files())) . ' % cached' : '–', + 'JIT' => empty($jit['buffer_size']) ? '–' : round(($jit['buffer_size'] - $jit['buffer_free']) / $jit['buffer_size'] * 100) . ' % used', + 'Your IP' => $ipFormatter($_SERVER['REMOTE_ADDR'] ?? null), + 'Server IP' => $ipFormatter($_SERVER['SERVER_ADDR'] ?? null), + 'HTTP method / response code' => isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] . ' / ' . http_response_code() : null, + 'PHP' => PHP_VERSION, + 'Xdebug' => extension_loaded('xdebug') ? phpversion('xdebug') : null, + 'Tracy' => Debugger::VERSION, + 'Server' => $_SERVER['SERVER_SOFTWARE'] ?? null, +]; + +$info = array_map('strval', array_filter($info + (array) $this->data)); + +$packages = $devPackages = []; +if (class_exists('Composer\Autoload\ClassLoader', false)) { + $baseDir = (function () { + @include dirname((new \ReflectionClass('Composer\Autoload\ClassLoader'))->getFileName()) . '/autoload_psr4.php'; // @ may not exist + return $baseDir; + })(); + $composer = @json_decode((string) file_get_contents($baseDir . '/composer.lock')); // @ may not exist or be valid + list($packages, $devPackages) = [(array) @$composer->packages, (array) @$composer->{'packages-dev'}]; // @ keys may not exist + foreach ([&$packages, &$devPackages] as &$items) { + array_walk($items, function($package) { + $package->hash = $package->source->reference ?? $package->dist->reference ?? null; + }, $items); + usort($items, function ($a, $b): int { return $a->name <=> $b->name; }); + } +} + +?> +<style class="tracy-debug"> + #tracy-debug .tracy-InfoPanel td { + white-space: nowrap; + } + #tracy-debug .tracy-InfoPanel td:nth-child(2) { + font-weight: bold; + width: 30%; + } + #tracy-debug .tracy-InfoPanel td[colspan='2'] b { + float: right; + margin-left: 2em; + } +</style> + +<h1>System info</h1> + +<div class="tracy-inner tracy-InfoPanel"> +<div class="tracy-inner-container"> +<table class="tracy-sortable"> +<?php foreach ($info as $key => $val): ?> +<tr> +<?php if (strlen($val) > 25): ?> + <td colspan=2><?= Helpers::escapeHtml($key) ?> <b><?= Helpers::escapeHtml($val) ?></b></td> +<?php else: ?> + <td><?= Helpers::escapeHtml($key) ?></td><td><?= Helpers::escapeHtml($val) ?></td> +<?php endif ?> +</tr> +<?php endforeach ?> +</table> + +<?php if ($packages || $devPackages): ?> + <h2><a class="tracy-toggle tracy-collapsed" data-tracy-ref="^div .tracy-InfoPanel-packages">Composer Packages (<?= count($packages), $devPackages ? ' + ' . count($devPackages) . ' dev' : '' ?>)</a></h2> + + <div class="tracy-InfoPanel-packages tracy-collapsed"> + <?php if ($packages): ?> + <table class="tracy-sortable"> + <?php foreach ($packages as $package): ?> + <tr><td><?= Helpers::escapeHtml($package->name) ?></td><td><?= Helpers::escapeHtml($package->version . (strpos($package->version, 'dev') !== false && $package->hash ? ' #' . substr($package->hash, 0, 4) : '')) ?></td></tr> + <?php endforeach ?> + </table> + <?php endif ?> + + <?php if ($devPackages): ?> + <h2>Dev Packages</h2> + <table class="tracy-sortable"> + <?php foreach ($devPackages as $package): ?> + <tr><td><?= Helpers::escapeHtml($package->name) ?></td><td><?= Helpers::escapeHtml($package->version . (strpos($package->version, 'dev') !== false && $package->hash ? ' #' . substr($package->hash, 0, 4) : '')) ?></td></tr> + <?php endforeach ?> + </table> + <?php endif ?> + </div> +<?php endif ?> +</div> +</div> diff --git a/vendor/tracy/tracy/src/Tracy/Bar/panels/info.tab.phtml b/vendor/tracy/tracy/src/Tracy/Bar/panels/info.tab.phtml new file mode 100644 index 0000000..19926b7 --- /dev/null +++ b/vendor/tracy/tracy/src/Tracy/Bar/panels/info.tab.phtml @@ -0,0 +1,20 @@ +<?php + +/** + * Debug Bar: tab "info" template. + * + * This file is part of the Tracy (https://tracy.nette.org) + * Copyright (c) 2004 David Grudl (https://davidgrudl.com) + */ + +declare(strict_types=1); + +namespace Tracy; + +$this->time = microtime(true) - Debugger::$time; + +?> +<span title="Execution time"> +<svg viewBox="0 0 2048 2048"><path fill="#86bbf0" d="m640 1153.6v639.3h-256v-639.3z"/><path fill="#6ba9e6" d="m1024 254.68v1538.2h-256v-1538.2z"/><path fill="#4f96dc" d="m1408 897.57v894.3h-256v-894.3z"/><path fill="#3987d4" d="m1792 513.08v1279.8h-256v-1279.8z"/> +</svg><span class="tracy-label"><?= number_format($this->time * 1000, 1, '.', ' ') ?> ms</span> +</span> diff --git a/vendor/tracy/tracy/src/Tracy/BlueScreen/BlueScreen.php b/vendor/tracy/tracy/src/Tracy/BlueScreen/BlueScreen.php new file mode 100644 index 0000000..6567e52 --- /dev/null +++ b/vendor/tracy/tracy/src/Tracy/BlueScreen/BlueScreen.php @@ -0,0 +1,470 @@ +<?php + +/** + * This file is part of the Tracy (https://tracy.nette.org) + * Copyright (c) 2004 David Grudl (https://davidgrudl.com) + */ + +declare(strict_types=1); + +namespace Tracy; + + +/** + * Red BlueScreen. + */ +class BlueScreen +{ + private const MAX_MESSAGE_LENGTH = 2000; + + /** @var string[] */ + public $info = []; + + /** @var string[] paths to be collapsed in stack trace (e.g. core libraries) */ + public $collapsePaths = []; + + /** @var int */ + public $maxDepth = 5; + + /** @var int */ + public $maxLength = 150; + + /** @var callable|null a callable returning true for sensitive data; fn(string $key, mixed $val): bool */ + public $scrubber; + + /** @var string[] */ + public $keysToHide = ['password', 'passwd', 'pass', 'pwd', 'creditcard', 'credit card', 'cc', 'pin', self::class . '::$snapshot']; + + /** @var bool */ + public $showEnvironment = false; + + /** @var callable[] */ + private $panels = []; + + /** @var callable[] functions that returns action for exceptions */ + private $actions = []; + + /** @var array */ + private $snapshot; + + + public function __construct() + { + $this->collapsePaths = preg_match('#(.+/vendor)/tracy/tracy/src/Tracy/BlueScreen$#', strtr(__DIR__, '\\', '/'), $m) + ? [$m[1] . '/tracy', $m[1] . '/nette', $m[1] . '/latte'] + : [dirname(__DIR__)]; + } + + + /** + * Add custom panel as function (?\Throwable $e): ?array + * @return static + */ + public function addPanel(callable $panel): self + { + if (!in_array($panel, $this->panels, true)) { + $this->panels[] = $panel; + } + return $this; + } + + + /** + * Add action. + * @return static + */ + public function addAction(callable $action): self + { + $this->actions[] = $action; + return $this; + } + + + /** + * Renders blue screen. + */ + public function render(\Throwable $exception): void + { + if (Helpers::isAjax() && session_status() === PHP_SESSION_ACTIVE) { + $_SESSION['_tracy']['bluescreen'][$_SERVER['HTTP_X_TRACY_AJAX']] = [ + 'content' => Helpers::capture(function () use ($exception) { + $this->renderTemplate($exception, __DIR__ . '/assets/content.phtml'); + }), + 'time' => time(), + ]; + + } else { + if (!headers_sent()) { + header('Content-Type: text/html; charset=UTF-8'); + } + $this->renderTemplate($exception, __DIR__ . '/assets/page.phtml'); + } + } + + + /** + * Renders blue screen to file (if file exists, it will not be overwritten). + */ + public function renderToFile(\Throwable $exception, string $file): bool + { + if ($handle = @fopen($file, 'x')) { + ob_start(); // double buffer prevents sending HTTP headers in some PHP + ob_start(function ($buffer) use ($handle): void { fwrite($handle, $buffer); }, 4096); + $this->renderTemplate($exception, __DIR__ . '/assets/page.phtml', false); + ob_end_flush(); + ob_end_clean(); + fclose($handle); + return true; + } + return false; + } + + + private function renderTemplate(\Throwable $exception, string $template, $toScreen = true): void + { + $showEnvironment = $this->showEnvironment && (strpos($exception->getMessage(), 'Allowed memory size') === false); + $info = array_filter($this->info); + $source = Helpers::getSource(); + $title = $exception instanceof \ErrorException + ? Helpers::errorTypeToString($exception->getSeverity()) + : Helpers::getClass($exception); + $lastError = $exception instanceof \ErrorException || $exception instanceof \Error + ? null + : error_get_last(); + + if (function_exists('apache_request_headers')) { + $httpHeaders = apache_request_headers(); + } else { + $httpHeaders = array_filter($_SERVER, function ($k) { return strncmp($k, 'HTTP_', 5) === 0; }, ARRAY_FILTER_USE_KEY); + $httpHeaders = array_combine(array_map(function ($k) { return strtolower(strtr(substr($k, 5), '_', '-')); }, array_keys($httpHeaders)), $httpHeaders); + } + + $snapshot = &$this->snapshot; + $snapshot = []; + $dump = $this->getDumper(); + + $css = array_map('file_get_contents', array_merge([ + __DIR__ . '/assets/bluescreen.css', + __DIR__ . '/../Toggle/toggle.css', + __DIR__ . '/../TableSort/table-sort.css', + __DIR__ . '/../Dumper/assets/dumper-light.css', + ], Debugger::$customCssFiles)); + $css = Helpers::minifyCss(implode($css)); + + $nonce = $toScreen ? Helpers::getNonce() : null; + $actions = $toScreen ? $this->renderActions($exception) : []; + + require $template; + } + + + /** + * @return \stdClass[] + */ + private function renderPanels(?\Throwable $ex): array + { + $obLevel = ob_get_level(); + $res = []; + foreach ($this->panels as $callback) { + try { + $panel = $callback($ex); + if (empty($panel['tab']) || empty($panel['panel'])) { + continue; + } + $res[] = (object) $panel; + continue; + } catch (\Throwable $e) { + } + while (ob_get_level() > $obLevel) { // restore ob-level if broken + ob_end_clean(); + } + is_callable($callback, true, $name); + $res[] = (object) [ + 'tab' => "Error in panel $name", + 'panel' => nl2br(Helpers::escapeHtml($e)), + ]; + } + return $res; + } + + + /** + * @return array[] + */ + private function renderActions(\Throwable $ex): array + { + $actions = []; + foreach ($this->actions as $callback) { + $action = $callback($ex); + if (!empty($action['link']) && !empty($action['label'])) { + $actions[] = $action; + } + } + + if ( + property_exists($ex, 'tracyAction') + && !empty($ex->tracyAction['link']) + && !empty($ex->tracyAction['label']) + ) { + $actions[] = $ex->tracyAction; + } + + if (preg_match('# ([\'"])(\w{3,}(?:\\\\\w{3,})+)\1#i', $ex->getMessage(), $m)) { + $class = $m[2]; + if ( + !class_exists($class, false) && !interface_exists($class, false) && !trait_exists($class, false) + && ($file = Helpers::guessClassFile($class)) && !is_file($file) + ) { + $actions[] = [ + 'link' => Helpers::editorUri($file, 1, 'create'), + 'label' => 'create class', + ]; + } + } + + if (preg_match('# ([\'"])((?:/|[a-z]:[/\\\\])\w[^\'"]+\.\w{2,5})\1#i', $ex->getMessage(), $m)) { + $file = $m[2]; + $actions[] = [ + 'link' => Helpers::editorUri($file, 1, $label = is_file($file) ? 'open' : 'create'), + 'label' => $label . ' file', + ]; + } + + $query = ($ex instanceof \ErrorException ? '' : Helpers::getClass($ex) . ' ') + . preg_replace('#\'.*\'|".*"#Us', '', $ex->getMessage()); + $actions[] = [ + 'link' => 'https://www.google.com/search?sourceid=tracy&q=' . urlencode($query), + 'label' => 'search', + 'external' => true, + ]; + + if ( + $ex instanceof \ErrorException + && !empty($ex->skippable) + && preg_match('#^https?://#', $source = Helpers::getSource()) + ) { + $actions[] = [ + 'link' => $source . (strpos($source, '?') ? '&' : '?') . '_tracy_skip_error', + 'label' => 'skip error', + ]; + } + return $actions; + } + + + /** + * Returns syntax highlighted source code. + */ + public static function highlightFile(string $file, int $line, int $lines = 15): ?string + { + $source = @file_get_contents($file); // @ file may not exist + if ($source === false) { + return null; + } + $source = static::highlightPhp($source, $line, $lines); + if ($editor = Helpers::editorUri($file, $line)) { + $source = substr_replace($source, ' title="Ctrl-Click to open in editor" data-tracy-href="' . Helpers::escapeHtml($editor) . '"', 4, 0); + } + return $source; + } + + + /** + * Returns syntax highlighted source code. + */ + public static function highlightPhp(string $source, int $line, int $lines = 15): string + { + if (function_exists('ini_set')) { + ini_set('highlight.comment', '#998; font-style: italic'); + ini_set('highlight.default', '#000'); + ini_set('highlight.html', '#06B'); + ini_set('highlight.keyword', '#D24; font-weight: bold'); + ini_set('highlight.string', '#080'); + } + + $source = preg_replace('#(__halt_compiler\s*\(\)\s*;).*#is', '$1', $source); + $source = str_replace(["\r\n", "\r"], "\n", $source); + $source = explode("\n", highlight_string($source, true)); + $out = $source[0]; // <code><span color=highlight.html> + $source = str_replace('<br />', "\n", $source[1]); + $out .= static::highlightLine($source, $line, $lines); + $out = str_replace(' ', ' ', $out); + return "<pre class='code'><div>$out</div></pre>"; + } + + + /** + * Returns highlighted line in HTML code. + */ + public static function highlightLine(string $html, int $line, int $lines = 15): string + { + $source = explode("\n", "\n" . str_replace("\r\n", "\n", $html)); + $out = ''; + $spans = 1; + $start = $i = max(1, min($line, count($source) - 1) - (int) floor($lines * 2 / 3)); + while (--$i >= 1) { // find last highlighted block + if (preg_match('#.*(</?span[^>]*>)#', $source[$i], $m)) { + if ($m[1] !== '</span>') { + $spans++; + $out .= $m[1]; + } + break; + } + } + + $source = array_slice($source, $start, $lines, true); + end($source); + $numWidth = strlen((string) key($source)); + + foreach ($source as $n => $s) { + $spans += substr_count($s, '<span') - substr_count($s, '</span'); + $s = str_replace(["\r", "\n"], ['', ''], $s); + preg_match_all('#<[^>]+>#', $s, $tags); + if ($n == $line) { + $out .= sprintf( + "<span class='highlight'>%{$numWidth}s: %s\n</span>%s", + $n, + strip_tags($s), + implode('', $tags[0]) + ); + } else { + $out .= sprintf("<span class='line'>%{$numWidth}s:</span> %s\n", $n, $s); + } + } + $out .= str_repeat('</span>', $spans) . '</code>'; + return $out; + } + + + /** + * Returns syntax highlighted source code to Terminal. + */ + public static function highlightPhpCli(string $file, int $line, int $lines = 15): string + { + $source = @file_get_contents($file); // @ file may not exist + if ($source === false) { + return null; + } + $s = self::highlightPhp($source, $line, $lines); + + $colors = [ + 'color: ' . ini_get('highlight.comment') => '1;30', + 'color: ' . ini_get('highlight.default') => '1;36', + 'color: ' . ini_get('highlight.html') => '1;35', + 'color: ' . ini_get('highlight.keyword') => '1;37', + 'color: ' . ini_get('highlight.string') => '1;32', + 'line' => '1;30', + 'highlight' => "1;37m\e[41", + ]; + + $stack = ['0']; + $s = preg_replace_callback( + '#<\w+(?: (class|style)=["\'](.*?)["\'])?[^>]*>|</\w+>#', + function ($m) use ($colors, &$stack): string { + if ($m[0][1] === '/') { + array_pop($stack); + } else { + $stack[] = isset($m[2], $colors[$m[2]]) ? $colors[$m[2]] : '0'; + } + return "\e[0m\e[" . end($stack) . 'm'; + }, + $s + ); + $s = htmlspecialchars_decode(strip_tags($s), ENT_QUOTES | ENT_HTML5); + return $s; + } + + + /** + * Should a file be collapsed in stack trace? + * @internal + */ + public function isCollapsed(string $file): bool + { + $file = strtr($file, '\\', '/') . '/'; + foreach ($this->collapsePaths as $path) { + $path = strtr($path, '\\', '/') . '/'; + if (strncmp($file, $path, strlen($path)) === 0) { + return true; + } + } + return false; + } + + + /** @internal */ + public function getDumper(): \Closure + { + return function ($v, $k = null): string { + return Dumper::toHtml($v, [ + Dumper::DEPTH => $this->maxDepth, + Dumper::TRUNCATE => $this->maxLength, + Dumper::SNAPSHOT => &$this->snapshot, + Dumper::LOCATION => Dumper::LOCATION_CLASS, + Dumper::SCRUBBER => $this->scrubber, + Dumper::KEYS_TO_HIDE => $this->keysToHide, + ], $k); + }; + } + + + public function formatMessage(\Throwable $exception): string + { + $msg = Helpers::encodeString(trim((string) $exception->getMessage()), self::MAX_MESSAGE_LENGTH, false); + + // highlight 'string' + $msg = preg_replace( + '#\'\S(?:[^\']|\\\\\')*\S\'|"\S(?:[^"]|\\\\")*\S"#', + '<i>$0</i>', + $msg + ); + + // clickable class & methods + $msg = preg_replace_callback( + '#(\w+\\\\[\w\\\\]+\w)(?:::(\w+))?#', + function ($m) { + if (isset($m[2]) && method_exists($m[1], $m[2])) { + $r = new \ReflectionMethod($m[1], $m[2]); + } elseif (class_exists($m[1], false) || interface_exists($m[1], false)) { + $r = new \ReflectionClass($m[1]); + } + if (empty($r) || !$r->getFileName()) { + return $m[0]; + } + return '<a href="' . Helpers::escapeHtml(Helpers::editorUri($r->getFileName(), $r->getStartLine())) . '" class="tracy-editor">' . $m[0] . '</a>'; + }, + $msg + ); + + // clickable file name + $msg = preg_replace_callback( + '#([\w\\\\/.:-]+\.(?:php|phpt|phtml|latte|neon))(?|:(\d+)| on line (\d+))?#', + function ($m) { + return @is_file($m[1]) + ? '<a href="' . Helpers::escapeHtml(Helpers::editorUri($m[1], isset($m[2]) ? (int) $m[2] : null)) . '" class="tracy-editor">' . $m[0] . '</a>' + : $m[0]; + }, + $msg + ); + + return $msg; + } + + + private function renderPhpInfo(): void + { + ob_start(); + @phpinfo(INFO_LICENSE); // @ phpinfo may be disabled + $license = ob_get_clean(); + ob_start(); + @phpinfo(INFO_CONFIGURATION | INFO_MODULES); // @ phpinfo may be disabled + $info = ob_get_clean(); + + if (strpos($license, '<body') === false) { + echo '<pre class="tracy-dump tracy-light">', Helpers::escapeHtml($info), '</pre>'; + } else { + $info = str_replace('<table', '<table class="tracy-sortable"', $info); + echo preg_replace('#^.+<body>|</body>.+\z#s', '', $info); + } + } +} diff --git a/vendor/tracy/tracy/src/Tracy/BlueScreen/assets/bluescreen.css b/vendor/tracy/tracy/src/Tracy/BlueScreen/assets/bluescreen.css new file mode 100644 index 0000000..b142a49 --- /dev/null +++ b/vendor/tracy/tracy/src/Tracy/BlueScreen/assets/bluescreen.css @@ -0,0 +1,290 @@ +/** + * This file is part of the Tracy (https://tracy.nette.org) + */ + +#tracy-bs { + font: 9pt/1.5 Verdana, sans-serif; + background: white; + color: #333; + position: absolute; + z-index: 20000; + left: 0; + top: 0; + width: 100%; + text-align: left; +} + +#tracy-bs a { + text-decoration: none; + color: #328ADC; + padding: 2px 4px; + margin: -2px -4px; +} + +#tracy-bs a + a { + margin-left: 0; +} + +#tracy-bs a:hover, +#tracy-bs a:focus { + color: #085AA3; +} + +#tracy-bs-toggle { + position: absolute; + right: .5em; + top: .5em; + text-decoration: none; + background: #CD1818; + color: white !important; + padding: 3px; +} + +.tracy-bs-main { + display: flex; + flex-direction: column; + min-height: 100vh; +} + +.tracy-bs-main.tracy-collapsed { + display: none; +} + +#tracy-bs div.panel:last-of-type { + flex: 1; +} + +#tracy-bs-error { + background: #CD1818; + color: white; + font-size: 13pt; +} + +#tracy-bs-error::selection, +#tracy-bs-error ::selection { + color: black !important; + background: #FDF5CE !important; +} + +#tracy-bs-error a { + color: #ffefa1 !important; +} + +#tracy-bs-error span span { + font-size: 80%; + color: rgba(255, 255, 255, 0.5); + text-shadow: none; +} + +#tracy-bs-error a.action { + color: white !important; + opacity: 0; + font-size: .7em; + border-bottom: none !important; +} + +#tracy-bs-error:hover a.action { + opacity: .6; +} + +#tracy-bs-error a.action:hover { + opacity: 1; +} + +#tracy-bs-error i { + color: #ffefa1; + font-style: normal; +} + +#tracy-bs h1 { + font-size: 15pt; + font-weight: normal; + text-shadow: 1px 1px 2px rgba(0, 0, 0, .3); + margin: .7em 0; +} + +#tracy-bs h1 span { + white-space: pre-wrap; +} + +#tracy-bs h2 { + font-size: 14pt; + font-weight: normal; + margin: .6em 0; +} + +#tracy-bs h3 { + font-size: 10pt; + font-weight: bold; + margin: 1em 0; + padding: 0; +} + +#tracy-bs p, +#tracy-bs pre { + margin: .8em 0 +} + +#tracy-bs pre, +#tracy-bs code, +#tracy-bs table { + font: 9pt/1.5 Consolas, monospace !important; +} + +#tracy-bs pre, +#tracy-bs table { + background: #FDF5CE; + padding: .4em .7em; + border: 1px dotted silver; + overflow: auto; +} + +#tracy-bs table pre { + padding: 0; + margin: 0; + border: none; +} + +#tracy-bs table { + border-collapse: collapse; + width: 100%; + margin-bottom: 1em; +} + +#tracy-bs td, +#tracy-bs th { + vertical-align: top; + text-align: left; + padding: 2px 6px; + border: 1px solid #e6dfbf; +} + +#tracy-bs th { + font-weight: bold; +} + +#tracy-bs tr > :first-child { + width: 20%; +} + +#tracy-bs tr:nth-child(2n), +#tracy-bs tr:nth-child(2n) pre { + background-color: #F7F0CB; +} + +#tracy-bs ol { + margin: 1em 0; + padding-left: 2.5em; +} + +#tracy-bs ul { + font-size: 7pt; + padding: 2em 3em; + margin: 1em 0 0; + color: #777; + background: #F6F5F3; + border-top: 1px solid #DDD; + list-style: none; +} + +#tracy-bs .footer-logo a { + position: absolute; + bottom: 0; + right: 0; + width: 100px; + height: 50px; + background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFoAAAAUBAMAAAD/1DctAAAAMFBMVEWupZzj39rEvbTy8O3X0sz9/PvGwLu8tavQysHq6OS0rKP5+Pbd2dT29fPMxbzPx8DKErMJAAAACXBIWXMAAAsTAAALEwEAmpwYAAACGUlEQVQoFX3TQWgTQRQA0MWLIJJDYehBTykhG5ERTx56K1u8eEhCYtomE7x5L4iLh0ViF7egewuFFqSIYE6hIHsIYQ6CQSg9CDKn4QsNCRlB59C74J/ZNHW1+An5+bOPyf6/s46oz2P+A0yIeZZ2ieEHi6TOnLKTxvWq+b52mxlVO3xnM1s7xLX1504XQH65OnW2dBqn7cCkYsFsfYsWpyY/2salmFTpEyzeR8zosYqMdiPDXdyU52K1wgEa/SjGpdEwUAxqvRfckQCDOyFearsEHe2grvkh/cFAHKvdtI3lcVceKQIOFpv+FOZaNPQBwJZLPp+hfrvT5JZXaUFsR8zqQc9qSgAharkfS5M/5F6nGJJAtXq/eLr3ucZpHccSxOOIPaQhtHohpCH2Xu6rLmQ0djnr4/+J3C6v+AW8/XWYxwYNdlhWj/P5fPSTQwVr0T9lGxdaBCqErNZaqYnEwbkjEB3NasGF3lPdrHa1nnxNOMgj0+neePUPjd2v/qVvUv29ifvc19huQ48qwXShy/9o8o3OSk0cs37mOFd0Ydgvsf/oZEnPVtggfd66lORn9mDyyzXU13SRtH2L6aR5T/snGAcZPfAXz5J1YlJWBEuxdMYqQecpBrlM49xAbmqyHA+xlA1FxBtqT2xmJoNXZlIt74ZBLeJ9ZGDqByNI7p543idzJ23vXEv7IgnsxiS+eNtwNbFdLq7+Bi4wQ0I4SVb9AAAAAElFTkSuQmCC') no-repeat; + opacity: .6; + padding: 0; + margin: 0; +} + +#tracy-bs .footer-logo a:hover, +#tracy-bs .footer-logo a:focus { + opacity: 1; + transition: opacity 0.1s; +} + + +#tracy-bs div.panel { + padding: 1px 25px; +} + +#tracy-bs div.inner { + background: #F4F3F1; + padding: .1em 1em 1em; + border-radius: 8px; +} + +#tracy-bs .outer { + overflow: auto; +} + +#tracy-bs.mac .outer { + padding-bottom: 12px; +} + + +/* source code */ +#tracy-bs pre.code > div { + min-width: 100%; + float: left; + white-space: pre; +} + +#tracy-bs .highlight { + background: #CD1818; + color: white; + font-weight: bold; + font-style: normal; + display: block; + padding: 0 .4em; + margin: 0 -.4em; +} + +#tracy-bs .line { + color: #9F9C7F; + font-weight: normal; + font-style: normal; +} + +#tracy-bs a.tracy-editor { + color: inherit; + border-bottom: 1px dotted rgba(0, 0, 0, .3); + border-radius: 3px; +} + +#tracy-bs a.tracy-editor:hover { + background: #0001; +} + +#tracy-bs span[data-tracy-href] { + border-bottom: 1px dotted rgba(0, 0, 0, .3); +} + +#tracy-bs .tracy-dump-whitespace { + color: #0003; +} + +#tracy-bs .caused { + float: right; + padding: .3em .6em; + background: #df8075; + border-radius: 0 0 0 8px; + white-space: nowrap; +} + +#tracy-bs .caused a { + color: white; +} + +#tracy-bs .args tr:first-child > * { + position: relative; +} + +#tracy-bs .args tr:first-child td:before { + position: absolute; + right: .3em; + content: 'may not be true'; + opacity: .4; +} diff --git a/vendor/tracy/tracy/src/Tracy/BlueScreen/assets/bluescreen.js b/vendor/tracy/tracy/src/Tracy/BlueScreen/assets/bluescreen.js new file mode 100644 index 0000000..577c605 --- /dev/null +++ b/vendor/tracy/tracy/src/Tracy/BlueScreen/assets/bluescreen.js @@ -0,0 +1,71 @@ +/** + * This file is part of the Tracy (https://tracy.nette.org) + */ + +class BlueScreen +{ + static init(ajax) { + let blueScreen = document.getElementById('tracy-bs'); + let styles = []; + + for (let i = 0; i < document.styleSheets.length; i++) { + let style = document.styleSheets[i]; + if (!style.ownerNode.classList.contains('tracy-debug')) { + style.oldDisabled = style.disabled; + style.disabled = true; + styles.push(style); + } + } + + if (navigator.platform.indexOf('Mac') > -1) { + blueScreen.classList.add('mac'); + } + + document.getElementById('tracy-bs-toggle').addEventListener('tracy-toggle', function() { + let collapsed = this.classList.contains('tracy-collapsed'); + for (let i = 0; i < styles.length; i++) { + styles[i].disabled = collapsed ? styles[i].oldDisabled : true; + } + }); + + if (!ajax) { + document.body.appendChild(blueScreen); + let id = location.href + document.getElementById('tracy-bs-error').textContent; + Tracy.Toggle.persist(blueScreen, sessionStorage.getItem('tracy-toggles-bskey') === id); + sessionStorage.setItem('tracy-toggles-bskey', id); + } + + if (inited) { + return; + } + inited = true; + + // enables toggling via ESC + document.addEventListener('keyup', (e) => { + if (e.keyCode === 27 && !e.shiftKey && !e.altKey && !e.ctrlKey && !e.metaKey) { // ESC + Tracy.Toggle.toggle(document.getElementById('tracy-bs-toggle')); + } + }); + + Tracy.TableSort.init(); + } + + + static loadAjax(content) { + let ajaxBs = document.getElementById('tracy-bs'); + if (ajaxBs) { + ajaxBs.remove(); + } + document.body.insertAdjacentHTML('beforeend', content); + ajaxBs = document.getElementById('tracy-bs'); + Tracy.Dumper.init(ajaxBs); + BlueScreen.init(true); + window.scrollTo(0, 0); + } +} + +let inited; + + +let Tracy = window.Tracy = window.Tracy || {}; +Tracy.BlueScreen = Tracy.BlueScreen || BlueScreen; diff --git a/vendor/tracy/tracy/src/Tracy/BlueScreen/assets/content.phtml b/vendor/tracy/tracy/src/Tracy/BlueScreen/assets/content.phtml new file mode 100644 index 0000000..31b505c --- /dev/null +++ b/vendor/tracy/tracy/src/Tracy/BlueScreen/assets/content.phtml @@ -0,0 +1,364 @@ +<?php + +/** + * Debugger bluescreen template. + * + * This file is part of the Tracy (https://tracy.nette.org) + * Copyright (c) 2004 David Grudl (https://davidgrudl.com) + * + * @param array $exception + * @param array[] $actions + * @param array $info + * @param string $title + * @param string $source + * @param array $lastError + * @param array $httpHeaders + * @param callable $dump + * @return void + */ + +declare(strict_types=1); + +namespace Tracy; + +$code = $exception->getCode() ? ' #' . $exception->getCode() : ''; +$exceptions = $exceptions ?? Helpers::getExceptionChain($exception); + +?> +<div id="tracy-bs" itemscope> + <a id="tracy-bs-toggle" href="#" class="tracy-toggle"></a> + <div class="tracy-bs-main"> + <div id="tracy-bs-error" class="panel"> + <?php if ($exception->getMessage()): ?><p><?= Helpers::escapeHtml($title . $code) ?></p><?php endif ?> + + + <h1><span><?= $this->formatMessage($exception) ?: Helpers::escapeHtml($title . $code) ?></span> + <?php foreach ($actions as $item): ?> + <a href="<?= Helpers::escapeHtml($item['link']) ?>" class="action"<?= empty($item['external']) ? '' : ' target="_blank" rel="noreferrer noopener"'?>><?= Helpers::escapeHtml($item['label']) ?>►</a> + <?php endforeach ?></h1> + </div> + + <?php if (count($exceptions) > 1): ?> + <div class="caused"> + <a href="#tracyCaused">Caused by <?= Helpers::escapeHtml(Helpers::getClass($exceptions[1])) ?></a> + </div> + <?php endif ?> + + + <?php foreach ($exceptions as $level => $ex): ?> + + <?php if ($level): ?> + <div class="panel"<?php if ($level === 1) echo ' id="tracyCaused"' ?>> + <h2><a data-tracy-ref="^+" class="tracy-toggle<?= ($collapsed = $level > 1) ? ' tracy-collapsed' : '' ?>">Caused by</a></h2> + + <div class="<?= $collapsed ? 'tracy-collapsed ' : '' ?>inner"> + <div class="panel"> + <h2><?= Helpers::escapeHtml(Helpers::getClass($ex) . ($ex->getCode() ? ' #' . $ex->getCode() : '')) ?></h2> + + <h2><?= $this->formatMessage($ex) ?></h2> + </div> + <?php endif ?> + + + <?php foreach ($this->renderPanels($ex) as $panel): ?> + <div class="panel"> + <h2><a data-tracy-ref="^+" class="tracy-toggle"><?= Helpers::escapeHtml($panel->tab) ?></a></h2> + + <div class="inner"> + <?= $panel->panel ?> + </div></div> + <?php endforeach ?> + + + <?php $stack = $ex->getTrace(); $expanded = null ?> + <?php if ((!$exception instanceof \ErrorException || in_array($exception->getSeverity(), [E_USER_NOTICE, E_USER_WARNING, E_USER_DEPRECATED], true)) && $this->isCollapsed($ex->getFile())) { + foreach ($stack as $key => $row) { + if (isset($row['file']) && !$this->isCollapsed($row['file'])) { $expanded = $key; break; } + } + } ?> + + <div class="panel"> + <h2><a data-tracy-ref="^+" class="tracy-toggle<?= ($collapsed = $expanded !== null) ? ' tracy-collapsed' : '' ?>">Source file</a></h2> + + <div class="<?= $collapsed ? 'tracy-collapsed ' : '' ?>inner"> + <p><b>File:</b> <?= Helpers::editorLink($ex->getFile(), $ex->getLine()) ?></p> + <?php if (is_file($ex->getFile())): ?><?= self::highlightFile($ex->getFile(), $ex->getLine()) ?><?php endif ?> + </div></div> + + + <?php if (isset($stack[0]['class']) && $stack[0]['class'] === 'Tracy\Debugger' && ($stack[0]['function'] === 'shutdownHandler' || $stack[0]['function'] === 'errorHandler')) unset($stack[0]) ?> + <?php if ($stack): ?> + <div class="panel"> + <h2><a data-tracy-ref="^+" class="tracy-toggle">Call stack</a></h2> + + <div class="inner"> + <ol> + <?php foreach ($stack as $key => $row): ?> + <li><p> + + <?php if (isset($row['file']) && is_file($row['file'])): ?> + <?= Helpers::editorLink($row['file'], $row['line']) ?> + <?php else: ?> + <i>inner-code</i><?php if (isset($row['line'])) echo ':', $row['line'] ?> + <?php endif ?> + + <?php if (isset($row['file']) && is_file($row['file'])): ?><a data-tracy-ref="^p + .file" class="tracy-toggle<?php if ($expanded !== $key) echo ' tracy-collapsed' ?>">source</a>  <?php endif ?> + + <?php + if (isset($row['class'])) echo '<b>', Helpers::escapeHtml($row['class'] . $row['type']), '</b>'; + echo '<b>', Helpers::escapeHtml($row['function']), '</b> ('; + if (!empty($row['args'])): ?><a data-tracy-ref="^p + .args" class="tracy-toggle tracy-collapsed">arguments</a><?php endif ?>) + </p> + + <?php if (isset($row['file']) && is_file($row['file'])): ?> + <div class="<?php if ($expanded !== $key) echo 'tracy-collapsed ' ?>file"><?= self::highlightFile($row['file'], $row['line']) ?></div> + <?php endif ?> + + + <?php if (!empty($row['args'])): ?> + <div class="tracy-collapsed outer args"> + <table> + <?php + try { + $r = isset($row['class']) ? new \ReflectionMethod($row['class'], $row['function']) : new \ReflectionFunction($row['function']); + $params = $r->getParameters(); + } catch (\Exception $e) { + $params = []; + } + foreach ($row['args'] as $k => $v) { + $argName = isset($params[$k]) && !$params[$k]->isVariadic() ? $params[$k]->name : $k; + echo '<tr><th>', Helpers::escapeHtml((is_string($argName) ? '$' : '#') . $argName), '</th><td>'; + echo $dump($v, (string) $argName); + echo "</td></tr>\n"; + } + ?> + </table> + </div> + <?php endif ?> + </li> + <?php endforeach ?> + </ol> + </div></div> + <?php endif ?> + + + <?php if ($ex instanceof \ErrorException && isset($ex->context) && is_array($ex->context)):?> + <div class="panel"> + <h2><a data-tracy-ref="^+" class="tracy-toggle tracy-collapsed">Variables</a></h2> + + <div class="tracy-collapsed inner"> + <div class="outer"> + <table class="tracy-sortable"> + <?php + foreach ($ex->context as $k => $v) { + echo '<tr><th>$', Helpers::escapeHtml($k), '</th><td>', $dump($v, $k), "</td></tr>\n"; + } + ?> + </table> + </div> + </div></div> + <?php endif ?> + + <?php endforeach ?> + <?php while ($level--) echo '</div></div>' ?> + + + <?php if (count((array) $exception) > count((array) new \Exception)):?> + <div class="panel"> + <h2><a data-tracy-ref="^+" class="tracy-toggle tracy-collapsed">Exception</a></h2> + <div class="tracy-collapsed inner"> + <?= $dump($exception) ?> + </div></div> + <?php endif ?> + + + <?php if ($lastError): ?> + <div class="panel"> + <h2><a data-tracy-ref="^+" class="tracy-toggle tracy-collapsed">Last muted error</a></h2> + <div class="tracy-collapsed inner"> + + <h3><?= Helpers::errorTypeToString($lastError['type']) ?>: <?= Helpers::escapeHtml($lastError['message']) ?></h3> + <?php if (isset($lastError['file']) && is_file($lastError['file'])): ?> + <p><?= Helpers::editorLink($lastError['file'], $lastError['line']) ?></p> + <div><?= self::highlightFile($lastError['file'], $lastError['line']) ?></div> + <?php else: ?> + <p><i>inner-code</i><?php if (isset($lastError['line'])) echo ':', $lastError['line'] ?></p> + <?php endif ?> + + </div></div> + <?php endif ?> + + + <?php $bottomPanels = [] ?> + <?php foreach ($this->renderPanels(null) as $panel): ?> + <?php if (!empty($panel->bottom)) { $bottomPanels[] = $panel; continue; } ?> + <?php $collapsedClass = !isset($panel->collapsed) || $panel->collapsed ? ' tracy-collapsed' : ''; ?> + <div class="panel"> + <h2><a data-tracy-ref="^+" class="tracy-toggle<?= $collapsedClass ?>"><?= Helpers::escapeHtml($panel->tab) ?></a></h2> + + <div class="inner<?= $collapsedClass ?>"> + <?= $panel->panel ?> + </div></div> + <?php endforeach ?> + + + <?php if ($showEnvironment):?> + <div class="panel"> + <h2><a data-tracy-ref="^+" class="tracy-toggle tracy-collapsed">Environment</a></h2> + + <div class="tracy-collapsed inner"> + <h3><a data-tracy-ref="^+" class="tracy-toggle">$_SERVER</a></h3> + <div class="outer"> + <table class="tracy-sortable"> + <?php + foreach ($_SERVER as $k => $v) echo '<tr><th>', Helpers::escapeHtml($k), '</th><td>', $dump($v, $k), "</td></tr>\n"; + ?> + </table> + </div> + + + <h3><a data-tracy-ref="^+" class="tracy-toggle">$_SESSION</a></h3> + <div class="outer"> + <?php if (empty($_SESSION)):?> + <p><i>empty</i></p> + <?php else: ?> + <table class="tracy-sortable"> + <?php + foreach ($_SESSION as $k => $v) echo '<tr><th>', Helpers::escapeHtml($k), '</th><td>', $k === '__NF' ? '<i>Nette Session</i>' : $dump($v, $k), "</td></tr>\n"; + ?> + </table> + <?php endif ?> + </div> + + + <?php if (!empty($_SESSION['__NF']['DATA'])):?> + <h3><a data-tracy-ref="^+" class="tracy-toggle">Nette Session</a></h3> + <div class="outer"> + <table class="tracy-sortable"> + <?php + foreach ($_SESSION['__NF']['DATA'] as $k => $v) echo '<tr><th>', Helpers::escapeHtml($k), '</th><td>', $dump($v, $k), "</td></tr>\n"; + ?> + </table> + </div> + <?php endif ?> + + + <?php + $list = get_defined_constants(true); + if (!empty($list['user'])):?> + <h3><a data-tracy-ref="^+" class="tracy-toggle tracy-collapsed">Constants</a></h3> + <div class="outer tracy-collapsed"> + <table class="tracy-sortable"> + <?php + foreach ($list['user'] as $k => $v) { + echo '<tr><th>', Helpers::escapeHtml($k), '</th>'; + echo '<td>', $dump($v, $k), "</td></tr>\n"; + } + ?> + </table> + </div> + <?php endif ?> + + + <h3><a data-tracy-ref="^+" class="tracy-toggle tracy-collapsed">Configuration options</a></h3> + <div class="outer tracy-collapsed"> + <?php $this->renderPhpInfo() ?> + </div> + </div></div> + <?php endif ?> + + + <?php if (PHP_SAPI === 'cli'): ?> + <div class="panel"> + <h2><a data-tracy-ref="^+" class="tracy-toggle tracy-collapsed">CLI request</a></h2> + + <div class="tracy-collapsed inner"> + <h3>Process ID <?= Helpers::escapeHtml(getmypid()) ?></h3> + <pre>php<?= Helpers::escapeHtml(explode('):', $source, 2)[1]) ?></pre> + + <h3>Arguments</h3> + <div class="outer"> + <table> + <?php + foreach ($_SERVER['argv'] as $k => $v) echo '<tr><th>', Helpers::escapeHtml($k), '</th><td>', $dump($v, $k), "</td></tr>\n"; + ?> + </table> + </div> + </div></div> + + + <?php else: ?> + <div class="panel"> + <h2><a data-tracy-ref="^+" class="tracy-toggle tracy-collapsed">HTTP request</a></h2> + + <div class="tracy-collapsed inner"> + <h3><?= Helpers::escapeHtml($_SERVER['REQUEST_METHOD'] ?? 'URL') ?></h3> + <p><a href="<?= Helpers::escapeHtml($source) ?>" target="_blank" rel="noreferrer noopener"><?= Helpers::escapeHtml($source) ?></a></p> + + <h3>Headers</h3> + <div class="outer"> + <table class="tracy-sortable"> + <?php + foreach ($httpHeaders as $k => $v) echo '<tr><th>', Helpers::escapeHtml($k), '</th><td>', $dump($v, $k), "</td></tr>\n"; + ?> + </table> + </div> + + + <?php foreach (['_GET', '_POST', '_COOKIE'] as $name): ?> + <h3>$<?= Helpers::escapeHtml($name) ?></h3> + <?php if (empty($GLOBALS[$name])):?> + <p><i>empty</i></p> + <?php else: ?> + <div class="outer"> + <table class="tracy-sortable"> + <?php + foreach ($GLOBALS[$name] as $k => $v) echo '<tr><th>', Helpers::escapeHtml($k), '</th><td>', $dump($v, $k), "</td></tr>\n"; + ?> + </table> + </div> + <?php endif ?> + <?php endforeach ?> + </div></div> + + + <div class="panel"> + <h2><a data-tracy-ref="^+" class="tracy-toggle tracy-collapsed">HTTP response</a></h2> + + <div class="tracy-collapsed inner"> + <h3>Headers</h3> + <?php if (headers_list()): ?> + <div class="outer"> + <table class="tracy-sortable"> + <?php + foreach (headers_list() as $s) { $s = explode(':', $s, 2); echo '<tr><th>', Helpers::escapeHtml($s[0]), '</th><td>', Helpers::escapeHtml(trim($s[1])), "</td></tr>\n"; } + ?> + </table> + </div> + <?php else: ?> + <p><i>no headers</i></p> + <?php endif ?> + </div></div> + <?php endif ?> + + + <?php foreach ($bottomPanels as $panel): ?> + <div class="panel"> + <h2><a data-tracy-ref="^+" class="tracy-toggle"><?= Helpers::escapeHtml($panel->tab) ?></a></h2> + + <div class="inner"> + <?= $panel->panel ?> + </div></div> + <?php endforeach ?> + + <footer> + <ul> + <li><b><a href="https://github.com/sponsors/dg" target="_blank" rel="noreferrer noopener">Please support Tracy via a donation 💙️</a></b></li> + <li>Report generated at <?= date('Y/m/d H:i:s') ?></li> + <?php foreach ($info as $item): ?><li><?= Helpers::escapeHtml($item) ?></li><?php endforeach ?> + </ul> + <div class="footer-logo"><a href="https://tracy.nette.org" rel="noreferrer"></a></div> + </footer> + </div> + <meta itemprop=tracy-snapshot content=<?= Dumper::formatSnapshotAttribute($snapshot) ?>> +</div> diff --git a/vendor/tracy/tracy/src/Tracy/BlueScreen/assets/page.phtml b/vendor/tracy/tracy/src/Tracy/BlueScreen/assets/page.phtml new file mode 100644 index 0000000..2470dbb --- /dev/null +++ b/vendor/tracy/tracy/src/Tracy/BlueScreen/assets/page.phtml @@ -0,0 +1,57 @@ +<?php + +/** + * Debugger bluescreen template. + * + * This file is part of the Tracy (https://tracy.nette.org) + * Copyright (c) 2004 David Grudl (https://davidgrudl.com) + * + * @param array $exception + * @param string $title + * @param string $nonce + * @return void + */ + +declare(strict_types=1); + +namespace Tracy; + +$code = $exception->getCode() ? ' #' . $exception->getCode() : ''; +$nonceAttr = $nonce ? ' nonce="' . Helpers::escapeHtml($nonce) . '"' : ''; +$exceptions = Helpers::getExceptionChain($exception); +?><!DOCTYPE html><!-- "' --></textarea></script></style></pre></xmp></a></iframe></noembed></noframes></noscript></option></select></template> + + + + + + + <?= Helpers::escapeHtml($title . ': ' . $exception->getMessage() . $code) ?> + + 1): ?> + + + + + + + + + + +> +'use strict'; + +Tracy.BlueScreen.init(); + + + diff --git a/vendor/tracy/tracy/src/Tracy/Debugger/Debugger.php b/vendor/tracy/tracy/src/Tracy/Debugger/Debugger.php new file mode 100644 index 0000000..1d707ca --- /dev/null +++ b/vendor/tracy/tracy/src/Tracy/Debugger/Debugger.php @@ -0,0 +1,654 @@ +dispatchAssets()) { + exit; + } + } + + + /** + * Renders loading + + + +Server Error + + + +
+
+

Server Error

+ +

We're sorry! The server encountered an internal error and + was unable to complete your request. Please try again later.

+ +

error 500 |
Tracy is unable to log error.

+
+
+ + diff --git a/vendor/tracy/tracy/src/Tracy/Dumper/Describer.php b/vendor/tracy/tracy/src/Tracy/Dumper/Describer.php new file mode 100644 index 0000000..efcd759 --- /dev/null +++ b/vendor/tracy/tracy/src/Tracy/Dumper/Describer.php @@ -0,0 +1,378 @@ + */ + public $objectExposers; + + /** @var (int|\stdClass)[] */ + public $references = []; + + + public function describe($var): \stdClass + { + uksort($this->objectExposers, function ($a, $b): int { + return $b === '' || (class_exists($a, false) && is_subclass_of($a, $b)) ? -1 : 1; + }); + + try { + return (object) [ + 'value' => $this->describeVar($var), + 'snapshot' => $this->snapshot, + 'location' => $this->location ? self::findLocation() : null, + ]; + + } finally { + $free = [[], []]; + $this->snapshot = &$free[0]; + $this->references = &$free[1]; + } + } + + + /** + * @return mixed + */ + private function describeVar($var, int $depth = 0, int $refId = null) + { + if ($var === null || is_bool($var)) { + return $var; + } + $m = 'describe' . explode(' ', gettype($var))[0]; + return $this->$m($var, $depth, $refId); + } + + + /** + * @return Value|int + */ + private function describeInteger(int $num) + { + return $num <= self::JS_SAFE_INTEGER && $num >= -self::JS_SAFE_INTEGER + ? $num + : new Value(Value::TYPE_NUMBER, "$num"); + } + + + /** + * @return Value|float + */ + private function describeDouble(float $num) + { + if (!is_finite($num)) { + return new Value(Value::TYPE_NUMBER, (string) $num); + } + $js = json_encode($num); + return strpos($js, '.') + ? $num + : new Value(Value::TYPE_NUMBER, "$js.0"); // to distinct int and float in JS + } + + + /** + * @return Value|string + */ + private function describeString(string $s, int $depth = 0) + { + $encoded = Helpers::encodeString($s, $depth ? $this->maxLength : null); + if ($encoded === $s) { + return $encoded; + } elseif (Helpers::isUtf8($s)) { + return new Value(Value::TYPE_STRING_HTML, $encoded, Helpers::utf8Length($s)); + } else { + return new Value(Value::TYPE_BINARY_HTML, $encoded, strlen($s)); + } + } + + + /** + * @return Value|array + */ + private function describeArray(array $arr, int $depth = 0, int $refId = null) + { + if ($refId) { + $res = new Value(Value::TYPE_REF, 'p' . $refId); + $value = &$this->snapshot[$res->value]; + if ($value && $value->depth <= $depth) { + return $res; + } + + $value = new Value(Value::TYPE_ARRAY); + $value->id = $res->value; + $value->depth = $depth; + if ($this->maxDepth && $depth >= $this->maxDepth) { + $value->length = count($arr); + return $res; + } elseif ($depth && $this->maxItems && count($arr) > $this->maxItems) { + $value->length = count($arr); + $arr = array_slice($arr, 0, $this->maxItems, true); + } + $items = &$value->items; + + } elseif ($arr && $this->maxDepth && $depth >= $this->maxDepth) { + return new Value(Value::TYPE_ARRAY, null, count($arr)); + + } elseif ($depth && $this->maxItems && count($arr) > $this->maxItems) { + $res = new Value(Value::TYPE_ARRAY, null, count($arr)); + $res->depth = $depth; + $items = &$res->items; + $arr = array_slice($arr, 0, $this->maxItems, true); + } + + $items = []; + foreach ($arr as $k => $v) { + $refId = $this->getReferenceId($arr, $k); + $items[] = [ + $this->describeVar($k, $depth + 1), + $this->isSensitive((string) $k, $v) + ? new Value(Value::TYPE_TEXT, self::hideValue($v)) + : $this->describeVar($v, $depth + 1, $refId), + ] + ($refId ? [2 => $refId] : []); + } + + return $res ?? $items; + } + + + private function describeObject(object $obj, int $depth = 0): Value + { + $id = spl_object_id($obj); + $value = &$this->snapshot[$id]; + if ($value && $value->depth <= $depth) { + return new Value(Value::TYPE_REF, $id); + } + + $value = new Value(Value::TYPE_OBJECT, Helpers::getClass($obj)); + $value->id = $id; + $value->depth = $depth; + $value->holder = $obj; // to be not released by garbage collector in collecting mode + if ($this->location) { + $rc = $obj instanceof \Closure + ? new \ReflectionFunction($obj) + : new \ReflectionClass($obj); + if ($rc->getFileName() && ($editor = Helpers::editorUri($rc->getFileName(), $rc->getStartLine()))) { + $value->editor = (object) ['file' => $rc->getFileName(), 'line' => $rc->getStartLine(), 'url' => $editor]; + } + } + + if ($this->maxDepth && $depth < $this->maxDepth) { + $value->items = []; + $props = $this->exposeObject($obj, $value); + foreach ($props ?? [] as $k => $v) { + $this->addPropertyTo($value, (string) $k, $v, Value::PROP_VIRTUAL, $this->getReferenceId($props, $k)); + } + } + return new Value(Value::TYPE_REF, $id); + } + + + /** + * @param resource $resource + */ + private function describeResource($resource, int $depth = 0): Value + { + $id = 'r' . (int) $resource; + $value = &$this->snapshot[$id]; + if (!$value) { + $type = is_resource($resource) ? get_resource_type($resource) : 'closed'; + $value = new Value(Value::TYPE_RESOURCE, $type . ' resource'); + $value->id = $id; + $value->depth = $depth; + $value->items = []; + if (isset($this->resourceExposers[$type])) { + foreach (($this->resourceExposers[$type])($resource) as $k => $v) { + $value->items[] = [htmlspecialchars($k), $this->describeVar($v, $depth + 1)]; + } + } + } + return new Value(Value::TYPE_REF, $id); + } + + + /** + * @return Value|string + */ + public function describeKey(string $key) + { + if (preg_match('#^[\w!\#$%&*+./;<>?@^{|}~-]{1,50}$#D', $key) && !preg_match('#^(true|false|null)$#iD', $key)) { + return $key; + } + $value = $this->describeString($key); + return is_string($value) // ensure result is Value + ? new Value(Value::TYPE_STRING_HTML, $key, Helpers::utf8Length($key)) + : $value; + } + + + public function addPropertyTo( + Value $value, + string $k, + $v, + $type = Value::PROP_VIRTUAL, + int $refId = null, + string $class = null + ) { + if ($value->depth && $this->maxItems && count($value->items ?? []) >= $this->maxItems) { + $value->length = ($value->length ?? count($value->items)) + 1; + return; + } + + $class = $class ?? $value->value; + $value->items[] = [ + $this->describeKey($k), + $type !== Value::PROP_VIRTUAL && $this->isSensitive($k, $v, $class) + ? new Value(Value::TYPE_TEXT, self::hideValue($v)) + : $this->describeVar($v, $value->depth + 1, $refId), + $type === Value::PROP_PRIVATE ? $class : $type, + ] + ($refId ? [3 => $refId] : []); + } + + + private function exposeObject(object $obj, Value $value): ?array + { + foreach ($this->objectExposers as $type => $dumper) { + if (!$type || $obj instanceof $type) { + return $dumper($obj, $value, $this); + } + } + + if ($this->debugInfo && method_exists($obj, '__debugInfo')) { + return $obj->__debugInfo(); + } + + Exposer::exposeObject($obj, $value, $this); + return null; + } + + + private function isSensitive(string $key, $val, string $class = null): bool + { + return + ($this->scrubber !== null && ($this->scrubber)($key, $val, $class)) + || isset($this->keysToHide[strtolower($key)]) + || isset($this->keysToHide[strtolower($class . '::$' . $key)]); + } + + + private static function hideValue($var): string + { + return self::HIDDEN_VALUE . ' (' . (is_object($var) ? Helpers::getClass($var) : gettype($var)) . ')'; + } + + + public function getReferenceId($arr, $key): ?int + { + if (PHP_VERSION_ID >= 70400) { + if ((!$rr = \ReflectionReference::fromArrayElement($arr, $key))) { + return null; + } + $tmp = &$this->references[$rr->getId()]; + if ($tmp === null) { + return $tmp = count($this->references); + } + return $tmp; + } + $uniq = new \stdClass; + $copy = $arr; + $orig = $copy[$key]; + $copy[$key] = $uniq; + if ($arr[$key] !== $uniq) { + return null; + } + $res = array_search($uniq, $this->references, true); + $copy[$key] = $orig; + if ($res === false) { + $this->references[] = &$arr[$key]; + return count($this->references); + } + return $res + 1; + } + + + /** + * Finds the location where dump was called. Returns [file, line, code] + */ + private static function findLocation(): ?array + { + foreach (debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) as $item) { + if (isset($item['class']) && ($item['class'] === self::class || $item['class'] === \Tracy\Dumper::class)) { + $location = $item; + continue; + } elseif (isset($item['function'])) { + try { + $reflection = isset($item['class']) + ? new \ReflectionMethod($item['class'], $item['function']) + : new \ReflectionFunction($item['function']); + if ( + $reflection->isInternal() + || preg_match('#\s@tracySkipLocation\s#', (string) $reflection->getDocComment()) + ) { + $location = $item; + continue; + } + } catch (\ReflectionException $e) { + } + } + break; + } + + if (isset($location['file'], $location['line']) && is_file($location['file'])) { + $lines = file($location['file']); + $line = $lines[$location['line'] - 1]; + return [ + $location['file'], + $location['line'], + trim(preg_match('#\w*dump(er::\w+)?\(.*\)#i', $line, $m) ? $m[0] : $line), + ]; + } + return null; + } +} diff --git a/vendor/tracy/tracy/src/Tracy/Dumper/Dumper.php b/vendor/tracy/tracy/src/Tracy/Dumper/Dumper.php new file mode 100644 index 0000000..af22780 --- /dev/null +++ b/vendor/tracy/tracy/src/Tracy/Dumper/Dumper.php @@ -0,0 +1,242 @@ + '1;33', + 'null' => '1;33', + 'number' => '1;32', + 'string' => '1;36', + 'array' => '1;31', + 'public' => '1;37', + 'protected' => '1;37', + 'private' => '1;37', + 'dynamic' => '1;37', + 'virtual' => '1;37', + 'object' => '1;31', + 'resource' => '1;37', + 'indent' => '1;30', + ]; + + /** @var array */ + public static $resources = [ + 'stream' => 'stream_get_meta_data', + 'stream-context' => 'stream_context_get_options', + 'curl' => 'curl_getinfo', + ]; + + /** @var array */ + public static $objectExporters = [ + \Closure::class => [Exposer::class, 'exposeClosure'], + \UnitEnum::class => [Exposer::class, 'exposeEnum'], + \ArrayObject::class => [Exposer::class, 'exposeArrayObject'], + \SplFileInfo::class => [Exposer::class, 'exposeSplFileInfo'], + \SplObjectStorage::class => [Exposer::class, 'exposeSplObjectStorage'], + \__PHP_Incomplete_Class::class => [Exposer::class, 'exposePhpIncompleteClass'], + \DOMNode::class => [Exposer::class, 'exposeDOMNode'], + \DOMNodeList::class => [Exposer::class, 'exposeDOMNodeList'], + \DOMNamedNodeMap::class => [Exposer::class, 'exposeDOMNodeList'], + \Ds\Collection::class => [Exposer::class, 'exposeDsCollection'], + \Ds\Map::class => [Exposer::class, 'exposeDsMap'], + ]; + + /** @var Describer */ + private $describer; + + /** @var Renderer */ + private $renderer; + + + /** + * Dumps variable to the output. + * @return mixed variable + */ + public static function dump($var, array $options = []) + { + if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { + $useColors = self::$terminalColors && Helpers::detectColors(); + $dumper = new self($options); + fwrite(STDOUT, $dumper->asTerminal($var, $useColors ? self::$terminalColors : [])); + + } elseif (preg_match('#^Content-Type: (?!text/html)#im', implode("\n", headers_list()))) { // non-html + echo self::toText($var, $options); + + } else { // html + $options[self::LOCATION] = $options[self::LOCATION] ?? true; + self::renderAssets(); + echo self::toHtml($var, $options); + } + return $var; + } + + + /** + * Dumps variable to HTML. + */ + public static function toHtml($var, array $options = [], $key = null): string + { + return (new self($options))->asHtml($var, $key); + } + + + /** + * Dumps variable to plain text. + */ + public static function toText($var, array $options = []): string + { + return (new self($options))->asTerminal($var); + } + + + /** + * Dumps variable to x-terminal. + */ + public static function toTerminal($var, array $options = []): string + { + return (new self($options))->asTerminal($var, self::$terminalColors); + } + + + /** + * Renders \n"; + } + } + + + private function __construct(array $options = []) + { + $location = $options[self::LOCATION] ?? 0; + $location = $location === true ? ~0 : (int) $location; + + $describer = $this->describer = new Describer; + $describer->maxDepth = (int) ($options[self::DEPTH] ?? $describer->maxDepth); + $describer->maxLength = (int) ($options[self::TRUNCATE] ?? $describer->maxLength); + $describer->maxItems = (int) ($options[self::ITEMS] ?? $describer->maxItems); + $describer->debugInfo = (bool) ($options[self::DEBUGINFO] ?? $describer->debugInfo); + $describer->scrubber = $options[self::SCRUBBER] ?? $describer->scrubber; + $describer->keysToHide = array_flip(array_map('strtolower', $options[self::KEYS_TO_HIDE] ?? [])); + $describer->resourceExposers = ($options['resourceExporters'] ?? []) + self::$resources; + $describer->objectExposers = ($options[self::OBJECT_EXPORTERS] ?? []) + self::$objectExporters; + $describer->location = (bool) $location; + if ($options[self::LIVE] ?? false) { + $tmp = &self::$liveSnapshot; + } elseif (isset($options[self::SNAPSHOT])) { + $tmp = &$options[self::SNAPSHOT]; + } + if (isset($tmp)) { + $tmp[0] = $tmp[0] ?? []; + $tmp[1] = $tmp[1] ?? []; + $describer->snapshot = &$tmp[0]; + $describer->references = &$tmp[1]; + } + + $renderer = $this->renderer = new Renderer; + $renderer->collapseTop = $options[self::COLLAPSE] ?? $renderer->collapseTop; + $renderer->collapseSub = $options[self::COLLAPSE_COUNT] ?? $renderer->collapseSub; + $renderer->collectingMode = isset($options[self::SNAPSHOT]) || !empty($options[self::LIVE]); + $renderer->lazy = $renderer->collectingMode + ? true + : ($options[self::LAZY] ?? $renderer->lazy); + $renderer->sourceLocation = !(~$location & self::LOCATION_SOURCE); + $renderer->classLocation = !(~$location & self::LOCATION_CLASS); + $renderer->theme = $options[self::THEME] ?? $renderer->theme; + } + + + /** + * Dumps variable to HTML. + */ + private function asHtml($var, $key = null): string + { + if ($key === null) { + $model = $this->describer->describe($var); + } else { + $model = $this->describer->describe([$key => $var]); + $model->value = $model->value[0][1]; + } + return $this->renderer->renderAsHtml($model); + } + + + /** + * Dumps variable to x-terminal. + */ + private function asTerminal($var, array $colors = []): string + { + $model = $this->describer->describe($var); + return $this->renderer->renderAsText($model, $colors); + } + + + public static function formatSnapshotAttribute(array &$snapshot): string + { + $res = "'" . Renderer::jsonEncode($snapshot[0] ?? []) . "'"; + $snapshot = []; + return $res; + } +} diff --git a/vendor/tracy/tracy/src/Tracy/Dumper/Exposer.php b/vendor/tracy/tracy/src/Tracy/Dumper/Exposer.php new file mode 100644 index 0000000..0f005c2 --- /dev/null +++ b/vendor/tracy/tracy/src/Tracy/Dumper/Exposer.php @@ -0,0 +1,215 @@ + $v) { + $describer->addPropertyTo( + $value, + (string) $k, + $v, + Value::PROP_DYNAMIC, + $describer->getReferenceId($values, $k) + ); + } + + foreach ($props as $k => [$name, $class, $type]) { + if (array_key_exists($k, $values)) { + $describer->addPropertyTo( + $value, + $name, + $values[$k], + $type, + $describer->getReferenceId($values, $k), + $class + ); + } else { + $value->items[] = [ + $name, + new Value(Value::TYPE_TEXT, 'unset'), + $type === Value::PROP_PRIVATE ? $class : $type, + ]; + } + } + } + + + private static function getProperties($class): array + { + static $cache; + if (isset($cache[$class])) { + return $cache[$class]; + } + $rc = new \ReflectionClass($class); + $parentProps = $rc->getParentClass() ? self::getProperties($rc->getParentClass()->getName()) : []; + $props = []; + + foreach ($rc->getProperties() as $prop) { + $name = $prop->getName(); + if ($prop->isStatic() || $prop->getDeclaringClass()->getName() !== $class) { + // nothing + } elseif ($prop->isPrivate()) { + $props["\x00" . $class . "\x00" . $name] = [$name, $class, Value::PROP_PRIVATE]; + } elseif ($prop->isProtected()) { + $props["\x00*\x00" . $name] = [$name, $class, Value::PROP_PROTECTED]; + } else { + $props[$name] = [$name, $class, Value::PROP_PUBLIC]; + unset($parentProps["\x00*\x00" . $name]); + } + } + + return $cache[$class] = $props + $parentProps; + } + + + public static function exposeClosure(\Closure $obj, Value $value, Describer $describer): void + { + $rc = new \ReflectionFunction($obj); + if ($describer->location) { + $describer->addPropertyTo($value, 'file', $rc->getFileName() . ':' . $rc->getStartLine()); + } + + $params = []; + foreach ($rc->getParameters() as $param) { + $params[] = '$' . $param->getName(); + } + $value->value .= '(' . implode(', ', $params) . ')'; + + $uses = []; + $useValue = new Value(Value::TYPE_OBJECT); + $useValue->depth = $value->depth + 1; + foreach ($rc->getStaticVariables() as $name => $v) { + $uses[] = '$' . $name; + $describer->addPropertyTo($useValue, '$' . $name, $v); + } + if ($uses) { + $useValue->value = implode(', ', $uses); + $useValue->collapsed = true; + $value->items[] = ['use', $useValue]; + } + } + + + public static function exposeEnum(\UnitEnum $enum, Value $value, Describer $describer): void + { + $value->value = get_class($enum) . '::' . $enum->name; + if ($enum instanceof \BackedEnum) { + $describer->addPropertyTo($value, 'value', $enum->value); + $value->collapsed = true; + } + } + + + public static function exposeArrayObject(\ArrayObject $obj, Value $value, Describer $describer): void + { + $flags = $obj->getFlags(); + $obj->setFlags(\ArrayObject::STD_PROP_LIST); + self::exposeObject($obj, $value, $describer); + $obj->setFlags($flags); + $describer->addPropertyTo($value, 'storage', $obj->getArrayCopy(), Value::PROP_PRIVATE, null, \ArrayObject::class); + } + + + public static function exposeDOMNode(\DOMNode $obj, Value $value, Describer $describer): void + { + $props = preg_match_all('#^\s*\[([^\]]+)\] =>#m', print_r($obj, true), $tmp) ? $tmp[1] : []; + sort($props); + foreach ($props as $p) { + $describer->addPropertyTo($value, $p, $obj->$p, Value::PROP_PUBLIC); + } + } + + + /** + * @param \DOMNodeList|\DOMNamedNodeMap $obj + */ + public static function exposeDOMNodeList($obj, Value $value, Describer $describer): void + { + $describer->addPropertyTo($value, 'length', $obj->length, Value::PROP_PUBLIC); + $describer->addPropertyTo($value, 'items', iterator_to_array($obj)); + } + + + public static function exposeSplFileInfo(\SplFileInfo $obj): array + { + return ['path' => $obj->getPathname()]; + } + + + public static function exposeSplObjectStorage(\SplObjectStorage $obj): array + { + $res = []; + foreach (clone $obj as $item) { + $res[] = ['object' => $item, 'data' => $obj[$item]]; + } + return $res; + } + + + public static function exposePhpIncompleteClass( + \__PHP_Incomplete_Class $obj, + Value $value, + Describer $describer + ): void { + $values = (array) $obj; + $class = $values['__PHP_Incomplete_Class_Name']; + unset($values['__PHP_Incomplete_Class_Name']); + foreach ($values as $k => $v) { + $refId = $describer->getReferenceId($values, $k); + if (isset($k[0]) && $k[0] === "\x00") { + $info = explode("\00", $k); + $k = end($info); + $type = $info[1] === '*' ? Value::PROP_PROTECTED : Value::PROP_PRIVATE; + $decl = $type === Value::PROP_PRIVATE ? $info[1] : null; + } else { + $type = Value::PROP_PUBLIC; + $k = (string) $k; + $decl = null; + } + $describer->addPropertyTo($value, $k, $v, $type, $refId, $decl); + } + $value->value = $class . ' (Incomplete Class)'; + } + + + public static function exposeDsCollection( + \Ds\Collection $obj, + Value $value, + Describer $describer + ): void { + foreach ($obj as $k => $v) { + $describer->addPropertyTo($value, (string) $k, $v, Value::PROP_VIRTUAL); + } + } + + + public static function exposeDsMap( + \Ds\Map $obj, + Value $value, + Describer $describer + ): void { + $i = 0; + foreach ($obj as $k => $v) { + $describer->addPropertyTo($value, (string) $i++, new \Ds\Pair($k, $v), Value::PROP_VIRTUAL); + } + } +} diff --git a/vendor/tracy/tracy/src/Tracy/Dumper/Renderer.php b/vendor/tracy/tracy/src/Tracy/Dumper/Renderer.php new file mode 100644 index 0000000..3bbd013 --- /dev/null +++ b/vendor/tracy/tracy/src/Tracy/Dumper/Renderer.php @@ -0,0 +1,484 @@ +value; + $this->snapshot = $model->snapshot; + + if ($this->lazy === false) { // no lazy-loading + $html = $this->renderVar($value); + $json = $snapshot = null; + + } elseif ($this->lazy && (is_array($value) && $value || is_object($value))) { // full lazy-loading + $html = ''; + $snapshot = $this->collectingMode ? null : $this->snapshot; + $json = $value; + + } else { // lazy-loading of collapsed parts + $html = $this->renderVar($value); + $snapshot = $this->snapshotSelection; + $json = null; + } + } finally { + $this->parents = $this->snapshot = $this->above = []; + $this->snapshotSelection = null; + } + + $location = null; + if ($model->location && $this->sourceLocation) { + [$file, $line, $code] = $model->location; + $uri = Helpers::editorUri($file, $line); + $location = Helpers::formatHtml( + '', + $uri ?? '#', + $file, + $line, + $uri ? "\nClick to open in editor" : '' + ) . Helpers::encodeString($code, 50) . " 📍"; + } + + return '
 100 ? "\n" : '')
+			. '>'
+			. $location
+			. $html
+			. "
\n"; + } + + + public function renderAsText(\stdClass $model, array $colors = []): string + { + try { + $this->snapshot = $model->snapshot; + $this->lazy = false; + $s = $this->renderVar($model->value); + } finally { + $this->parents = $this->snapshot = $this->above = []; + } + + $s = $colors ? self::htmlToAnsi($s, $colors) : $s; + $s = htmlspecialchars_decode(strip_tags($s), ENT_QUOTES | ENT_HTML5); + $s = str_replace('…', '...', $s); + $s .= substr($s, -1) === "\n" ? '' : "\n"; + + if ($this->sourceLocation && ([$file, $line] = $model->location)) { + $s .= "in $file:$line\n"; + } + + return $s; + } + + + /** + * @param mixed $value + * @param string|int|null $keyType + */ + private function renderVar($value, int $depth = 0, $keyType = null): string + { + switch (true) { + case $value === null: + return 'null'; + + case is_bool($value): + return '' . ($value ? 'true' : 'false') . ''; + + case is_int($value): + return '' . $value . ''; + + case is_float($value): + return '' . self::jsonEncode($value) . ''; + + case is_string($value): + return $this->renderString($value, $depth, $keyType); + + case is_array($value): + case $value->type === Value::TYPE_ARRAY: + return $this->renderArray($value, $depth); + + case $value->type === Value::TYPE_REF: + return $this->renderVar($this->snapshot[$value->value], $depth, $keyType); + + case $value->type === Value::TYPE_OBJECT: + return $this->renderObject($value, $depth); + + case $value->type === Value::TYPE_NUMBER: + return '' . Helpers::escapeHtml($value->value) . ''; + + case $value->type === Value::TYPE_TEXT: + return '' . Helpers::escapeHtml($value->value) . ''; + + case $value->type === Value::TYPE_STRING_HTML: + case $value->type === Value::TYPE_BINARY_HTML: + return $this->renderString($value, $depth, $keyType); + + case $value->type === Value::TYPE_RESOURCE: + return $this->renderResource($value, $depth); + + default: + throw new \Exception('Unknown type'); + } + } + + + /** + * @param string|Value $str + * @param string|int|null $keyType + */ + private function renderString($str, int $depth, $keyType): string + { + if ($keyType === self::TYPE_ARRAY_KEY) { + $indent = ' ' . str_repeat('| ', $depth - 1) . ' '; + return '' + . "'" + . (is_string($str) ? Helpers::escapeHtml($str) : str_replace("\n", "\n" . $indent, $str->value)) + . "'" + . ''; + + } elseif ($keyType !== null) { + static $classes = [ + Value::PROP_PUBLIC => 'tracy-dump-public', + Value::PROP_PROTECTED => 'tracy-dump-protected', + Value::PROP_DYNAMIC => 'tracy-dump-dynamic', + Value::PROP_VIRTUAL => 'tracy-dump-virtual', + ]; + $indent = ' ' . str_repeat('| ', $depth - 1) . ' '; + $title = is_string($keyType) + ? ' title="declared in ' . Helpers::escapeHtml($keyType) . '"' + : null; + return '' + . (is_string($str) + ? Helpers::escapeHtml($str) + : "'" . str_replace("\n", "\n" . $indent, $str->value) . "'") + . ''; + + } elseif (is_string($str)) { + $len = Helpers::utf8Length($str); + return ' 1 ? ' title="' . $len . ' characters"' : '') + . '>' + . "'" + . Helpers::escapeHtml($str) + . "'" + . ''; + + } else { + $unit = $str->type === Value::TYPE_STRING_HTML ? 'characters' : 'bytes'; + $count = substr_count($str->value, "\n"); + if ($count) { + $collapsed = $indent1 = $toggle = null; + $indent = ' '; + if ($depth) { + $collapsed = $count >= $this->collapseSub; + $indent1 = ' ' . str_repeat('| ', $depth) . ''; + $indent = ' ' . str_repeat('| ', $depth) . ' '; + $toggle = 'string' . "\n"; + } + return $toggle + . '
' + . $indent1 + . ''" + . str_replace("\n", "\n" . $indent, $str->value) + . "'" + . ($depth ? "\n" : '') + . '
'; + } + + return 'length > 1 ? " title=\"{$str->length} $unit\"" : '') + . '>' + . "'" + . $str->value + . "'" + . ''; + } + } + + + /** + * @param array|Value $array + */ + private function renderArray($array, int $depth): string + { + $out = 'array ('; + + if (is_array($array)) { + $items = $array; + $count = count($items); + $out .= $count . ')'; + } elseif ($array->items === null) { + return $out . $array->length . ') …'; + } else { + $items = $array->items; + $count = $array->length ?? count($items); + $out .= $count . ')'; + if ($array->id && isset($this->parents[$array->id])) { + return $out . ' RECURSION'; + + } elseif ($array->id && ($array->depth < $depth || isset($this->above[$array->id]))) { + if ($this->lazy !== false) { + $ref = new Value(Value::TYPE_REF, $array->id); + $this->copySnapshot($ref); + return '" . $out . ''; + } + return $out . (isset($this->above[$array->id]) ? ' see above' : ' see below'); + } + } + + if (!$count) { + return $out; + } + + $collapsed = $depth + ? ($this->lazy === false || $depth === 1 ? $count >= $this->collapseSub : true) + : (is_int($this->collapseTop) ? $count >= $this->collapseTop : $this->collapseTop); + + $span = 'lazy !== false) { + $array = isset($array->id) ? new Value(Value::TYPE_REF, $array->id) : $array; + $this->copySnapshot($array); + return $span . " data-tracy-dump='" . self::jsonEncode($array) . "'>" . $out . ''; + } + + $out = $span . '>' . $out . "\n" . ''; + $indent = ' ' . str_repeat('| ', $depth) . ''; + $this->parents[$array->id ?? null] = $this->above[$array->id ?? null] = true; + + foreach ($items as $info) { + [$k, $v, $ref] = $info + [2 => null]; + $out .= $indent + . $this->renderVar($k, $depth + 1, self::TYPE_ARRAY_KEY) + . ' => ' + . ($ref ? '&' . $ref . ' ' : '') + . ($tmp = $this->renderVar($v, $depth + 1)) + . (substr($tmp, -6) === '' ? '' : "\n"); + } + + if ($count > count($items)) { + $out .= $indent . "…\n"; + } + unset($this->parents[$array->id ?? null]); + return $out . ''; + } + + + private function renderObject(Value $object, int $depth): string + { + $editorAttributes = ''; + if ($this->classLocation && $object->editor) { + $editorAttributes = Helpers::formatHtml( + ' title="Declared in file % on line %%%" data-tracy-href="%"', + $object->editor->file, + $object->editor->line, + $object->editor->url ? "\nCtrl-Click to open in editor" : '', + "\nAlt-Click to expand/collapse all child nodes", + $object->editor->url + ); + } + + $out = '' + . Helpers::escapeHtml($object->value) + . '' + . ($object->id ? ' #' . $object->id . '' : ''); + + if ($object->items === null) { + return $out . ' …'; + + } elseif (!$object->items) { + return $out; + + } elseif ($object->id && isset($this->parents[$object->id])) { + return $out . ' RECURSION'; + + } elseif ($object->id && ($object->depth < $depth || isset($this->above[$object->id]))) { + if ($this->lazy !== false) { + $ref = new Value(Value::TYPE_REF, $object->id); + $this->copySnapshot($ref); + return '" . $out . ''; + } + return $out . (isset($this->above[$object->id]) ? ' see above' : ' see below'); + } + + $collapsed = $object->collapsed ?? ($depth + ? ($this->lazy === false || $depth === 1 ? count($object->items) >= $this->collapseSub : true) + : (is_int($this->collapseTop) ? count($object->items) >= $this->collapseTop : $this->collapseTop)); + + $span = 'lazy !== false) { + $value = $object->id ? new Value(Value::TYPE_REF, $object->id) : $object; + $this->copySnapshot($value); + return $span . " data-tracy-dump='" . self::jsonEncode($value) . "'>" . $out . ''; + } + + $out = $span . '>' . $out . "\n" . ''; + $indent = ' ' . str_repeat('| ', $depth) . ''; + $this->parents[$object->id] = $this->above[$object->id] = true; + + foreach ($object->items as $info) { + [$k, $v, $type, $ref] = $info + [2 => Value::PROP_VIRTUAL, null]; + $out .= $indent + . $this->renderVar($k, $depth + 1, $type) + . ': ' + . ($ref ? '&' . $ref . ' ' : '') + . ($tmp = $this->renderVar($v, $depth + 1)) + . (substr($tmp, -6) === '' ? '' : "\n"); + } + + if ($object->length > count($object->items)) { + $out .= $indent . "…\n"; + } + unset($this->parents[$object->id]); + return $out . ''; + } + + + private function renderResource(Value $resource, int $depth): string + { + $out = '' . Helpers::escapeHtml($resource->value) . ' ' + . '@' . substr($resource->id, 1) . ''; + + if (!$resource->items) { + return $out; + + } elseif (isset($this->above[$resource->id])) { + if ($this->lazy !== false) { + $ref = new Value(Value::TYPE_REF, $resource->id); + $this->copySnapshot($ref); + return '" . $out . ''; + } + return $out . ' see above'; + + } else { + $this->above[$resource->id] = true; + $out = "$out\n
"; + foreach ($resource->items as [$k, $v]) { + $out .= ' ' . str_repeat('| ', $depth) . '' + . $this->renderVar($k, $depth + 1, Value::PROP_VIRTUAL) + . ': ' + . ($tmp = $this->renderVar($v, $depth + 1)) + . (substr($tmp, -6) === '
' ? '' : "\n"); + } + return $out . ''; + } + } + + + private function copySnapshot($value): void + { + if ($this->collectingMode) { + return; + } + if ($this->snapshotSelection === null) { + $this->snapshotSelection = []; + } + + if (is_array($value)) { + foreach ($value as [, $v]) { + $this->copySnapshot($v); + } + } elseif ($value instanceof Value && $value->type === Value::TYPE_REF) { + if (!isset($this->snapshotSelection[$value->value])) { + $ref = $this->snapshotSelection[$value->value] = $this->snapshot[$value->value]; + $this->copySnapshot($ref); + } + } elseif ($value instanceof Value && $value->items) { + foreach ($value->items as [, $v]) { + $this->copySnapshot($v); + } + } + } + + + public static function jsonEncode($snapshot): string + { + $old = @ini_set('serialize_precision', '-1'); // @ may be disabled + try { + return json_encode($snapshot, JSON_HEX_APOS | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); + } finally { + if ($old !== false) { + ini_set('serialize_precision', $old); + } + } + } + + + private static function htmlToAnsi(string $s, array $colors): string + { + $stack = ['0']; + $s = preg_replace_callback( + '#<\w+(?: class="tracy-dump-(\w+)")?[^>]*>|#', + function ($m) use ($colors, &$stack): string { + if ($m[0][1] === '/') { + array_pop($stack); + } else { + $stack[] = isset($m[1], $colors[$m[1]]) ? $colors[$m[1]] : '0'; + } + return "\033[" . end($stack) . 'm'; + }, + $s + ); + $s = preg_replace('/\e\[0m(\n*)(?=\e)/', '$1', $s); + return $s; + } +} diff --git a/vendor/tracy/tracy/src/Tracy/Dumper/Value.php b/vendor/tracy/tracy/src/Tracy/Dumper/Value.php new file mode 100644 index 0000000..0f136b2 --- /dev/null +++ b/vendor/tracy/tracy/src/Tracy/Dumper/Value.php @@ -0,0 +1,81 @@ +type = $type; + $this->value = $value; + $this->length = $length; + } + + + public function jsonSerialize(): array + { + $res = [$this->type => $this->value]; + foreach (['length', 'editor', 'items', 'collapsed'] as $k) { + if ($this->$k !== null) { + $res[$k] = $this->$k; + } + } + return $res; + } +} diff --git a/vendor/tracy/tracy/src/Tracy/Dumper/assets/dumper-dark.css b/vendor/tracy/tracy/src/Tracy/Dumper/assets/dumper-dark.css new file mode 100644 index 0000000..3540edd --- /dev/null +++ b/vendor/tracy/tracy/src/Tracy/Dumper/assets/dumper-dark.css @@ -0,0 +1,145 @@ +/** + * This file is part of the Tracy (https://tracy.nette.org) + */ + +.tracy-dump.tracy-dark { + text-align: left; + color: #f8f8f2; + background: #29292e; + border-radius: 4px; + padding: 1em; + margin: 1em 0; + word-break: break-all; + white-space: pre-wrap; +} + +.tracy-dump.tracy-dark div { + padding-left: 2.5ex; +} + +.tracy-dump.tracy-dark div div { + border-left: 1px solid rgba(255, 255, 255, .1); + margin-left: .5ex; +} + +.tracy-dump.tracy-dark div div:hover { + border-left-color: rgba(255, 255, 255, .25); +} + +.tracy-dark .tracy-dump-location { + color: silver; + font-size: 80%; + text-decoration: none; + background: none; + opacity: .5; + float: right; + cursor: pointer; +} + +.tracy-dark .tracy-dump-location:hover, +.tracy-dark .tracy-dump-location:focus { + opacity: 1; +} + +.tracy-dark .tracy-dump-array, +.tracy-dark .tracy-dump-object { + color: #f69c2e; + user-select: text; +} + +.tracy-dark .tracy-dump-string { + color: #3cdfef; + white-space: break-spaces; +} + +.tracy-dark div.tracy-dump-string { + position: relative; + padding-left: 3.5ex; +} + +.tracy-dark .tracy-dump-lq { + margin-left: calc(-1ex - 1px); +} + +.tracy-dark div.tracy-dump-string:before { + content: ''; + position: absolute; + left: calc(3ex - 1px); + top: 1.5em; + bottom: 0; + border-left: 1px solid rgba(255, 255, 255, .1); +} + +.tracy-dark .tracy-dump-virtual span, +.tracy-dark .tracy-dump-dynamic span, +.tracy-dark .tracy-dump-string span { + color: rgba(255, 255, 255, 0.5); +} + +.tracy-dark .tracy-dump-virtual i, +.tracy-dark .tracy-dump-dynamic i, +.tracy-dark .tracy-dump-string i { + font-size: 80%; + font-style: normal; + color: rgba(255, 255, 255, 0.5); + user-select: none; +} + +.tracy-dark .tracy-dump-number { + color: #77d285; +} + +.tracy-dark .tracy-dump-null, +.tracy-dark .tracy-dump-bool { + color: #f3cb44; +} + +.tracy-dark .tracy-dump-virtual { + font-style: italic; +} + +.tracy-dark .tracy-dump-public::after { + content: ' pub'; +} + +.tracy-dark .tracy-dump-protected::after { + content: ' pro'; +} + +.tracy-dark .tracy-dump-private::after { + content: ' pri'; +} + +.tracy-dark .tracy-dump-public::after, +.tracy-dark .tracy-dump-protected::after, +.tracy-dark .tracy-dump-private::after, +.tracy-dark .tracy-dump-hash { + font-size: 85%; + color: rgba(255, 255, 255, 0.4); +} + +.tracy-dark .tracy-dump-indent { + display: none; +} + +.tracy-dark .tracy-dump-highlight { + background: #C22; + color: white; + border-radius: 2px; + padding: 0 2px; + margin: 0 -2px; +} + +span[data-tracy-href] { + border-bottom: 1px dotted rgba(255, 255, 255, .2); +} + +.tracy-dark .tracy-dump-flash { + animation: tracy-dump-flash .2s ease; +} + +@keyframes tracy-dump-flash { + 0% { + background: #c0c0c033; + } +} diff --git a/vendor/tracy/tracy/src/Tracy/Dumper/assets/dumper-light.css b/vendor/tracy/tracy/src/Tracy/Dumper/assets/dumper-light.css new file mode 100644 index 0000000..69aba78 --- /dev/null +++ b/vendor/tracy/tracy/src/Tracy/Dumper/assets/dumper-light.css @@ -0,0 +1,145 @@ +/** + * This file is part of the Tracy (https://tracy.nette.org) + */ + +.tracy-dump.tracy-light { + text-align: left; + color: #444; + background: #fdf9e2; + border-radius: 4px; + padding: 1em; + margin: 1em 0; + word-break: break-all; + white-space: pre-wrap; +} + +.tracy-dump.tracy-light div { + padding-left: 2.5ex; +} + +.tracy-dump.tracy-light div div { + border-left: 1px solid rgba(0, 0, 0, .1); + margin-left: .5ex; +} + +.tracy-dump.tracy-light div div:hover { + border-left-color: rgba(0, 0, 0, .25); +} + +.tracy-light .tracy-dump-location { + color: gray; + font-size: 80%; + text-decoration: none; + background: none; + opacity: .5; + float: right; + cursor: pointer; +} + +.tracy-light .tracy-dump-location:hover, +.tracy-light .tracy-dump-location:focus { + opacity: 1; +} + +.tracy-light .tracy-dump-array, +.tracy-light .tracy-dump-object { + color: #C22; + user-select: text; +} + +.tracy-light .tracy-dump-string { + color: #35D; + white-space: break-spaces; +} + +.tracy-light div.tracy-dump-string { + position: relative; + padding-left: 3.5ex; +} + +.tracy-light .tracy-dump-lq { + margin-left: calc(-1ex - 1px); +} + +.tracy-light div.tracy-dump-string:before { + content: ''; + position: absolute; + left: calc(3ex - 1px); + top: 1.5em; + bottom: 0; + border-left: 1px solid rgba(0, 0, 0, .1); +} + +.tracy-light .tracy-dump-virtual span, +.tracy-light .tracy-dump-dynamic span, +.tracy-light .tracy-dump-string span { + color: rgba(0, 0, 0, 0.5); +} + +.tracy-light .tracy-dump-virtual i, +.tracy-light .tracy-dump-dynamic i, +.tracy-light .tracy-dump-string i { + font-size: 80%; + font-style: normal; + color: rgba(0, 0, 0, 0.5); + user-select: none; +} + +.tracy-light .tracy-dump-number { + color: #090; +} + +.tracy-light .tracy-dump-null, +.tracy-light .tracy-dump-bool { + color: #850; +} + +.tracy-light .tracy-dump-virtual { + font-style: italic; +} + +.tracy-light .tracy-dump-public::after { + content: ' pub'; +} + +.tracy-light .tracy-dump-protected::after { + content: ' pro'; +} + +.tracy-light .tracy-dump-private::after { + content: ' pri'; +} + +.tracy-light .tracy-dump-public::after, +.tracy-light .tracy-dump-protected::after, +.tracy-light .tracy-dump-private::after, +.tracy-light .tracy-dump-hash { + font-size: 85%; + color: rgba(0, 0, 0, 0.5); +} + +.tracy-light .tracy-dump-indent { + display: none; +} + +.tracy-light .tracy-dump-highlight { + background: #C22; + color: white; + border-radius: 2px; + padding: 0 2px; + margin: 0 -2px; +} + +span[data-tracy-href] { + border-bottom: 1px dotted rgba(0, 0, 0, .2); +} + +.tracy-light .tracy-dump-flash { + animation: tracy-dump-flash .2s ease; +} + +@keyframes tracy-dump-flash { + 0% { + background: #c0c0c033; + } +} diff --git a/vendor/tracy/tracy/src/Tracy/Dumper/assets/dumper.js b/vendor/tracy/tracy/src/Tracy/Dumper/assets/dumper.js new file mode 100644 index 0000000..457d765 --- /dev/null +++ b/vendor/tracy/tracy/src/Tracy/Dumper/assets/dumper.js @@ -0,0 +1,388 @@ +/** + * This file is part of the Tracy (https://tracy.nette.org) + */ + +const + COLLAPSE_COUNT = 7, + COLLAPSE_COUNT_TOP = 14, + TYPE_ARRAY = 'a', + TYPE_OBJECT = 'o', + TYPE_RESOURCE = 'r', + PROP_VIRTUAL = 4, + PROP_PRIVATE = 2; + +const + HINT_CTRL = 'Ctrl-Click to open in editor', + HINT_ALT = 'Alt-Click to expand/collapse all child nodes'; + +class Dumper +{ + static init(context) { + // full lazy + (context || document).querySelectorAll('[data-tracy-snapshot][data-tracy-dump]').forEach((pre) => { //
+			let snapshot = JSON.parse(pre.getAttribute('data-tracy-snapshot'));
+			pre.removeAttribute('data-tracy-snapshot');
+			pre.appendChild(build(JSON.parse(pre.getAttribute('data-tracy-dump')), snapshot, pre.classList.contains('tracy-collapsed')));
+			pre.removeAttribute('data-tracy-dump');
+			pre.classList.remove('tracy-collapsed');
+		});
+
+		// snapshots
+		(context || document).querySelectorAll('meta[itemprop=tracy-snapshot]').forEach((meta) => {
+			let snapshot = JSON.parse(meta.getAttribute('content'));
+			meta.parentElement.querySelectorAll('[data-tracy-dump]').forEach((pre) => { // 
+				if (pre.closest('[data-tracy-snapshot]')) { // ignore unrelated 
+					return;
+				}
+				pre.appendChild(build(JSON.parse(pre.getAttribute('data-tracy-dump')), snapshot, pre.classList.contains('tracy-collapsed')));
+				pre.removeAttribute('data-tracy-dump');
+				pre.classList.remove('tracy-collapsed');
+			});
+			//  must be left for debug bar panel content
+		});
+
+		if (Dumper.inited) {
+			return;
+		}
+		Dumper.inited = true;
+
+		document.documentElement.addEventListener('click', (e) => {
+			let el;
+			// enables  & ctrl key
+			if (e.ctrlKey && (el = e.target.closest('[data-tracy-href]'))) {
+				location.href = el.getAttribute('data-tracy-href');
+				return false;
+			}
+
+			// initializes lazy  inside 
+			if ((el = e.target.closest('[data-tracy-snapshot]'))) {
+				let snapshot = JSON.parse(el.getAttribute('data-tracy-snapshot'));
+				el.removeAttribute('data-tracy-snapshot');
+				el.querySelectorAll('[data-tracy-dump]').forEach((toggler) => {
+					if (!toggler.nextSibling) {
+						toggler.after(document.createTextNode('\n')); // enforce \n after toggler
+					}
+					toggler.nextSibling.after(buildStruct(JSON.parse(toggler.getAttribute('data-tracy-dump')), snapshot, toggler, true, []));
+					toggler.removeAttribute('data-tracy-dump');
+				});
+			}
+		});
+
+		document.documentElement.addEventListener('tracy-toggle', (e) => {
+			if (!e.target.matches('.tracy-dump *')) {
+				return;
+			}
+
+			let cont = e.detail.relatedTarget;
+			let origE = e.detail.originalEvent;
+
+			if (origE && origE.usedIds) { // triggered by expandChild()
+				toggleChildren(cont, origE.usedIds);
+				return;
+
+			} else if (origE && origE.altKey && cont.querySelector('.tracy-toggle')) { // triggered by alt key
+				if (e.detail.collapsed) { // reopen
+					e.target.classList.toggle('tracy-collapsed', false);
+					cont.classList.toggle('tracy-collapsed', false);
+					e.detail.collapsed = false;
+				}
+
+				let expand = e.target.tracyAltExpand = !e.target.tracyAltExpand;
+				toggleChildren(cont, expand ? {} : false);
+			}
+
+			cont.classList.toggle('tracy-dump-flash', !e.detail.collapsed);
+		});
+
+		document.documentElement.addEventListener('animationend', (e) => {
+			if (e.animationName === 'tracy-dump-flash') {
+				e.target.classList.toggle('tracy-dump-flash', false);
+			}
+		});
+
+		document.addEventListener('mouseover', (e) => {
+			if (!e.target.matches('.tracy-dump *')) {
+				return;
+			}
+
+			let el;
+
+			if (e.target.matches('.tracy-dump-hash') && (el = e.target.closest('.tracy-dump'))) {
+				el.querySelectorAll('.tracy-dump-hash').forEach((el) => {
+					if (el.textContent === e.target.textContent) {
+						el.classList.add('tracy-dump-highlight');
+					}
+				});
+				return;
+			}
+
+			if ((el = e.target.closest('.tracy-toggle')) && !el.title) {
+				el.title = HINT_ALT;
+			}
+		});
+
+		document.addEventListener('mouseout', (e) => {
+			if (e.target.matches('.tracy-dump-hash')) {
+				document.querySelectorAll('.tracy-dump-hash.tracy-dump-highlight').forEach((el) => {
+					el.classList.remove('tracy-dump-highlight');
+				});
+			}
+		});
+
+		Tracy.Toggle.init();
+	}
+}
+
+
+function build(data, repository, collapsed, parentIds, keyType) {
+	let id, type = data === null ? 'null' : typeof data,
+		collapseCount = collapsed === null ? COLLAPSE_COUNT : COLLAPSE_COUNT_TOP;
+
+	if (type === 'null' || type === 'number' || type === 'boolean') {
+		return createEl(null, null, [
+			createEl(
+				'span',
+				{'class': 'tracy-dump-' + type.replace('ean', '')},
+				[data + '']
+			)
+		]);
+
+	} else if (type === 'string') {
+		data = {
+			string: data.replace(/&/g, '&').replace(/\'' + s + '\''}
+				),
+			]);
+
+		} else if (keyType !== undefined) {
+			if (type !== 'string') {
+				s = '\'' + s + '\'';
+			}
+
+			const classes = [
+				'tracy-dump-public',
+				'tracy-dump-protected',
+				'tracy-dump-private',
+				'tracy-dump-dynamic',
+				'tracy-dump-virtual',
+			];
+			return createEl(null, null, [
+				createEl(
+					'span',
+					{
+						'class': classes[typeof keyType === 'string' ? PROP_PRIVATE : keyType],
+						'title': typeof keyType === 'string' ? 'declared in ' + keyType : null,
+					},
+					{html: s}
+				),
+			]);
+		}
+
+		let count = (s.match(/\n/g) || []).length;
+		if (count) {
+			let collapsed = count >= COLLAPSE_COUNT;
+			return createEl(null, null, [
+				createEl('span', {'class': collapsed ? 'tracy-toggle tracy-collapsed' : 'tracy-toggle'}, ['string']),
+				'\n',
+				createEl(
+					'div',
+					{
+						'class': 'tracy-dump-string' + (collapsed ? ' tracy-collapsed' : ''),
+						'title': data.length + (data.bin ? ' bytes' : ' characters'),
+					},
+					{html: '\'' + s + '\''}
+				),
+			]);
+		}
+
+		return createEl(null, null, [
+			createEl(
+				'span',
+				{
+					'class': 'tracy-dump-string',
+					'title': data.length + (data.bin ? ' bytes' : ' characters'),
+				},
+				{html: '\'' + s + '\''}
+			),
+		]);
+
+	} else if (data.number) {
+		return createEl(null, null, [
+			createEl('span', {'class': 'tracy-dump-number'}, [data.number])
+		]);
+
+	} else if (data.text !== undefined) {
+		return createEl(null, null, [
+			createEl('span', {class: 'tracy-dump-virtual'}, [data.text])
+		]);
+
+	} else { // object || resource || array
+		let span = data.array !== undefined
+			? [
+				createEl('span', {'class': 'tracy-dump-array'}, ['array']),
+				' (' + (data.length || data.items.length) + ')'
+			]
+			: [
+				createEl('span', {
+					'class': data.object ? 'tracy-dump-object' : 'tracy-dump-resource',
+					title: data.editor ? 'Declared in file ' + data.editor.file + ' on line ' + data.editor.line + (data.editor.url ? '\n' + HINT_CTRL : '') + '\n' + HINT_ALT : null,
+					'data-tracy-href': data.editor ? data.editor.url : null
+				}, [data.object || data.resource]),
+				...(id ? [' ', createEl('span', {'class': 'tracy-dump-hash'}, [data.resource ? '@' + id.substr(1) : '#' + id])] : [])
+			];
+
+		parentIds = parentIds ? parentIds.slice() : [];
+		let recursive = id && parentIds.indexOf(id) > -1;
+		parentIds.push(id);
+
+		if (recursive || !data.items || !data.items.length) {
+			span.push(recursive ? ' RECURSION' : (!data.items || data.items.length ? ' …' : ''));
+			return createEl(null, null, span);
+		}
+
+		collapsed = collapsed === true || data.collapsed || (data.items && data.items.length >= collapseCount);
+		let toggle = createEl('span', {'class': collapsed ? 'tracy-toggle tracy-collapsed' : 'tracy-toggle'}, span);
+
+		return createEl(null, null, [
+			toggle,
+			'\n',
+			buildStruct(data, repository, toggle, collapsed, parentIds),
+		]);
+	}
+}
+
+
+function buildStruct(data, repository, toggle, collapsed, parentIds) {
+	if (Array.isArray(data)) {
+		data = {items: data};
+
+	} else if (data.ref) {
+		parentIds = parentIds.slice();
+		parentIds.push(data.ref);
+		data = repository[data.ref];
+	}
+
+	let cut = data.items && data.length > data.items.length;
+	let type = data.object ? TYPE_OBJECT : data.resource ? TYPE_RESOURCE : TYPE_ARRAY;
+	let div = createEl('div', {'class': collapsed ? 'tracy-collapsed' : null});
+
+	if (collapsed) {
+		let handler;
+		toggle.addEventListener('tracy-toggle', handler = function() {
+			toggle.removeEventListener('tracy-toggle', handler);
+			createItems(div, data.items, type, repository, parentIds, null);
+			if (cut) {
+				createEl(div, null, ['…\n']);
+			}
+		});
+	} else {
+		createItems(div, data.items, type, repository, parentIds, true);
+		if (cut) {
+			createEl(div, null, ['…\n']);
+		}
+	}
+
+	return div;
+}
+
+
+function createEl(el, attrs, content) {
+	if (!(el instanceof Node)) {
+		el = el ? document.createElement(el) : document.createDocumentFragment();
+	}
+	for (let id in attrs || {}) {
+		if (attrs[id] !== null) {
+			el.setAttribute(id, attrs[id]);
+		}
+	}
+
+	if (content && content.html !== undefined) {
+		el.innerHTML = content.html;
+		return el;
+	}
+	content = content || [];
+	for (let id = 0; id < content.length; id++) {
+		let child = content[id];
+		if (child !== null) {
+			el.appendChild(child instanceof Node ? child : document.createTextNode(child));
+		}
+	}
+	return el;
+}
+
+
+function createItems(el, items, type, repository, parentIds, collapsed) {
+	let key, val, vis, ref, i, tmp;
+
+	for (i = 0; i < items.length; i++) {
+		if (type === TYPE_ARRAY) {
+			[key, val, ref] = items[i];
+		} else {
+			[key, val, vis = PROP_VIRTUAL, ref] = items[i];
+		}
+
+		createEl(el, null, [
+			build(key, null, null, null, type === TYPE_ARRAY ? TYPE_ARRAY : vis),
+			type === TYPE_ARRAY ? ' => ' : ': ',
+			...(ref ? [createEl('span', {'class': 'tracy-dump-hash'}, ['&' + ref]), ' '] : []),
+			tmp = build(val, repository, collapsed, parentIds),
+			tmp.lastElementChild.tagName === 'DIV' ? '' : '\n',
+		]);
+	}
+}
+
+
+function toggleChildren(cont, usedIds) {
+	let hashEl, id;
+
+	cont.querySelectorAll(':scope > .tracy-toggle').forEach((el) => {
+		hashEl = (el.querySelector('.tracy-dump-hash') || el.previousElementSibling);
+		id = hashEl && hashEl.matches('.tracy-dump-hash') ? hashEl.textContent : null;
+
+		if (!usedIds || (id && usedIds[id])) {
+			Tracy.Toggle.toggle(el, false);
+		} else {
+			usedIds[id] = true;
+			Tracy.Toggle.toggle(el, true, {usedIds: usedIds});
+		}
+	});
+}
+
+
+function UnknownEntityException() {}
+
+
+let Tracy = window.Tracy = window.Tracy || {};
+Tracy.Dumper = Tracy.Dumper || Dumper;
+
+function init() {
+	Tracy.Dumper.init();
+}
+
+if (document.readyState === 'loading') {
+	document.addEventListener('DOMContentLoaded', init);
+} else {
+	init();
+}
diff --git a/vendor/tracy/tracy/src/Tracy/Helpers.php b/vendor/tracy/tracy/src/Tracy/Helpers.php
new file mode 100644
index 0000000..9632a19
--- /dev/null
+++ b/vendor/tracy/tracy/src/Tracy/Helpers.php
@@ -0,0 +1,525 @@
+ strlen($m[0])) {
+				$file = '...' . $m[0];
+			}
+			$file = strtr($file, '/', DIRECTORY_SEPARATOR);
+			return self::formatHtml(
+				'%%%',
+				$editor,
+				$origFile . ($line ? ":$line" : ''),
+				rtrim(dirname($file), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR,
+				basename($file),
+				$line ? ":$line" : ''
+			);
+		} else {
+			return self::formatHtml('%', $file . ($line ? ":$line" : ''));
+		}
+	}
+
+
+	/**
+	 * Returns link to editor.
+	 */
+	public static function editorUri(
+		string $file,
+		int $line = null,
+		string $action = 'open',
+		string $search = '',
+		string $replace = ''
+	): ?string {
+		if (Debugger::$editor && $file && ($action === 'create' || is_file($file))) {
+			$file = strtr($file, '/', DIRECTORY_SEPARATOR);
+			$file = strtr($file, Debugger::$editorMapping);
+			return strtr(Debugger::$editor, [
+				'%action' => $action,
+				'%file' => rawurlencode($file),
+				'%line' => $line ?: 1,
+				'%search' => rawurlencode($search),
+				'%replace' => rawurlencode($replace),
+			]);
+		}
+		return null;
+	}
+
+
+	public static function formatHtml(string $mask): string
+	{
+		$args = func_get_args();
+		return preg_replace_callback('#%#', function () use (&$args, &$count): string {
+			return str_replace("\n", '
', self::escapeHtml($args[++$count]));
+		}, $mask);
+	}
+
+
+	public static function escapeHtml($s): string
+	{
+		return htmlspecialchars((string) $s, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML5, 'UTF-8');
+	}
+
+
+	public static function findTrace(array $trace, $method, int &$index = null): ?array
+	{
+		$m = is_array($method) ? $method : explode('::', $method);
+		foreach ($trace as $i => $item) {
+			if (
+				isset($item['function'])
+				&& $item['function'] === end($m)
+				&& isset($item['class']) === isset($m[1])
+				&& (!isset($item['class']) || $m[0] === '*' || is_a($item['class'], $m[0], true))
+			) {
+				$index = $i;
+				return $item;
+			}
+		}
+		return null;
+	}
+
+
+	public static function getClass($obj): string
+	{
+		return explode("\x00", get_class($obj))[0];
+	}
+
+
+	/** @internal */
+	public static function fixStack(\Throwable $exception): \Throwable
+	{
+		if (function_exists('xdebug_get_function_stack')) {
+			$stack = [];
+			$trace = @xdebug_get_function_stack(); // @ xdebug compatibility warning
+			$trace = array_slice(array_reverse($trace), 2, -1);
+			foreach ($trace as $row) {
+				$frame = [
+					'file' => $row['file'],
+					'line' => $row['line'],
+					'function' => $row['function'] ?? '*unknown*',
+					'args' => [],
+				];
+				if (!empty($row['class'])) {
+					$frame['type'] = isset($row['type']) && $row['type'] === 'dynamic' ? '->' : '::';
+					$frame['class'] = $row['class'];
+				}
+				$stack[] = $frame;
+			}
+			$ref = new \ReflectionProperty('Exception', 'trace');
+			$ref->setAccessible(true);
+			$ref->setValue($exception, $stack);
+		}
+		return $exception;
+	}
+
+
+	/** @internal */
+	public static function errorTypeToString(int $type): string
+	{
+		$types = [
+			E_ERROR => 'Fatal Error',
+			E_USER_ERROR => 'User Error',
+			E_RECOVERABLE_ERROR => 'Recoverable Error',
+			E_CORE_ERROR => 'Core Error',
+			E_COMPILE_ERROR => 'Compile Error',
+			E_PARSE => 'Parse Error',
+			E_WARNING => 'Warning',
+			E_CORE_WARNING => 'Core Warning',
+			E_COMPILE_WARNING => 'Compile Warning',
+			E_USER_WARNING => 'User Warning',
+			E_NOTICE => 'Notice',
+			E_USER_NOTICE => 'User Notice',
+			E_STRICT => 'Strict standards',
+			E_DEPRECATED => 'Deprecated',
+			E_USER_DEPRECATED => 'User Deprecated',
+		];
+		return $types[$type] ?? 'Unknown error';
+	}
+
+
+	/** @internal */
+	public static function getSource(): string
+	{
+		if (isset($_SERVER['REQUEST_URI'])) {
+			return (!empty($_SERVER['HTTPS']) && strcasecmp($_SERVER['HTTPS'], 'off') ? 'https://' : 'http://')
+				. ($_SERVER['HTTP_HOST'] ?? '')
+				. $_SERVER['REQUEST_URI'];
+		} else {
+			return 'CLI (PID: ' . getmypid() . ')'
+				. (isset($_SERVER['argv']) ? ': ' . implode(' ', array_map([self::class, 'escapeArg'], $_SERVER['argv'])) : '');
+		}
+	}
+
+
+	/** @internal */
+	public static function improveException(\Throwable $e): void
+	{
+		$message = $e->getMessage();
+		if (
+			(!$e instanceof \Error && !$e instanceof \ErrorException)
+			|| $e instanceof \Nette\MemberAccessException
+			|| strpos($e->getMessage(), 'did you mean')
+		) {
+			// do nothing
+		} elseif (preg_match('#^Call to undefined function (\S+\\\\)?(\w+)\(#', $message, $m)) {
+			$funcs = array_merge(get_defined_functions()['internal'], get_defined_functions()['user']);
+			$hint = self::getSuggestion($funcs, $m[1] . $m[2]) ?: self::getSuggestion($funcs, $m[2]);
+			$message = "Call to undefined function $m[2](), did you mean $hint()?";
+			$replace = ["$m[2](", "$hint("];
+
+		} elseif (preg_match('#^Call to undefined method ([\w\\\\]+)::(\w+)#', $message, $m)) {
+			$hint = self::getSuggestion(get_class_methods($m[1]) ?: [], $m[2]);
+			$message .= ", did you mean $hint()?";
+			$replace = ["$m[2](", "$hint("];
+
+		} elseif (preg_match('#^Undefined variable:? \$?(\w+)#', $message, $m) && !empty($e->context)) {
+			$hint = self::getSuggestion(array_keys($e->context), $m[1]);
+			$message = "Undefined variable $$m[1], did you mean $$hint?";
+			$replace = ["$$m[1]", "$$hint"];
+
+		} elseif (preg_match('#^Undefined property: ([\w\\\\]+)::\$(\w+)#', $message, $m)) {
+			$rc = new \ReflectionClass($m[1]);
+			$items = array_filter($rc->getProperties(\ReflectionProperty::IS_PUBLIC), function ($prop) { return !$prop->isStatic(); });
+			$hint = self::getSuggestion($items, $m[2]);
+			$message .= ", did you mean $$hint?";
+			$replace = ["->$m[2]", "->$hint"];
+
+		} elseif (preg_match('#^Access to undeclared static property:? ([\w\\\\]+)::\$(\w+)#', $message, $m)) {
+			$rc = new \ReflectionClass($m[1]);
+			$items = array_filter($rc->getProperties(\ReflectionProperty::IS_STATIC), function ($prop) { return $prop->isPublic(); });
+			$hint = self::getSuggestion($items, $m[2]);
+			$message .= ", did you mean $$hint?";
+			$replace = ["::$$m[2]", "::$$hint"];
+		}
+
+		if (isset($hint)) {
+			$ref = new \ReflectionProperty($e, 'message');
+			$ref->setAccessible(true);
+			$ref->setValue($e, $message);
+			$e->tracyAction = [
+				'link' => self::editorUri($e->getFile(), $e->getLine(), 'fix', $replace[0], $replace[1]),
+				'label' => 'fix it',
+			];
+		}
+	}
+
+
+	/** @internal */
+	public static function improveError(string $message, array $context = []): string
+	{
+		if (preg_match('#^Undefined variable:? \$?(\w+)#', $message, $m) && $context) {
+			$hint = self::getSuggestion(array_keys($context), $m[1]);
+			return $hint
+				? "Undefined variable $$m[1], did you mean $$hint?"
+				: $message;
+
+		} elseif (preg_match('#^Undefined property: ([\w\\\\]+)::\$(\w+)#', $message, $m)) {
+			$rc = new \ReflectionClass($m[1]);
+			$items = array_filter($rc->getProperties(\ReflectionProperty::IS_PUBLIC), function ($prop) { return !$prop->isStatic(); });
+			$hint = self::getSuggestion($items, $m[2]);
+			return $hint ? $message . ", did you mean $$hint?" : $message;
+		}
+		return $message;
+	}
+
+
+	/** @internal */
+	public static function guessClassFile(string $class): ?string
+	{
+		$segments = explode('\\', $class);
+		$res = null;
+		$max = 0;
+		foreach (get_declared_classes() as $class) {
+			$parts = explode('\\', $class);
+			foreach ($parts as $i => $part) {
+				if ($part !== ($segments[$i] ?? null)) {
+					break;
+				}
+			}
+			if ($i > $max && $i < count($segments) && ($file = (new \ReflectionClass($class))->getFileName())) {
+				$max = $i;
+				$res = array_merge(array_slice(explode(DIRECTORY_SEPARATOR, $file), 0, $i - count($parts)), array_slice($segments, $i));
+				$res = implode(DIRECTORY_SEPARATOR, $res) . '.php';
+			}
+		}
+		return $res;
+	}
+
+
+	/**
+	 * Finds the best suggestion.
+	 * @internal
+	 */
+	public static function getSuggestion(array $items, string $value): ?string
+	{
+		$best = null;
+		$min = (strlen($value) / 4 + 1) * 10 + .1;
+		$items = array_map(function ($item) {
+			return $item instanceof \Reflector ? $item->getName() : (string) $item;
+		}, $items);
+		foreach (array_unique($items) as $item) {
+			if (($len = levenshtein($item, $value, 10, 11, 10)) > 0 && $len < $min) {
+				$min = $len;
+				$best = $item;
+			}
+		}
+		return $best;
+	}
+
+
+	/** @internal */
+	public static function isHtmlMode(): bool
+	{
+		return empty($_SERVER['HTTP_X_REQUESTED_WITH']) && empty($_SERVER['HTTP_X_TRACY_AJAX'])
+			&& PHP_SAPI !== 'cli'
+			&& !preg_match('#^Content-Type: (?!text/html)#im', implode("\n", headers_list()));
+	}
+
+
+	/** @internal */
+	public static function isAjax(): bool
+	{
+		return isset($_SERVER['HTTP_X_TRACY_AJAX']) && preg_match('#^\w{10,15}$#D', $_SERVER['HTTP_X_TRACY_AJAX']);
+	}
+
+
+	/** @internal */
+	public static function getNonce(): ?string
+	{
+		return preg_match('#^Content-Security-Policy(?:-Report-Only)?:.*\sscript-src\s+(?:[^;]+\s)?\'nonce-([\w+/]+=*)\'#mi', implode("\n", headers_list()), $m)
+			? $m[1]
+			: null;
+	}
+
+
+	/**
+	 * Escape a string to be used as a shell argument.
+	 */
+	private static function escapeArg(string $s): string
+	{
+		if (preg_match('#^[a-z0-9._=/:-]+$#Di', $s)) {
+			return $s;
+		}
+
+		return defined('PHP_WINDOWS_VERSION_BUILD')
+			? '"' . str_replace('"', '""', $s) . '"'
+			: escapeshellarg($s);
+	}
+
+
+	/**
+	 * Captures PHP output into a string.
+	 */
+	public static function capture(callable $func): string
+	{
+		ob_start(function () {});
+		try {
+			$func();
+			return ob_get_clean();
+		} catch (\Throwable $e) {
+			ob_end_clean();
+			throw $e;
+		}
+	}
+
+
+	/** @internal */
+	public static function encodeString(string $s, int $maxLength = null, bool $showWhitespaces = true): string
+	{
+		static $tableU, $tableB;
+		if ($tableU === null) {
+			foreach (range("\x00", "\x1F") as $ch) {
+				$tableU[$ch] = '\x' . str_pad(strtoupper(dechex(ord($ch))), 2, '0', STR_PAD_LEFT) . '';
+			}
+			$tableB = $tableU = [
+				"\r" => '\r',
+				"\n" => "\\n\n",
+				"\t" => '\t    ',
+				"\e" => '\e',
+				'<' => '<',
+				'&' => '&',
+			] + $tableU;
+			foreach (range("\x7F", "\xFF") as $ch) {
+				$tableB[$ch] = '\x' . str_pad(strtoupper(dechex(ord($ch))), 2, '0', STR_PAD_LEFT) . '';
+			}
+		}
+
+		$utf = self::isUtf8($s);
+		$table = $utf ? $tableU : $tableB;
+		if (!$showWhitespaces) {
+			unset($table["\r"], $table["\n"], $table["\t"]);
+		}
+
+		$len = $utf ? self::utf8Length($s) : strlen($s);
+		$s = $maxLength && $len > $maxLength + 20
+			? strtr(self::truncateString($s, $maxLength, $utf), $table)
+				. '  '
+				. strtr(self::truncateString($s, -10, $utf), $table)
+			: strtr($s, $table);
+
+		$s = str_replace('', '', $s);
+		$s = preg_replace('~\n$~D', '', $s);
+		return $s;
+	}
+
+
+	/** @internal */
+	public static function utf8Length(string $s): int
+	{
+		return strlen(utf8_decode($s));
+	}
+
+
+	/** @internal */
+	public static function isUtf8(string $s): bool
+	{
+		return (bool) preg_match('##u', $s);
+	}
+
+
+	/** @internal */
+	public static function truncateString(string $s, int $len, bool $utf): string
+	{
+		if (!$utf) {
+			return $len < 0 ? substr($s, $len) : substr($s, 0, $len);
+		} elseif (function_exists('mb_substr')) {
+			return $len < 0
+				? mb_substr($s, $len, -$len, 'UTF-8')
+				: mb_substr($s, 0, $len, 'UTF-8');
+		} else {
+			$len < 0
+				? preg_match('#.{0,' . -$len . '}\z#us', $s, $m)
+				: preg_match("#^.{0,$len}#us", $s, $m);
+			return $m[0];
+		}
+	}
+
+
+	/** @internal */
+	public static function minifyJs(string $s): string
+	{
+		// author: Jakub Vrana https://php.vrana.cz/minifikace-javascriptu.php
+		$last = '';
+		return preg_replace_callback(
+			<<<'XX'
+			(
+				(?:
+					(^|[-+\([{}=,:;!%^&*|?~]|/(?![/*])|return|throw) # context before regexp
+					(?:\s|//[^\n]*+\n|/\*(?:[^*]|\*(?!/))*+\*/)* # optional space
+					(/(?![/*])(?:\\[^\n]|[^[\n/\\]|\[(?:\\[^\n]|[^]])++)+/) # regexp
+					|(^
+						|'(?:\\.|[^\n'\\])*'
+						|"(?:\\.|[^\n"\\])*"
+						|([0-9A-Za-z_$]+)
+						|([-+]+)
+						|.
+					)
+				)(?:\s|//[^\n]*+\n|/\*(?:[^*]|\*(?!/))*+\*/)* # optional space
+			())sx
+XX
+,
+			function ($match) use (&$last) {
+				[, $context, $regexp, $result, $word, $operator] = $match;
+				if ($word !== '') {
+					$result = ($last === 'word' ? ' ' : ($last === 'return' ? ' ' : '')) . $result;
+					$last = ($word === 'return' || $word === 'throw' || $word === 'break' ? 'return' : 'word');
+				} elseif ($operator) {
+					$result = ($last === $operator[0] ? ' ' : '') . $result;
+					$last = $operator[0];
+				} else {
+					if ($regexp) {
+						$result = $context . ($context === '/' ? ' ' : '') . $regexp;
+					}
+					$last = '';
+				}
+				return $result;
+			},
+			$s . "\n"
+		);
+	}
+
+
+	/** @internal */
+	public static function minifyCss(string $s): string
+	{
+		$last = '';
+		return preg_replace_callback(
+			<<<'XX'
+			(
+				(^
+					|'(?:\\.|[^\n'\\])*'
+					|"(?:\\.|[^\n"\\])*"
+					|([0-9A-Za-z_*#.%:()[\]-]+)
+					|.
+				)(?:\s|/\*(?:[^*]|\*(?!/))*+\*/)* # optional space
+			())sx
+XX
+,
+			function ($match) use (&$last) {
+				[, $result, $word] = $match;
+				if ($last === ';') {
+					$result = $result === '}' ? '}' : ';' . $result;
+					$last = '';
+				}
+				if ($word !== '') {
+					$result = ($last === 'word' ? ' ' : '') . $result;
+					$last = 'word';
+				} elseif ($result === ';') {
+					$last = ';';
+					$result = '';
+				} else {
+					$last = '';
+				}
+				return $result;
+			},
+			$s . "\n"
+		);
+	}
+
+
+	public static function detectColors(): bool
+	{
+		return (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg')
+			&& getenv('NO_COLOR') === false // https://no-color.org
+			&& (getenv('FORCE_COLOR')
+				|| @stream_isatty(STDOUT) // @ may trigger error 'cannot cast a filtered stream on this system'
+				|| (defined('PHP_WINDOWS_VERSION_BUILD')
+					&& (function_exists('sapi_windows_vt100_support') && sapi_windows_vt100_support(STDOUT))
+						|| getenv('ConEmuANSI') === 'ON' // ConEmu
+						|| getenv('ANSICON') !== false // ANSICON
+						|| getenv('term') === 'xterm' // MSYS
+						|| getenv('term') === 'xterm-256color' // MSYS
+					)
+			);
+	}
+
+
+	public static function getExceptionChain(\Throwable $ex): array
+	{
+		$res = [$ex];
+		while (($ex = $ex->getPrevious()) && !in_array($ex, $res, true)) {
+			$res[] = $ex;
+		}
+		return $res;
+	}
+}
diff --git a/vendor/tracy/tracy/src/Tracy/Logger/FireLogger.php b/vendor/tracy/tracy/src/Tracy/Logger/FireLogger.php
new file mode 100644
index 0000000..05c0899
--- /dev/null
+++ b/vendor/tracy/tracy/src/Tracy/Logger/FireLogger.php
@@ -0,0 +1,184 @@
+ []];
+
+
+	/**
+	 * Sends message to FireLogger console.
+	 * @param  mixed  $message
+	 */
+	public function log($message, $level = self::DEBUG): bool
+	{
+		if (!isset($_SERVER['HTTP_X_FIRELOGGER']) || headers_sent()) {
+			return false;
+		}
+
+		$item = [
+			'name' => 'PHP',
+			'level' => $level,
+			'order' => count($this->payload['logs']),
+			'time' => str_pad(number_format((microtime(true) - Debugger::$time) * 1000, 1, '.', ' '), 8, '0', STR_PAD_LEFT) . ' ms',
+			'template' => '',
+			'message' => '',
+			'style' => 'background:#767ab6',
+		];
+
+		$args = func_get_args();
+		if (isset($args[0]) && is_string($args[0])) {
+			$item['template'] = array_shift($args);
+		}
+
+		if (isset($args[0]) && $args[0] instanceof \Throwable) {
+			$e = array_shift($args);
+			$trace = $e->getTrace();
+			if (
+				isset($trace[0]['class'])
+				&& $trace[0]['class'] === Debugger::class
+				&& ($trace[0]['function'] === 'shutdownHandler' || $trace[0]['function'] === 'errorHandler')
+			) {
+				unset($trace[0]);
+			}
+
+			$file = str_replace(dirname($e->getFile(), 3), "\xE2\x80\xA6", $e->getFile());
+			$item['template'] = ($e instanceof \ErrorException ? '' : Helpers::getClass($e) . ': ')
+				. $e->getMessage() . ($e->getCode() ? ' #' . $e->getCode() : '') . ' in ' . $file . ':' . $e->getLine();
+			$item['pathname'] = $e->getFile();
+			$item['lineno'] = $e->getLine();
+
+		} else {
+			$trace = debug_backtrace();
+			if (
+				isset($trace[1]['class'])
+				&& $trace[1]['class'] === Debugger::class
+				&& ($trace[1]['function'] === 'fireLog')
+			) {
+				unset($trace[0]);
+			}
+
+			foreach ($trace as $frame) {
+				if (isset($frame['file']) && is_file($frame['file'])) {
+					$item['pathname'] = $frame['file'];
+					$item['lineno'] = $frame['line'];
+					break;
+				}
+			}
+		}
+
+		$item['exc_info'] = ['', '', []];
+		$item['exc_frames'] = [];
+
+		foreach ($trace as $frame) {
+			$frame += ['file' => null, 'line' => null, 'class' => null, 'type' => null, 'function' => null, 'object' => null, 'args' => null];
+			$item['exc_info'][2][] = [$frame['file'], $frame['line'], "$frame[class]$frame[type]$frame[function]", $frame['object']];
+			$item['exc_frames'][] = $frame['args'];
+		}
+
+		if (
+			isset($args[0])
+			&& in_array($args[0], [self::DEBUG, self::INFO, self::WARNING, self::ERROR, self::CRITICAL], true)
+		) {
+			$item['level'] = array_shift($args);
+		}
+
+		$item['args'] = $args;
+
+		$this->payload['logs'][] = $this->jsonDump($item, -1);
+		foreach (str_split(base64_encode(json_encode($this->payload, JSON_INVALID_UTF8_SUBSTITUTE)), 4990) as $k => $v) {
+			header("FireLogger-de11e-$k: $v");
+		}
+		return true;
+	}
+
+
+	/**
+	 * Dump implementation for JSON.
+	 * @param  mixed  $var
+	 * @return array|int|float|bool|string|null
+	 */
+	private function jsonDump(&$var, int $level = 0)
+	{
+		if (is_bool($var) || $var === null || is_int($var) || is_float($var)) {
+			return $var;
+
+		} elseif (is_string($var)) {
+			$var = Helpers::encodeString($var, $this->maxLength);
+			return htmlspecialchars_decode(strip_tags($var));
+
+		} elseif (is_array($var)) {
+			static $marker;
+			if ($marker === null) {
+				$marker = uniqid("\x00", true);
+			}
+			if (isset($var[$marker])) {
+				return "\xE2\x80\xA6RECURSION\xE2\x80\xA6";
+
+			} elseif ($level < $this->maxDepth || !$this->maxDepth) {
+				$var[$marker] = true;
+				$res = [];
+				foreach ($var as $k => &$v) {
+					if ($k !== $marker) {
+						$res[$this->jsonDump($k)] = $this->jsonDump($v, $level + 1);
+					}
+				}
+				unset($var[$marker]);
+				return $res;
+
+			} else {
+				return " \xE2\x80\xA6 ";
+			}
+
+		} elseif (is_object($var)) {
+			$arr = (array) $var;
+			static $list = [];
+			if (in_array($var, $list, true)) {
+				return "\xE2\x80\xA6RECURSION\xE2\x80\xA6";
+
+			} elseif ($level < $this->maxDepth || !$this->maxDepth) {
+				$list[] = $var;
+				$res = ["\x00" => '(object) ' . Helpers::getClass($var)];
+				foreach ($arr as $k => &$v) {
+					if (isset($k[0]) && $k[0] === "\x00") {
+						$k = substr($k, strrpos($k, "\x00") + 1);
+					}
+					$res[$this->jsonDump($k)] = $this->jsonDump($v, $level + 1);
+				}
+				array_pop($list);
+				return $res;
+
+			} else {
+				return " \xE2\x80\xA6 ";
+			}
+
+		} elseif (is_resource($var)) {
+			return 'resource ' . get_resource_type($var);
+
+		} else {
+			return 'unknown type';
+		}
+	}
+}
diff --git a/vendor/tracy/tracy/src/Tracy/Logger/ILogger.php b/vendor/tracy/tracy/src/Tracy/Logger/ILogger.php
new file mode 100644
index 0000000..4746c69
--- /dev/null
+++ b/vendor/tracy/tracy/src/Tracy/Logger/ILogger.php
@@ -0,0 +1,27 @@
+directory = $directory;
+		$this->email = $email;
+		$this->blueScreen = $blueScreen;
+		$this->mailer = [$this, 'defaultMailer'];
+	}
+
+
+	/**
+	 * Logs message or exception to file and sends email notification.
+	 * @param  mixed  $message
+	 * @param  string  $level  one of constant ILogger::INFO, WARNING, ERROR (sends email), EXCEPTION (sends email), CRITICAL (sends email)
+	 * @return string|null logged error filename
+	 */
+	public function log($message, $level = self::INFO)
+	{
+		if (!$this->directory) {
+			throw new \LogicException('Logging directory is not specified.');
+		} elseif (!is_dir($this->directory)) {
+			throw new \RuntimeException("Logging directory '$this->directory' is not found or is not directory.");
+		}
+
+		$exceptionFile = $message instanceof \Throwable
+			? $this->getExceptionFile($message, $level)
+			: null;
+		$line = static::formatLogLine($message, $exceptionFile);
+		$file = $this->directory . '/' . strtolower($level ?: self::INFO) . '.log';
+
+		if (!@file_put_contents($file, $line . PHP_EOL, FILE_APPEND | LOCK_EX)) { // @ is escalated to exception
+			throw new \RuntimeException("Unable to write to log file '$file'. Is directory writable?");
+		}
+
+		if ($exceptionFile) {
+			$this->logException($message, $exceptionFile);
+		}
+
+		if (in_array($level, [self::ERROR, self::EXCEPTION, self::CRITICAL], true)) {
+			$this->sendEmail($message);
+		}
+
+		return $exceptionFile;
+	}
+
+
+	/**
+	 * @param  mixed  $message
+	 */
+	public static function formatMessage($message): string
+	{
+		if ($message instanceof \Throwable) {
+			foreach (Helpers::getExceptionChain($message) as $exception) {
+				$tmp[] = ($exception instanceof \ErrorException
+					? Helpers::errorTypeToString($exception->getSeverity()) . ': ' . $exception->getMessage()
+					: Helpers::getClass($exception) . ': ' . $exception->getMessage() . ($exception->getCode() ? ' #' . $exception->getCode() : '')
+				) . ' in ' . $exception->getFile() . ':' . $exception->getLine();
+			}
+			$message = implode("\ncaused by ", $tmp);
+
+		} elseif (!is_string($message)) {
+			$message = Dumper::toText($message);
+		}
+
+		return trim($message);
+	}
+
+
+	/**
+	 * @param  mixed  $message
+	 */
+	public static function formatLogLine($message, string $exceptionFile = null): string
+	{
+		return implode(' ', [
+			date('[Y-m-d H-i-s]'),
+			preg_replace('#\s*\r?\n\s*#', ' ', static::formatMessage($message)),
+			' @  ' . Helpers::getSource(),
+			$exceptionFile ? ' @@  ' . basename($exceptionFile) : null,
+		]);
+	}
+
+
+	public function getExceptionFile(\Throwable $exception, string $level = self::EXCEPTION): string
+	{
+		foreach (Helpers::getExceptionChain($exception) as $exception) {
+			$data[] = [
+				get_class($exception), $exception->getMessage(), $exception->getCode(), $exception->getFile(), $exception->getLine(),
+				array_map(function (array $item): array { unset($item['args']); return $item; }, $exception->getTrace()),
+			];
+		}
+		$hash = substr(md5(serialize($data)), 0, 10);
+		$dir = strtr($this->directory . '/', '\\/', DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR);
+		foreach (new \DirectoryIterator($this->directory) as $file) {
+			if (strpos($file->getBasename(), $hash)) {
+				return $dir . $file;
+			}
+		}
+		return $dir . $level . '--' . date('Y-m-d--H-i') . "--$hash.html";
+	}
+
+
+	/**
+	 * Logs exception to the file if file doesn't exist.
+	 * @return string logged error filename
+	 */
+	protected function logException(\Throwable $exception, string $file = null): string
+	{
+		$file = $file ?: $this->getExceptionFile($exception);
+		$bs = $this->blueScreen ?: new BlueScreen;
+		$bs->renderToFile($exception, $file);
+		return $file;
+	}
+
+
+	/**
+	 * @param  mixed  $message
+	 */
+	protected function sendEmail($message): void
+	{
+		$snooze = is_numeric($this->emailSnooze)
+			? $this->emailSnooze
+			: strtotime($this->emailSnooze) - time();
+
+		if (
+			$this->email
+			&& $this->mailer
+			&& @filemtime($this->directory . '/email-sent') + $snooze < time() // @ file may not exist
+			&& @file_put_contents($this->directory . '/email-sent', 'sent') // @ file may not be writable
+		) {
+			($this->mailer)($message, implode(', ', (array) $this->email));
+		}
+	}
+
+
+	/**
+	 * Default mailer.
+	 * @param  mixed  $message
+	 * @internal
+	 */
+	public function defaultMailer($message, string $email): void
+	{
+		$host = preg_replace('#[^\w.-]+#', '', $_SERVER['SERVER_NAME'] ?? php_uname('n'));
+		$parts = str_replace(
+			["\r\n", "\n"],
+			["\n", PHP_EOL],
+			[
+				'headers' => implode("\n", [
+					'From: ' . ($this->fromEmail ?: "noreply@$host"),
+					'X-Mailer: Tracy',
+					'Content-Type: text/plain; charset=UTF-8',
+					'Content-Transfer-Encoding: 8bit',
+				]) . "\n",
+				'subject' => "PHP: An error occurred on the server $host",
+				'body' => static::formatMessage($message) . "\n\nsource: " . Helpers::getSource(),
+			]
+		);
+
+		mail($email, $parts['subject'], $parts['body'], $parts['headers']);
+	}
+}
diff --git a/vendor/tracy/tracy/src/Tracy/OutputDebugger/OutputDebugger.php b/vendor/tracy/tracy/src/Tracy/OutputDebugger/OutputDebugger.php
new file mode 100644
index 0000000..e5c25d4
--- /dev/null
+++ b/vendor/tracy/tracy/src/Tracy/OutputDebugger/OutputDebugger.php
@@ -0,0 +1,80 @@
+start();
+	}
+
+
+	public function start(): void
+	{
+		foreach (get_included_files() as $file) {
+			if (fread(fopen($file, 'r'), 3) === self::BOM) {
+				$this->list[] = [$file, 1, self::BOM];
+			}
+		}
+		ob_start([$this, 'handler'], 1);
+	}
+
+
+	/** @internal */
+	public function handler(string $s, int $phase): ?string
+	{
+		$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
+		if (isset($trace[0]['file'], $trace[0]['line'])) {
+			$stack = $trace;
+			unset($stack[0]['line'], $stack[0]['args']);
+			$i = count($this->list);
+			if ($i && $this->list[$i - 1][3] === $stack) {
+				$this->list[$i - 1][2] .= $s;
+			} else {
+				$this->list[] = [$trace[0]['file'], $trace[0]['line'], $s, $stack];
+			}
+		}
+		return $phase === PHP_OUTPUT_HANDLER_FINAL
+			? $this->renderHtml()
+			: null;
+	}
+
+
+	private function renderHtml(): string
+	{
+		$res = '';
+		foreach ($this->list as $item) {
+			$stack = [];
+			foreach (array_slice($item[3], 1) as $t) {
+				$t += ['class' => '', 'type' => '', 'function' => ''];
+				$stack[] = "$t[class]$t[type]$t[function]()"
+					. (isset($t['file'], $t['line']) ? ' in ' . basename($t['file']) . ":$t[line]" : '');
+			}
+
+			$res .= ''
+				. Helpers::editorLink($item[0], $item[1]) . ' '
+				. str_replace(self::BOM, 'BOM', Dumper::toHtml($item[2]))
+				. "
\n"; + } + return $res . '
'; + } +} diff --git a/vendor/tracy/tracy/src/Tracy/TableSort/table-sort.css b/vendor/tracy/tracy/src/Tracy/TableSort/table-sort.css new file mode 100644 index 0000000..7967a64 --- /dev/null +++ b/vendor/tracy/tracy/src/Tracy/TableSort/table-sort.css @@ -0,0 +1,15 @@ +/** + * This file is part of the Tracy (https://tracy.nette.org) + */ + +.tracy-sortable > :first-child > tr:first-child > * { + position: relative; +} + +.tracy-sortable > :first-child > tr:first-child > *:hover:before { + position: absolute; + right: .3em; + content: "\21C5"; + opacity: .4; + font-weight: normal; +} diff --git a/vendor/tracy/tracy/src/Tracy/TableSort/table-sort.js b/vendor/tracy/tracy/src/Tracy/TableSort/table-sort.js new file mode 100644 index 0000000..f5510f2 --- /dev/null +++ b/vendor/tracy/tracy/src/Tracy/TableSort/table-sort.js @@ -0,0 +1,38 @@ +/** + * This file is part of the Tracy (https://tracy.nette.org) + */ + +// enables +class TableSort +{ + static init() { + document.documentElement.addEventListener('click', (e) => { + if (e.target.matches('.tracy-sortable > :first-child > tr:first-child *')) { + TableSort.sort(e.target.closest('td,th')); + } + }); + + TableSort.init = function() {}; + } + + static sort(tcell) { + let tbody = tcell.closest('table').tBodies[0]; + let preserveFirst = !tcell.closest('thead') && !tcell.parentNode.querySelectorAll('td').length; + let asc = !(tbody.tracyAsc === tcell.cellIndex); + tbody.tracyAsc = asc ? tcell.cellIndex : null; + let getText = (cell) => { return cell ? (cell.getAttribute('data-order') || cell.innerText) : ''; }; + + Array.from(tbody.children) + .slice(preserveFirst ? 1 : 0) + .sort((a, b) => { + return function(v1, v2) { + return v1 !== '' && v2 !== '' && !isNaN(v1) && !isNaN(v2) ? v1 - v2 : v1.toString().localeCompare(v2); + }(getText((asc ? a : b).children[tcell.cellIndex]), getText((asc ? b : a).children[tcell.cellIndex])); + }) + .forEach((tr) => { tbody.appendChild(tr); }); + } +} + + +let Tracy = window.Tracy = window.Tracy || {}; +Tracy.TableSort = Tracy.TableSort || TableSort; diff --git a/vendor/tracy/tracy/src/Tracy/Toggle/toggle.css b/vendor/tracy/tracy/src/Tracy/Toggle/toggle.css new file mode 100644 index 0000000..51b4f73 --- /dev/null +++ b/vendor/tracy/tracy/src/Tracy/Toggle/toggle.css @@ -0,0 +1,34 @@ +/** + * This file is part of the Tracy (https://tracy.nette.org) + */ + +.tracy-collapsed { + display: none; +} + +.tracy-toggle.tracy-collapsed { + display: inline; +} + +.tracy-toggle { + cursor: pointer; + user-select: none; +} + +.tracy-toggle:after { + content: ''; + display: inline-block; + vertical-align: middle; + line-height: 0; + border-top: .6ex solid; + border-right: .6ex solid transparent; + border-left: .6ex solid transparent; + transform: scale(1, 1.5); + margin: 0 .2ex 0 .7ex; + transition: .1s transform; + opacity: .5; +} + +.tracy-toggle.tracy-collapsed:after { + transform: rotate(-90deg) scale(1, 1.5) translate(.1ex, 0); +} diff --git a/vendor/tracy/tracy/src/Tracy/Toggle/toggle.js b/vendor/tracy/tracy/src/Tracy/Toggle/toggle.js new file mode 100644 index 0000000..6a32b17 --- /dev/null +++ b/vendor/tracy/tracy/src/Tracy/Toggle/toggle.js @@ -0,0 +1,111 @@ +/** + * This file is part of the Tracy (https://tracy.nette.org) + */ + +const MOVE_THRESHOLD = 100; + +// enables or toggling +class Toggle +{ + static init() { + let start; + document.documentElement.addEventListener('mousedown', (e) => { + start = [e.clientX, e.clientY]; + }); + + document.documentElement.addEventListener('click', (e) => { + let el; + if ( + !e.shiftKey && !e.ctrlKey && !e.metaKey + && (el = e.target.closest('.tracy-toggle')) + && Math.pow(start[0] - e.clientX, 2) + Math.pow(start[1] - e.clientY, 2) < MOVE_THRESHOLD + ) { + Toggle.toggle(el, undefined, e); + e.stopImmediatePropagation(); + } + }); + Toggle.init = function() {}; + } + + + // changes element visibility + static toggle(el, expand, e) { + let collapsed = el.classList.contains('tracy-collapsed'), + ref = el.getAttribute('data-tracy-ref') || el.getAttribute('href', 2), + dest = el; + + if (typeof expand === 'undefined') { + expand = collapsed; + } + + if (!ref || ref === '#') { + ref = '+'; + } else if (ref.substr(0, 1) === '#') { + dest = document; + } + ref = ref.match(/(\^\s*([^+\s]*)\s*)?(\+\s*(\S*)\s*)?(.*)/); + dest = ref[1] ? dest.parentNode : dest; + dest = ref[2] ? dest.closest(ref[2]) : dest; + dest = ref[3] ? Toggle.nextElement(dest.nextElementSibling, ref[4]) : dest; + dest = ref[5] ? dest.querySelector(ref[5]) : dest; + + el.classList.toggle('tracy-collapsed', !expand); + dest.classList.toggle('tracy-collapsed', !expand); + + el.dispatchEvent(new CustomEvent('tracy-toggle', { + bubbles: true, + detail: {relatedTarget: dest, collapsed: !expand, originalEvent: e} + })); + } + + + // save & restore toggles + static persist(baseEl, restore) { + let saved = []; + baseEl.addEventListener('tracy-toggle', (e) => { + if (saved.indexOf(e.target) < 0) { + saved.push(e.target); + } + }); + + let toggles = JSON.parse(sessionStorage.getItem('tracy-toggles-' + baseEl.id)); + if (toggles && restore !== false) { + toggles.forEach((item) => { + let el = baseEl; + for (let i in item.path) { + if (!(el = el.children[item.path[i]])) { + return; + } + } + if (el.textContent === item.text) { + Toggle.toggle(el, item.expand); + } + }); + } + + window.addEventListener('unload', () => { + toggles = saved.map((el) => { + let item = {path: [], text: el.textContent, expand: !el.classList.contains('tracy-collapsed')}; + do { + item.path.unshift(Array.from(el.parentNode.children).indexOf(el)); + el = el.parentNode; + } while (el && el !== baseEl); + return item; + }); + sessionStorage.setItem('tracy-toggles-' + baseEl.id, JSON.stringify(toggles)); + }); + } + + + // finds next matching element + static nextElement(el, selector) { + while (el && selector && !el.matches(selector)) { + el = el.nextElementSibling; + } + return el; + } +} + + +let Tracy = window.Tracy = window.Tracy || {}; +Tracy.Toggle = Tracy.Toggle || Toggle; diff --git a/vendor/tracy/tracy/src/Tracy/functions.php b/vendor/tracy/tracy/src/Tracy/functions.php new file mode 100644 index 0000000..f110f22 --- /dev/null +++ b/vendor/tracy/tracy/src/Tracy/functions.php @@ -0,0 +1,46 @@ +setStub("startBuffering(); +foreach ($iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(__DIR__ . '/../../src', RecursiveDirectoryIterator::SKIP_DOTS)) as $file) { + echo "adding: {$iterator->getSubPathname()}\n"; + + $s = file_get_contents($file->getPathname()); + if (strpos($s, '@tracySkipLocation') === false) { + $s = php_strip_whitespace($file->getPathname()); + } + + if ($file->getExtension() === 'js') { + $s = compressJs($s); + + } elseif ($file->getExtension() === 'css') { + $s = compressCss($s); + + } elseif ($file->getExtension() === 'phtml') { + $s = preg_replace_callback('#(<(script|style).*(?)(.*)(getExtension() !== 'php') { + continue; + } + + $phar[$iterator->getSubPathname()] = $s; +} + +$phar->stopBuffering(); +$phar->compressFiles(Phar::GZ); + +echo "OK\n"; diff --git a/vendor/tracy/tracy/tools/open-in-editor/linux/install.sh b/vendor/tracy/tracy/tools/open-in-editor/linux/install.sh new file mode 100644 index 0000000..5a7bfb3 --- /dev/null +++ b/vendor/tracy/tracy/tools/open-in-editor/linux/install.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# This shell script sets open-editor.sh as handler for editor:// protocol + +matches=0 +while read -r line +do + if [ "editor=" == "${line:0:7}" ]; then + matches=1 + break + fi +done < "open-editor.sh" + +if [ "$matches" == "0" ]; then + echo -e "\e[31;1mError: it seems like you have not set command to run your editor." + echo -e "Before install, set variable \`\$editor\` in file \`open-editor.sh\`.\e[0m" + exit 1 +fi + +# -------------------------------------------------------------- + +echo "[Desktop Entry] +Name=Tracy Open Editor +Exec=tracy-openeditor.sh %u +Terminal=false +NoDisplay=true +Type=Application +MimeType=x-scheme-handler/editor;" > tracy-openeditor.desktop + +chmod +x open-editor.sh +chmod +x tracy-openeditor.desktop + +sudo cp open-editor.sh /usr/bin/tracy-openeditor.sh +sudo xdg-desktop-menu install tracy-openeditor.desktop +sudo update-desktop-database +rm tracy-openeditor.desktop + +echo -e "\e[32;1mDone.\e[0m" diff --git a/vendor/tracy/tracy/tools/open-in-editor/linux/open-editor.sh b/vendor/tracy/tracy/tools/open-in-editor/linux/open-editor.sh new file mode 100644 index 0000000..3bf6c89 --- /dev/null +++ b/vendor/tracy/tracy/tools/open-in-editor/linux/open-editor.sh @@ -0,0 +1,105 @@ +#!/bin/bash +declare -A mapping + +# +# Configure your editor by setting the $editor variable: +# + +# Visual Studio Code +#editor='code --goto "$FILE":"$LINE"' +# Emacs +#editor='emacs +$LINE "$FILE"' +# gVim +#editor='gvim +$LINE "$FILE"' +# gEdit +#editor='gedit +$LINE "$FILE"' +# Pluma +#editor='pluma +$LINE "$FILE"' +# PHPStorm +# To enable PHPStorm command-line interface, folow this guide: https://www.jetbrains.com/help/phpstorm/working-with-the-ide-features-from-command-line.html +#editor='phpstorm --line $LINE "$FILE"' + + +# +# Optionally configure custom mapping here: +# + +#mapping["/remotepath"]="/localpath" +#mapping["/mnt/d/"]="d:/" + +# +# Please, do not modify the code below. +# + +# Find and return URI parameter value. Or nothing, if the param is missing. +# Arguments: 1) URI, 2) Parameter name. +function get_param { + echo "$1" | sed -n -r "s/.*$2=([^&]*).*/\1/ip" +} + +if [[ -z "$editor" ]]; then + echo "You need to set the \$editor variable in file '`realpath $0`'" + exit +fi + +url=$1 +if [ "${url:0:9}" != "editor://" ]; then + exit +fi + +# Parse action and essential data from the URI. +regex='editor\:\/\/(open|create|fix)\/\?(.*)' +action=`echo $url | sed -r "s/$regex/\1/i"` +uri_params=`echo $url | sed -r "s/$regex/\2/i"` + +file=`get_param $uri_params "file"` +line=`get_param $uri_params "line"` +search=`get_param $uri_params "search"` +replace=`get_param $uri_params "replace"` + +# Debug? +#echo "action '$action'" +#echo "file '$file'" +#echo "line '$line'" +#echo "search '$search'" +#echo "replace '$replace'" + +# Convert URI encoded codes to normal characters (e.g. '%2F' => '/'). +printf -v file "${file//%/\\x}" +# And escape double-quotes. +file=${file//\"/\\\"} + +# Apply custom mapping conversion. +for path in "${!mapping[@]}"; do + file="${file//$path/${mapping[$path]}}" +done + +# Action: Create a file (only if it does not already exist). +if [ "$action" == "create" ] && [[ ! -f "$file" ]]; then + mkdir -p $(dirname "$file") + touch "$file" +fi + +# Action: Fix the file (if the file exists and while creating backup beforehand). +if [ "$action" == "fix" ]; then + + if [[ ! -f "$file" ]]; then + echo "Cannot fix non-existing file '$file'" + exit + fi + + # Backup the original file. + cp $file "$file.bak" + # Search and replace in place - only on the specified line. + sed -i "${line}s/${search}/${replace}/" $file + +fi + +# Format the command according to the selected editor. +command="${editor//\$FILE/$file}" +command="${command//\$LINE/$line}" + +# Debug? +#echo $command + +eval $command diff --git a/vendor/tracy/tracy/tools/open-in-editor/windows/install.cmd b/vendor/tracy/tracy/tools/open-in-editor/windows/install.cmd new file mode 100644 index 0000000..d841122 --- /dev/null +++ b/vendor/tracy/tracy/tools/open-in-editor/windows/install.cmd @@ -0,0 +1,9 @@ +@echo off +:: This Windows batch file sets open-editor.js as handler for editor:// protocol + +if defined PROCESSOR_ARCHITEW6432 (set reg="%systemroot%\sysnative\reg.exe") else (set reg=reg) + +%reg% ADD HKCR\editor /ve /d "URL:editor Protocol" /f +%reg% ADD HKCR\editor /v "URL Protocol" /d "" /f +%reg% ADD HKCR\editor\shell\open\command /ve /d "wscript \"%~dp0open-editor.js\" \"%%1\"" /f +%reg% ADD HKLM\SOFTWARE\Policies\Google\Chrome\URLWhitelist /v "123" /d "editor://*" /f diff --git a/vendor/tracy/tracy/tools/open-in-editor/windows/open-editor.js b/vendor/tracy/tracy/tools/open-in-editor/windows/open-editor.js new file mode 100644 index 0000000..00f63d3 --- /dev/null +++ b/vendor/tracy/tracy/tools/open-in-editor/windows/open-editor.js @@ -0,0 +1,84 @@ +var settings = { + + // PhpStorm + editor: '"C:\\Program Files\\JetBrains\\PhpStorm 2021.1.3\\bin\\phpstorm64.exe" --line %line% "%file%"', + title: 'PhpStorm', + + // NetBeans + // editor: '"C:\\Program Files\\NetBeans 8.1\\bin\\netbeans.exe" "%file%:%line%" --console suppress', + + // Nusphere PHPEd + // editor: '"C:\\Program Files\\NuSphere\\PhpED\\phped.exe" "%file%" --line=%line%', + + // SciTE + // editor: '"C:\\Program Files\\SciTE\\scite.exe" "-open:%file%" -goto:%line%', + + // EmEditor + // editor: '"C:\\Program Files\\EmEditor\\EmEditor.exe" "%file%" /l %line%', + + // PSPad Editor + // editor: '"C:\\Program Files\\PSPad editor\\PSPad.exe" -%line% "%file%"', + + // gVim + // editor: '"C:\\Program Files\\Vim\\vim73\\gvim.exe" "%file%" +%line%', + + // Sublime Text 2 + // editor: '"C:\\Program Files\\Sublime Text 2\\sublime_text.exe" "%file%:%line%"', + + // Visual Studio Code / VSCodium + // editor: '"C:\\Program Files\\Microsoft VS Code\\Code.exe" --goto "%file%:%line%"', + + mappings: { + '/remotepath': '/localpath' + } +}; + + + +if (!settings.editor) { + WScript.Echo('Create variable "settings.editor" in ' + WScript.ScriptFullName); + WScript.Quit(); +} + +var url = WScript.Arguments(0); +var match = /^editor:\/\/(open|create|fix)\/\?file=([^&]+)&line=(\d+)(?:&search=([^&]*)&replace=([^&]*))?/.exec(url); +if (!match) { + WScript.Echo('Unexpected URI ' + url); + WScript.Quit(); +} +for (var i in match) { + match[i] = decodeURIComponent(match[i]).replace(/\+/g, ' '); +} + +var action = match[1]; +var file = match[2]; +var line = match[3]; +var search = match[4]; +var replace = match[5]; + +var shell = new ActiveXObject('WScript.Shell'); +var fileSystem = new ActiveXObject('Scripting.FileSystemObject'); + +for (var id in settings.mappings) { + if (file.indexOf(id) === 0) { + file = settings.mappings[id] + file.substr(id.length); + break; + } +} + +if (action === 'create' && !fileSystem.FileExists(file)) { + shell.Run('cmd /c mkdir "' + fileSystem.GetParentFolderName(file) + '"', 0, 1); + fileSystem.CreateTextFile(file); + +} else if (action === 'fix') { + var lines = fileSystem.OpenTextFile(file).ReadAll().split('\n'); + lines[line-1] = lines[line-1].replace(search, replace); + fileSystem.OpenTextFile(file, 2).Write(lines.join('\n')); +} + +var command = settings.editor.replace(/%line%/, line).replace(/%file%/, file); +shell.Exec(command); + +if (settings.title) { + shell.AppActivate(settings.title); +} diff --git a/vendor/verot/class.upload.php/.gitignore b/vendor/verot/class.upload.php/.gitignore new file mode 100644 index 0000000..a1595bd --- /dev/null +++ b/vendor/verot/class.upload.php/.gitignore @@ -0,0 +1,4 @@ +test/tmp/ +dev/ +*.sublime-project +*.sublime-workspace diff --git a/vendor/verot/class.upload.php/LICENSE.txt b/vendor/verot/class.upload.php/LICENSE.txt new file mode 100644 index 0000000..5b6e7c6 --- /dev/null +++ b/vendor/verot/class.upload.php/LICENSE.txt @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, 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 or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +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 give any other recipients of the Program a copy of this License +along with the Program. + +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 Program or any portion +of it, thus forming a work based on the Program, 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) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +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 Program, 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 Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) 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; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, 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 executable. However, as a +special exception, the source code 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. + +If distribution of executable or 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 counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program 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. + + 5. 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 Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program 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 to +this License. + + 7. 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 Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program 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 Program. + +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. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program 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. + + 9. The Free Software Foundation may publish revised and/or new versions +of the 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 Program +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 Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, 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 + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "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 PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. 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 PROGRAM 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 PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), 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 Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. 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 program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/vendor/verot/class.upload.php/README.md b/vendor/verot/class.upload.php/README.md new file mode 100644 index 0000000..a85beb5 --- /dev/null +++ b/vendor/verot/class.upload.php/README.md @@ -0,0 +1,683 @@ +# class.upload.php + +Homepage : [http://www.verot.net/php_class_upload.htm](http://www.verot.net/php_class_upload.htm) + +Demo : [http://www.verot.net/php_class_upload_samples.htm](http://www.verot.net/php_class_upload_samples.htm) + +Donations: [http://www.verot.net/php_class_upload_donate.htm](http://www.verot.net/php_class_upload_donate.htm) + +Commercial use: [http://www.verot.net/php_class_upload_license.htm](http://www.verot.net/php_class_upload_license.htm) + + +## What does it do? + + +This class manages file uploads for you. In short, it manages the uploaded file, and allows you to do whatever you want with the file, especially if it is an image, and as many times as you want. + +It is the ideal class to quickly integrate file upload in your site. If the file is an image, you can convert, resize, crop it in many ways. You can also apply filters, add borders, text, watermarks, etc... That's all you need for a gallery script for instance. Supported formats are PNG, JPG, GIF, WEBP and BMP. + +You can also use the class to work on local files, which is especially useful to use the image manipulation features. The class also supports Flash uploaders and XMLHttpRequest. + +The class works with PHP 5.3+, PHP 7 and PHP 8 (use version 1.x for PHP 4 support), and its error messages can be localized at will. + + +## Install via composer + +Edit your composer.json file to include the following: + +``` + { + "require": { + "verot/class.upload.php": "*" + } + } +``` + +Or install it directly: + +``` + composer require verot/class.upload.php +``` + +## Demo and examples + +Check out the `test/` directory, which you can load in your browser. You can test the class and its different ways to instantiate it, see some code examples, and run some tests. + + + +## How to use it? + +Create a simple HTML file, with a form such as: +```html +
+ + + +``` +Create a file called upload.php (into which you have first loaded the class): +```php +$handle = new \Verot\Upload\Upload($_FILES['image_field']); +if ($handle->uploaded) { + $handle->file_new_name_body = 'image_resized'; + $handle->image_resize = true; + $handle->image_x = 100; + $handle->image_ratio_y = true; + $handle->process('/home/user/files/'); + if ($handle->processed) { + echo 'image resized'; + $handle->clean(); + } else { + echo 'error : ' . $handle->error; + } +} +``` + + +### How does it work? + +You instanciate the class with the `$_FILES['my_field']` array where _my_field_ is the field name from your upload form. The class will check if the original file has been uploaded to its temporary location (alternatively, you can instanciate the class with a local filename). + +You can then set a number of processing variables to act on the file. For instance, you can rename the file, and if it is an image, convert and resize it in many ways. You can also set what will the class do if the file already exists. + +Then you call the function `process()` to actually perform the actions according to the processing parameters you set above. It will create new instances of the original file, so the original file remains the same between each process. The file will be manipulated, and copied to the given location. The processing variables will be reset once it is done. + +You can repeat setting up a new set of processing variables, and calling `process()` again as many times as you want. When you have finished, you can call `clean()` to delete the original uploaded file. + +If you don't set any processing parameters and call `process()` just after instanciating the class. The uploaded file will be simply copied to the given location without any alteration or checks. + +Don't forget to add `enctype="multipart/form-data"` in your form tag `
` if you want your form to upload the file. + +### Namespacing + +The class is now namespaced in the `Verot/Upload` namespace. If you have the error *Fatal error: Class 'Upload' not found*, then make sure your file belongs to the namespace, or instantiate the class with its fully qualified name: + +```php +namespace Verot\Upload; +$handle = new Upload($_FILES['image_field']); +``` +or + +```php +$handle = new \Verot\Upload\Upload($_FILES['image_field']); +``` + +### How to process local files? + +Instantiate the class with the local filename, as following: + +```php +$handle = new Upload('/home/user/myfile.jpg'); +``` + + +### How to process a file uploaded via XMLHttpRequest? + +Instantiate the class with the special _php:_ keyword, as following: + +```php +$handle = new Upload('php:'.$_SERVER['HTTP_X_FILE_NAME']); +``` + +Prefixing the argument with _php:_ tells the class to retrieve the uploaded data in _php://input_, and the rest is the stream's filename, which is generally in `$_SERVER['HTTP_X_FILE_NAME']`. But you can use any other name you see fit: + +```php +$handle = new Upload('php:mycustomname.ext'); +``` + +### How to process raw file data? + +Instantiate the class with the special _data:_ keyword, as following: + +```php +$handle = new Upload('data:'.$file_contents); +``` + +If your data is base64-encoded, the class provides a simple _base64:_ keyword, which will decode your data prior to using it: + +```php +$handle = new Upload('base64:'.$base64_file_contents); +``` + +### How to set the language? + +Instantiate the class with a second argument being the language code: + +```php +$handle = new Upload($_FILES['image_field'], 'fr_FR'); +$handle = new Upload('/home/user/myfile.jpg', 'fr_FR'); +``` + +### How to output the resulting file or picture directly to the browser? + +Simply call `process()` without an argument (or with null as first argument): + +```php +$handle = new Upload($_FILES['image_field']); +header('Content-type: ' . $handle->file_src_mime); +echo $handle->process(); +die(); +``` + +Or if you want to force the download of the file: + +```php +$handle = new Upload($_FILES['image_field']); +header('Content-type: ' . $handle->file_src_mime); +header("Content-Disposition: attachment; filename=".rawurlencode($handle->file_src_name).";"); +echo $handle->process(); +die(); +``` + + +### Troubleshooting + +If the class doesn't do what you want it to do, you can display the log, in order to see in details what the class does. To obtain the log, just add this line at the end of your code: +```php +echo $handle->log; +``` + +Your problem may have been already discussed in the Frequently Asked Questions : [http://www.verot.net/php_class_upload_faq.htm](http://www.verot.net/php_class_upload_faq.htm) + +Failing that, you can search in the forums, and ask a question there: [http://www.verot.net/php_class_upload_forum.htm](http://www.verot.net/php_class_upload_forum.htm). Please don't use Github issues to ask for help. + + + +## Processing parameters + + +> Note: all the parameters in this section are reset after each process. + + +### File handling + +* **file_new_name_body** replaces the name body (default: null) +```php +$handle->file_new_name_body = 'new name'; +``` +* **file_name_body_add** appends to the name body (default: null) +```php +$handle->file_name_body_add = '_uploaded'; +``` +* **file_name_body_pre** prepends to the name body (default: null) +```php +$handle->file_name_body_pre = 'thumb_'; +``` +* **file_new_name_ext** replaces the file extension (default: null) +```php +$handle->file_new_name_ext = 'txt'; +``` +* **file_safe_name** formats the filename (spaces changed to _, etc...) (default: true) +```php +$handle->file_safe_name = true; +``` +* **file_force_extension** forces an extension if there isn't any (default: true) +```php +$handle->file_force_extension = true; +``` +* **file_overwrite** sets behaviour if file already exists (default: false) +```php +$handle->file_overwrite = true; +``` +* **file_auto_rename** automatically renames file if it already exists (default: true) +```php +$handle->file_auto_rename = true; +``` +* **dir_auto_create** automatically creates destination directory if missing (default: true) +```php +$handle->dir_auto_create = true; +``` +* **dir_auto_chmod** automatically attempts to chmod the destination directory if not writeable (default: true) +```php +$handle->dir_auto_chmod = true; +``` +* **dir_chmod** chmod used when creating directory or if directory not writeable (default: 0777) +```php +$handle->dir_chmod = 0777; +``` +* **file_max_size** sets maximum upload size (default: _upload_max_filesize_ from php.ini) +```php +$handle->file_max_size = '1024'; // 1KB +``` +* **mime_check** sets if the class check the MIME against the `allowed` list (default: true) +```php +$handle->mime_check = true; +``` +* **no_script** sets if the class turns scripts into text files (default: true) +```php +$handle->no_script = false; +``` +* **allowed** array of allowed mime-types (or one string). wildcard accepted, as in _image/*_ (default: check `init()`) +```php +$handle->allowed = array('application/pdf','application/msword', 'image/*'); +``` +* **forbidden** array of forbidden mime-types (or one string). wildcard accepted, as in _image/*_ (default: check `init()`) +```php +$handle->forbidden = array('application/*'); +``` + + +### Image handling + + +* **image_convert** if set, image will be converted (possible values : ''|'png'|'webp'|'jpeg'|'gif'|'bmp'; default: '') +```php +$handle->image_convert = 'jpg'; +``` +* **image_background_color** if set, will forcibly fill transparent areas with the color, in hexadecimal (default: null) +```php +$handle->image_background_color = '#FF00FF'; +``` +* **image_default_color** fallback color background color for non alpha-transparent output formats, such as JPEG or BMP, in hexadecimal (default: #FFFFFF) +```php +$handle->image_default_color = '#FF00FF'; +``` +* **png_compression** sets the compression level for PNG images, between 1 (fast but large files) and 9 (slow but smaller files) (default: null (Zlib default)) +```php +$handle->png_compression = 9; +``` +* **webp_quality** sets the compression quality for WEBP images (default: 85) +```php +$handle->webp_quality = 50; +``` +* **jpeg_quality** sets the compression quality for JPEG images (default: 85) +```php +$handle->jpeg_quality = 50; +``` +* **jpeg_size** if set to a size in bytes, will approximate `jpeg_quality` so the output image fits within the size (default: null) +```php +$handle->jpeg_size = 3072; +``` +* **image_interlace** if set to true, the image will be saved interlaced (if it is a JPEG, it will be saved as a progressive PEG) (default: false) +```php +$handle->image_interlace = true; +``` + +### Image checking + + +The following eight settings can be used to invalidate an upload if the file is an image (note that _open_basedir_ restrictions prevent the use of these settings) + +* **image_max_width** if set to a dimension in pixels, the upload will be invalid if the image width is greater (default: null) +```php +$handle->image_max_width = 200; +``` +* **image_max_height** if set to a dimension in pixels, the upload will be invalid if the image height is greater (default: null) +```php +$handle->image_max_height = 100; +``` +* **image_max_pixels** if set to a number of pixels, the upload will be invalid if the image number of pixels is greater (default: null) +```php +$handle->image_max_pixels = 50000; +``` +* **image_max_ratio** if set to a aspect ratio (width/height), the upload will be invalid if the image apect ratio is greater (default: null) +```php +$handle->image_max_ratio = 1.5; +``` +* **image_min_width** if set to a dimension in pixels, the upload will be invalid if the image width is lower (default: null) +```php +$handle->image_min_width = 100; +``` +* **image_min_height** if set to a dimension in pixels, the upload will be invalid if the image height is lower (default: null) +```php +$handle->image_min_height = 500; +``` +* **image_min_pixels** if set to a number of pixels, the upload will be invalid if the image number of pixels is lower (default: null) +```php +$handle->image_min_pixels = 20000; +``` +* **image_min_ratio** if set to a aspect ratio (width/height), the upload will be invalid if the image apect ratio is lower (default: null) +```php +$handle->image_min_ratio = 0.5; +``` + +### Image resizing + + +* **image_resize** determines is an image will be resized (default: false) +```php +$handle->image_resize = true; +``` + +The following variables are used only if _image_resize_ == true + +* **image_x** destination image width (default: 150) +```php +$handle->image_x = 100; +``` +* **image_y** destination image height (default: 150) +```php +$handle->image_y = 200; +``` + +Use either one of the following + +* **image_ratio** if true, resize image conserving the original sizes ratio, using `image_x` **AND** `image_y` as max sizes if true (default: false) +```php +$handle->image_ratio = true; +``` +* **image_ratio_crop** if true, resize image conserving the original sizes ratio, using `image_x` AND `image_y` as max sizes, and cropping excedent to fill the space. setting can also be a string, with one or more from 'TBLR', indicating which side of the image will be kept while cropping (default: false) +```php +$handle->image_ratio_crop = true; +``` +* **image_ratio_fill** if true, resize image conserving the original sizes ratio, using `image_x` AND `image_y` as max sizes, fitting the image in the space and coloring the remaining space. setting can also be a string, with one or more from 'TBLR', indicating which side of the space the image will be in (default: false) +```php +$handle->image_ratio_fill = true; +``` +* **image_ratio_x** if true, resize image, calculating `image_x` from `image_y` and conserving the original sizes ratio (default: false) +```php +$handle->image_ratio_x = true; +``` +* **image_ratio_y** if true, resize image, calculating `image_y` from `image_x` and conserving the original sizes ratio (default: false) +```php +$handle->image_ratio_y = true; +``` +* **image_ratio_pixels** if set to a long integer, resize image, calculating `image_y` and `image_x` to match a the number of pixels (default: false) +```php +$handle->image_ratio_pixels = 25000; +``` + +And eventually prevent enlarging or shrinking images + +* **image_no_enlarging** cancel resizing if the resized image is bigger than the original image, to prevent enlarging (default: false) +```php +$handle->image_no_enlarging = true; +``` +* **image_no_shrinking** cancel resizing if the resized image is smaller than the original image, to prevent shrinking (default: false) +```php +$handle->image_no_shrinking = true; +``` + +### Image effects + +The following image manipulations require GD2+ + +* **image_brightness** if set, corrects the brightness. value between -127 and 127 (default: null) +```php +$handle->image_brightness = 40; +``` +* **image_contrast** if set, corrects the contrast. value between -127 and 127 (default: null) +```php +$handle->image_contrast = 50; +``` +* **image_opacity** if set, changes the image opacity. value between 0 and 100 (default: null) +```php +$handle->image_opacity = 50; +``` +* **image_tint_color** if set, will tint the image with a color, value as hexadecimal #FFFFFF (default: null) +```php +$handle->image_tint_color = '#FF0000'; +``` +* **image_overlay_color** if set, will add a colored overlay, value as hexadecimal #FFFFFF (default: null) +```php +$handle->image_overlay_color = '#FF0000'; +``` +* **image_overlay_opacity** used when `image_overlay_color` is set, determines the opacity (default: 50) +```php +$handle->image_overlay_opacity = 20; +``` +* **image_negative** inverts the colors in the image (default: false) +```php +$handle->image_negative = true; +``` +* **image_greyscale** transforms an image into greyscale (default: false) +```php +$handle->image_greyscale = true; +``` +* **image_threshold** applies a threshold filter. value between -127 and 127 (default: null) +```php +$handle->image_threshold = 20; +``` +* **image_pixelate** pixelate an image, value is block size (default: null) +```php +$handle->image_pixelate = 10; +``` +* **image_unsharp** applies an unsharp mask, with alpha transparency support (default: false) +```php +$handle->image_unsharp = true; +``` +* **image_unsharp_amount** unsharp mask amount, typically 50 - 200 (default: 80) +```php +$handle->image_unsharp_amount = 120; +``` +* **image_unsharp_radius** unsharp mask radius, typically 0.5 - 1 (default: 0.5) +```php +$handle->image_unsharp_radius = 1; +``` +* **image_unsharp_threshold** unsharp mask threshold, typically 0 - 5 (default: 1) +```php +$handle->image_unsharp_threshold = 0; +``` + +### Image text + +* **image_text** creates a text label on the image, value is a string, with eventual replacement tokens (default: null) +```php +$handle->image_text = 'test'; +``` +* **image_text_direction** text label direction, either 'h' horizontal or 'v' vertical (default: 'h') +```php +$handle->image_text_direction = 'v'; +``` +* **image_text_color** text color for the text label, in hexadecimal (default: #FFFFFF) +```php +$handle->image_text_color = '#FF0000'; +``` +* **image_text_opacity** text opacity on the text label, integer between 0 and 100 (default: 100) +```php +$handle->image_text_opacity = 50; +``` +* **image_text_background** text label background color, in hexadecimal (default: null) +```php +$handle->image_text_background = '#FFFFFF'; +``` +* **image_text_background_opacity** text label background opacity, integer between 0 and 100 (default: 100) +```php +$handle->image_text_background_opacity = 50; +``` +* **image_text_font** built-in font for the text label, from 1 to 5. 1 is the smallest (default: 5). Value can also be a string, which represents the path to a GDF or TTF font (TrueType). +```php +$handle->image_text_font = 4; // or './font.gdf' or './font.ttf' +``` +* **image_text_size** font size for TrueType fonts, in pixels (GD1) or points (GD1) (default: 16) (TrueType fonts only) +```php +$handle->image_text_size = 24; +``` +* **image_text_angle** text angle for TrueType fonts, in degrees, with 0 degrees being left-to-right reading text(default: null) (TrueType fonts only) +```php +$handle->image_text_angle = 45; +``` +* **image_text_x** absolute text label position, in pixels from the left border. can be negative (default: null) +```php +$handle->image_text_x = 5; +``` +* **image_text_y** absolute text label position, in pixels from the top border. can be negative (default: null) +```php +$handle->image_text_y = 5; +``` +* **image_text_position** text label position withing the image, a combination of one or two from 'TBLR': top, bottom, left, right (default: null) +```php +$handle->image_text_position = 'LR'; +``` +* **image_text_padding** text label padding, in pixels. can be overridden by `image_text_padding_x` and `image_text_padding_y` (default: 0) +```php +$handle->image_text_padding = 5; +``` +* **image_text_padding_x** text label horizontal padding (default: null) +```php +$handle->image_text_padding_x = 2; +``` +* **image_text_padding_y** text label vertical padding (default: null) +```php +$handle->image_text_padding_y = 10; +``` +* **image_text_alignment** text alignment when text has multiple lines, either 'L', 'C' or 'R' (default: 'C') (GD fonts only) +```php +$handle->image_text_alignment = 'R'; +``` +* **image_text_line_spacing** space between lines in pixels, when text has multiple lines (default: 0) (GD fonts only) +```php +$handle->image_text_line_spacing = 3; +``` + +### Image transformations + + +* **image_auto_rotate** automatically rotates the image according to EXIF data (JPEG only) (default: true, applies even if there is no image manipulations) +```php +$handle->image_auto_rotate = false; +``` +* **image_flip** flips image, wither 'h' horizontal or 'v' vertical (default: null) +```php +$handle->image_flip = 'h'; +``` +* **image_rotate** rotates image. Possible values are 90, 180 and 270 (default: null) +```php +$handle->image_rotate = 90; +``` +* **image_crop** crops image. accepts 4, 2 or 1 values as 'T R B L' or 'TB LR' or 'TBLR'. dimension can be 20, or 20px or 20% (default: null) +```php +$handle->image_crop = array(50,40,30,20); OR '-20 20%'... +``` +* **image_precrop** crops image, before an eventual resizing. accepts 4, 2 or 1 values as 'T R B L' or 'TB LR' or 'TBLR'. dimension can be 20, or 20px or 20% (default: null) +```php +$handle->image_precrop = array(50,40,30,20); OR '-20 20%'... +``` + +### Image borders + + +* **image_bevel** adds a bevel border to the image. value is thickness in pixels (default: null) +```php +$handle->image_bevel = 20; +``` +* **image_bevel_color1** top and left bevel color, in hexadecimal (default: #FFFFFF) +```php +$handle->image_bevel_color1 = '#FFFFFF'; +``` +* **image_bevel_color2** bottom and right bevel color, in hexadecimal (default: #000000) +```php +$handle->image_bevel_color2 = '#000000'; +``` +* **image_border** adds a unicolor border to the image. accepts 4, 2 or 1 values as 'T R B L' or 'TB LR' or 'TBLR'. dimension can be 20, or 20px or 20% (default: null) +```php +$handle->image_border = '3px'; OR '-20 20%' OR array(3,2)... +``` +* **image_border_color** border color, in hexadecimal (default: #FFFFFF) +```php +$handle->image_border_color = '#FFFFFF'; +``` +* **image_border_opacity** border opacity, integer between 0 and 100 (default: 100) +```php +$handle->image_border_opacity = 50; +``` +* **image_border_transparent** adds a fading-to-transparent border to the image. accepts 4, 2 or 1 values as 'T R B L' or 'TB LR' or 'TBLR'. dimension can be 20, or 20px or 20% (default: null) +```php +$handle->image_border_transparent = '3px'; OR '-20 20%' OR array(3,2)... +``` +* **image_frame** type of frame: 1=flat 2=crossed (default: null) +```php +$handle->image_frame = 2; +``` +* **image_frame_colors** list of hex colors, in an array or a space separated string (default: '#FFFFFF #999999 #666666 #000000') +```php +$handle->image_frame_colors = array('#999999', '#FF0000', '#666666', '#333333', '#000000'); +``` +* **image_frame_opacity** frame opacity, integer between 0 and 100 (default: 100) +```php +$handle->image_frame_opacity = 50; +``` + + +### Image watermark + +* **image_watermark** adds a watermark on the image, value is a local filename. accepted files are GIF, JPG, BMP, WEBP, PNG and PNG alpha (default: null) +```php +$handle->image_watermark = 'watermark.png'; +``` +* **image_watermark_x** absolute watermark position, in pixels from the left border. can be negative (default: null) +```php +$handle->image_watermark_x = 5; +``` +* **image_watermark_y** absolute watermark position, in pixels from the top border. can be negative (default: null) +```php +$handle->image_watermark_y = 5; +``` +* **image_watermark_position** watermark position withing the image, a combination of one or two from 'TBLR': top, bottom, left, right (default: null) +```php +$handle->image_watermark_position = 'LR'; +``` +* **image_watermark_no_zoom_in** prevents the watermark to be resized up if it is smaller than the image (default: true) +```php +$handle->image_watermark_no_zoom_in = false; +``` +* **image_watermark_no_zoom_out** prevents the watermark to be resized down if it is bigger than the image (default: false) +```php +$handle->image_watermark_no_zoom_out = true; +``` + + +### Image reflections + +* **image_reflection_height** if set, a reflection will be added. Format is either in pixels or percentage, such as 40, '40', '40px' or '40%' (default: null) +```php +$handle->image_reflection_height = '25%'; +``` +* **image_reflection_space** space in pixels between the source image and the reflection, can be negative (default: null) +```php +$handle->image_reflection_space = 3; +``` +* **image_reflection_color** reflection background color, in hexadecimal. Now deprecated in favor of `image_default_color` (default: #FFFFFF) +```php +$handle->image_default_color = '#000000'; +``` +* **image_reflection_opacity** opacity level at which the reflection starts, integer between 0 and 100 (default: 60) +```php +$handle->image_reflection_opacity = 60; +``` + + + +## Values that can be read before calling `process()` + +* **file_src_name** Source file name +* **file_src_name_body** Source file name body +* **file_src_name_ext** Source file extension +* **file_src_pathname** Source file complete path and name +* **file_src_mime** Source file mime type +* **file_src_size** Source file size in bytes +* **file_src_error** Upload error code +* **file_is_image** Boolean flag, true if the file is a supported image type + +If the file is a supported image type (and _open_basedir_ restrictions allow it) + +* **image_src_x** Source file width in pixels +* **image_src_y** Source file height in pixels +* **image_src_pixels** Source file number of pixels +* **image_src_type** Source file type (png, webp, jpg, gif or bmp) +* **image_src_bits** Source file color depth + + +## Values that can be read after calling `process()` + +* **file_dst_path** Destination file path +* **file_dst_name_body** Destination file name body +* **file_dst_name_ext** Destination file extension +* **file_dst_name** Destination file name +* **file_dst_pathname** Destination file complete path and name + +If the file is a supported image type + +* **image_dst_type** Destination file type (png, webp, jpg, gif or bmp) +* **image_dst_x** Destination file width +* **image_dst_y** Destination file height + + + +## Requirements + +Most of the image operations require GD. GD2 is greatly recommended + +Version 1.x supports PHP 4, 5 and 7, but is not namespaced. Use it if you need support for PHP <5.3 + +Version 2.x supports PHP 5.3+ and PHP 7. + diff --git a/vendor/verot/class.upload.php/composer.json b/vendor/verot/class.upload.php/composer.json new file mode 100644 index 0000000..7cb53f9 --- /dev/null +++ b/vendor/verot/class.upload.php/composer.json @@ -0,0 +1,23 @@ +{ + "name": "verot/class.upload.php", + "description": "This PHP class uploads files and manipulates images very easily.", + "type": "library", + "homepage":"http://www.verot.net/php_class_upload.htm", + "keywords": ["upload", "gd"], + "license": "GPL-2.0-only", + "authors": [ + { + "name": "Colin Verot", + "email": "colin@verot.net" + } + ], + "support":{ + "email":"colin@verot.net" + }, + "require": { + "php": ">=5.3" + }, + "autoload": { + "classmap": ["src/class.upload.php"] + } +} diff --git a/vendor/verot/class.upload.php/src/class.upload.php b/vendor/verot/class.upload.php/src/class.upload.php new file mode 100644 index 0000000..67f0412 --- /dev/null +++ b/vendor/verot/class.upload.php/src/class.upload.php @@ -0,0 +1,5182 @@ + + * @license http://opensource.org/licenses/gpl-license.php GNU Public License + * @copyright Colin Verot + */ +class Upload { + + + /** + * Class version + * + * @access public + * @var string + */ + var $version; + + /** + * Uploaded file name + * + * @access public + * @var string + */ + var $file_src_name; + + /** + * Uploaded file name body (i.e. without extension) + * + * @access public + * @var string + */ + var $file_src_name_body; + + /** + * Uploaded file name extension + * + * @access public + * @var string + */ + var $file_src_name_ext; + + /** + * Uploaded file MIME type + * + * @access public + * @var string + */ + var $file_src_mime; + + /** + * Uploaded file size, in bytes + * + * @access public + * @var double + */ + var $file_src_size; + + /** + * Holds eventual PHP error code from $_FILES + * + * @access public + * @var string + */ + var $file_src_error; + + /** + * Uloaded file name, including server path + * + * @access public + * @var string + */ + var $file_src_pathname; + + /** + * Uloaded file name temporary copy + * + * @access private + * @var string + */ + var $file_src_temp; + + /** + * Destination file name + * + * @access public + * @var string + */ + var $file_dst_path; + + /** + * Destination file name + * + * @access public + * @var string + */ + var $file_dst_name; + + /** + * Destination file name body (i.e. without extension) + * + * @access public + * @var string + */ + var $file_dst_name_body; + + /** + * Destination file extension + * + * @access public + * @var string + */ + var $file_dst_name_ext; + + /** + * Destination file name, including path + * + * @access public + * @var string + */ + var $file_dst_pathname; + + /** + * Source image width + * + * @access public + * @var integer + */ + var $image_src_x; + + /** + * Source image height + * + * @access public + * @var integer + */ + var $image_src_y; + + /** + * Source image color depth + * + * @access public + * @var integer + */ + var $image_src_bits; + + /** + * Number of pixels + * + * @access public + * @var long + */ + var $image_src_pixels; + + /** + * Type of image (png, gif, jpg, webp or bmp) + * + * @access public + * @var string + */ + var $image_src_type; + + /** + * Destination image width + * + * @access public + * @var integer + */ + var $image_dst_x; + + /** + * Destination image height + * + * @access public + * @var integer + */ + var $image_dst_y; + + /** + * Destination image type (png, gif, jpg, webp or bmp) + * + * @access public + * @var integer + */ + var $image_dst_type; + + /** + * Supported image formats + * + * @access private + * @var array + */ + var $image_supported; + + /** + * Flag to determine if the source file is an image + * + * @access public + * @var boolean + */ + var $file_is_image; + + /** + * Flag set after instanciating the class + * + * Indicates if the file has been uploaded properly + * + * @access public + * @var bool + */ + var $uploaded; + + /** + * Flag stopping PHP upload checks + * + * Indicates whether we instanciated the class with a filename, in which case + * we will not check on the validity of the PHP *upload* + * + * This flag is automatically set to true when working on a local file + * + * Warning: for uploads, this flag MUST be set to false for security reason + * + * @access public + * @var bool + */ + var $no_upload_check; + + /** + * Flag set after calling a process + * + * Indicates if the processing, and copy of the resulting file went OK + * + * @access public + * @var bool + */ + var $processed; + + /** + * Holds eventual error message in plain english + * + * @access public + * @var string + */ + var $error; + + /** + * Holds an HTML formatted log + * + * @access public + * @var string + */ + var $log; + + + // overiddable processing variables + + + /** + * Set this variable to replace the name body (i.e. without extension) + * + * @access public + * @var string + */ + var $file_new_name_body; + + /** + * Set this variable to append a string to the file name body + * + * @access public + * @var string + */ + var $file_name_body_add; + + /** + * Set this variable to prepend a string to the file name body + * + * @access public + * @var string + */ + var $file_name_body_pre; + + /** + * Set this variable to change the file extension + * + * @access public + * @var string + */ + var $file_new_name_ext; + + /** + * Set this variable to format the filename (spaces changed to _) + * + * @access public + * @var boolean + */ + var $file_safe_name; + + /** + * Forces an extension if the source file doesn't have one + * + * If the file is an image, then the correct extension will be added + * Otherwise, a .txt extension will be chosen + * + * @access public + * @var boolean + */ + var $file_force_extension; + + /** + * Set this variable to false if you don't want to check the MIME against the allowed list + * + * This variable is set to true by default for security reason + * + * @access public + * @var boolean + */ + var $mime_check; + + /** + * Set this variable to false in the init() function if you don't want to check the MIME + * with Fileinfo PECL extension. On some systems, Fileinfo is known to be buggy, and you + * may want to deactivate it in the class code directly. + * + * You can also set it with the path of the magic database file. + * If set to true, the class will try to read the MAGIC environment variable + * and if it is empty, will default to the system's default + * If set to an empty string, it will call finfo_open without the path argument + * + * This variable is set to true by default for security reason + * + * @access public + * @var boolean + */ + var $mime_fileinfo; + + /** + * Set this variable to false in the init() function if you don't want to check the MIME + * with UNIX file() command + * + * This variable is set to true by default for security reason + * + * @access public + * @var boolean + */ + var $mime_file; + + /** + * Set this variable to false in the init() function if you don't want to check the MIME + * with the magic.mime file + * + * The function mime_content_type() will be deprecated, + * and this variable will be set to false in a future release + * + * This variable is set to true by default for security reason + * + * @access public + * @var boolean + */ + var $mime_magic; + + /** + * Set this variable to false in the init() function if you don't want to check the MIME + * with getimagesize() + * + * The class tries to get a MIME type from getimagesize() + * If no MIME is returned, it tries to guess the MIME type from the file type + * + * This variable is set to true by default for security reason + * + * @access public + * @var boolean + */ + var $mime_getimagesize; + + /** + * Set this variable to false if you don't want to turn dangerous scripts into simple text files + * + * @access public + * @var boolean + */ + var $no_script; + + /** + * Set this variable to true to allow automatic renaming of the file + * if the file already exists + * + * Default value is true + * + * For instance, on uploading foo.ext,
+ * if foo.ext already exists, upload will be renamed foo_1.ext
+ * and if foo_1.ext already exists, upload will be renamed foo_2.ext
+ * + * Note that this option doesn't have any effect if {@link file_overwrite} is true + * + * @access public + * @var bool + */ + var $file_auto_rename; + + /** + * Set this variable to true to allow automatic creation of the destination + * directory if it is missing (works recursively) + * + * Default value is true + * + * @access public + * @var bool + */ + var $dir_auto_create; + + /** + * Set this variable to true to allow automatic chmod of the destination + * directory if it is not writeable + * + * Default value is true + * + * @access public + * @var bool + */ + var $dir_auto_chmod; + + /** + * Set this variable to the default chmod you want the class to use + * when creating directories, or attempting to write in a directory + * + * Default value is 0755 (without quotes) + * + * @access public + * @var bool + */ + var $dir_chmod; + + /** + * Set this variable tu true to allow overwriting of an existing file + * + * Default value is false, so no files will be overwritten + * + * @access public + * @var bool + */ + var $file_overwrite; + + /** + * Set this variable to change the maximum size in bytes for an uploaded file + * + * Default value is the value upload_max_filesize from php.ini + * + * Value in bytes (integer) or shorthand byte values (string) is allowed. + * The available options are K (for Kilobytes), M (for Megabytes) and G (for Gigabytes) + * + * @access public + * @var double + */ + var $file_max_size; + + /** + * Set this variable to true to resize the file if it is an image + * + * You will probably want to set {@link image_x} and {@link image_y}, and maybe one of the ratio variables + * + * Default value is false (no resizing) + * + * @access public + * @var bool + */ + var $image_resize; + + /** + * Set this variable to convert the file if it is an image + * + * Possibles values are : ''; 'png'; 'jpeg'; 'gif'; 'webp'; 'bmp' + * + * Default value is '' (no conversion)
+ * If {@link resize} is true, {@link convert} will be set to the source file extension + * + * @access public + * @var string + */ + var $image_convert; + + /** + * Set this variable to the wanted (or maximum/minimum) width for the processed image, in pixels + * + * Default value is 150 + * + * @access public + * @var integer + */ + var $image_x; + + /** + * Set this variable to the wanted (or maximum/minimum) height for the processed image, in pixels + * + * Default value is 150 + * + * @access public + * @var integer + */ + var $image_y; + + /** + * Set this variable to keep the original size ratio to fit within {@link image_x} x {@link image_y} + * + * Default value is false + * + * @access public + * @var bool + */ + var $image_ratio; + + /** + * Set this variable to keep the original size ratio to fit within {@link image_x} x {@link image_y} + * + * The image will be resized as to fill the whole space, and excedent will be cropped + * + * Value can also be a string, one or more character from 'TBLR' (top, bottom, left and right) + * If set as a string, it determines which side of the image is kept while cropping. + * By default, the part of the image kept is in the center, i.e. it crops equally on both sides + * + * Default value is false + * + * @access public + * @var mixed + */ + var $image_ratio_crop; + + /** + * Set this variable to keep the original size ratio to fit within {@link image_x} x {@link image_y} + * + * The image will be resized to fit entirely in the space, and the rest will be colored. + * The default color is white, but can be set with {@link image_default_color} + * + * Value can also be a string, one or more character from 'TBLR' (top, bottom, left and right) + * If set as a string, it determines in which side of the space the image is displayed. + * By default, the image is displayed in the center, i.e. it fills the remaining space equally on both sides + * + * Default value is false + * + * @access public + * @var mixed + */ + var $image_ratio_fill; + + /** + * Set this variable to a number of pixels so that {@link image_x} and {@link image_y} are the best match possible + * + * The image will be resized to have approximatively the number of pixels + * The aspect ratio wil be conserved + * + * Default value is false + * + * @access public + * @var mixed + */ + var $image_ratio_pixels; + + /** + * Set this variable to calculate {@link image_x} automatically , using {@link image_y} and conserving ratio + * + * Default value is false + * + * @access public + * @var bool + */ + var $image_ratio_x; + + /** + * Set this variable to calculate {@link image_y} automatically , using {@link image_x} and conserving ratio + * + * Default value is false + * + * @access public + * @var bool + */ + var $image_ratio_y; + + /** + * (deprecated) Set this variable to keep the original size ratio to fit within {@link image_x} x {@link image_y}, + * but only if original image is bigger + * + * This setting is soon to be deprecated. Instead, use {@link image_ratio} and {@link image_no_enlarging} + * + * Default value is false + * + * @access public + * @var bool + */ + var $image_ratio_no_zoom_in; + + /** + * (deprecated) Set this variable to keep the original size ratio to fit within {@link image_x} x {@link image_y}, + * but only if original image is smaller + * + * Default value is false + * + * This setting is soon to be deprecated. Instead, use {@link image_ratio} and {@link image_no_shrinking} + * + * @access public + * @var bool + */ + var $image_ratio_no_zoom_out; + + /** + * Cancel resizing if the resized image is bigger than the original image, to prevent enlarging + * + * Default value is false + * + * @access public + * @var bool + */ + var $image_no_enlarging; + + /** + * Cancel resizing if the resized image is smaller than the original image, to prevent shrinking + * + * Default value is false + * + * @access public + * @var bool + */ + var $image_no_shrinking; + + /** + * Set this variable to set a maximum image width, above which the upload will be invalid + * + * Default value is null + * + * @access public + * @var integer + */ + var $image_max_width; + + /** + * Set this variable to set a maximum image height, above which the upload will be invalid + * + * Default value is null + * + * @access public + * @var integer + */ + var $image_max_height; + + /** + * Set this variable to set a maximum number of pixels for an image, above which the upload will be invalid + * + * Default value is null + * + * @access public + * @var long + */ + var $image_max_pixels; + + /** + * Set this variable to set a maximum image aspect ratio, above which the upload will be invalid + * + * Note that ratio = width / height + * + * Default value is null + * + * @access public + * @var float + */ + var $image_max_ratio; + + /** + * Set this variable to set a minimum image width, below which the upload will be invalid + * + * Default value is null + * + * @access public + * @var integer + */ + var $image_min_width; + + /** + * Set this variable to set a minimum image height, below which the upload will be invalid + * + * Default value is null + * + * @access public + * @var integer + */ + var $image_min_height; + + /** + * Set this variable to set a minimum number of pixels for an image, below which the upload will be invalid + * + * Default value is null + * + * @access public + * @var long + */ + var $image_min_pixels; + + /** + * Set this variable to set a minimum image aspect ratio, below which the upload will be invalid + * + * Note that ratio = width / height + * + * Default value is null + * + * @access public + * @var float + */ + var $image_min_ratio; + + /** + * Compression level for PNG images + * + * Between 1 (fast but large files) and 9 (slow but smaller files) + * + * Default value is null (Zlib default) + * + * @access public + * @var integer + */ + var $png_compression; + + /** + * Quality of JPEG created/converted destination image + * + * Default value is 85 + * + * @access public + * @var integer + */ + var $jpeg_quality; + + /** + * Quality of WebP created/converted destination image + * + * Default value is 85 + * + * @access public + * @var integer + */ + var $webp_quality; + + /** + * Determines the quality of the JPG image to fit a desired file size + * + * The JPG quality will be set between 1 and 100% + * The calculations are approximations. + * + * Value in bytes (integer) or shorthand byte values (string) is allowed. + * The available options are K (for Kilobytes), M (for Megabytes) and G (for Gigabytes) + * + * Default value is null (no calculations) + * + * @access public + * @var integer + */ + var $jpeg_size; + + /** + * Turns the interlace bit on + * + * This is actually used only for JPEG images, and defaults to false + * + * @access public + * @var boolean + */ + var $image_interlace; + + /** + * Flag set to true when the image is transparent + * + * This is actually used only for transparent GIFs + * + * @access public + * @var boolean + */ + var $image_is_transparent; + + /** + * Transparent color in a palette + * + * This is actually used only for transparent GIFs + * + * @access public + * @var boolean + */ + var $image_transparent_color; + + /** + * Background color, used to paint transparent areas with + * + * If set, it will forcibly remove transparency by painting transparent areas with the color + * This setting will fill in all transparent areas in PNG, WEPB and GIF, as opposed to {@link image_default_color} + * which will do so only in BMP, JPEG, and alpha transparent areas in transparent GIFs + * This setting overrides {@link image_default_color} + * + * Default value is null + * + * @access public + * @var string + */ + var $image_background_color; + + /** + * Default color for non alpha-transparent images + * + * This setting is to be used to define a background color for semi transparent areas + * of an alpha transparent when the output format doesn't support alpha transparency + * This is useful when, from an alpha transparent PNG or WEBP image, or an image with alpha transparent features + * if you want to output it as a transparent GIFs for instance, you can set a blending color for transparent areas + * If you output in JPEG or BMP, this color will be used to fill in the previously transparent areas + * + * The default color white + * + * @access public + * @var boolean + */ + var $image_default_color; + + /** + * Flag set to true when the image is not true color + * + * @access public + * @var boolean + */ + var $image_is_palette; + + /** + * Corrects the image brightness + * + * Value can range between -127 and 127 + * + * Default value is null + * + * @access public + * @var integer + */ + var $image_brightness; + + /** + * Corrects the image contrast + * + * Value can range between -127 and 127 + * + * Default value is null + * + * @access public + * @var integer + */ + var $image_contrast; + + /** + * Changes the image opacity + * + * Value can range between 0 and 100 + * + * Default value is null + * + * @access public + * @var integer + */ + var $image_opacity; + + /** + * Applies threshold filter + * + * Value can range between -127 and 127 + * + * Default value is null + * + * @access public + * @var integer + */ + var $image_threshold; + + /** + * Applies a tint on the image + * + * Value is an hexadecimal color, such as #FFFFFF + * + * Default value is null + * + * @access public + * @var string; + */ + var $image_tint_color; + + /** + * Applies a colored overlay on the image + * + * Value is an hexadecimal color, such as #FFFFFF + * + * To use with {@link image_overlay_opacity} + * + * Default value is null + * + * @access public + * @var string; + */ + var $image_overlay_color; + + /** + * Sets the opacity for the colored overlay + * + * Value is a percentage, as an integer between 0 (transparent) and 100 (opaque) + * + * Unless used with {@link image_overlay_color}, this setting has no effect + * + * Default value is 50 + * + * @access public + * @var integer + */ + var $image_overlay_opacity; + + /** + * Inverts the color of an image + * + * Default value is FALSE + * + * @access public + * @var boolean; + */ + var $image_negative; + + /** + * Turns the image into greyscale + * + * Default value is FALSE + * + * @access public + * @var boolean; + */ + var $image_greyscale; + + /** + * Pixelate an image + * + * Value is integer, represents the block size + * + * Default value is null + * + * @access public + * @var integer; + */ + var $image_pixelate; + + /** + * Applies an unsharp mask, with alpha transparency support + * + * Beware that this unsharp mask is quite resource-intensive + * + * Default value is FALSE + * + * @access public + * @var boolean; + */ + var $image_unsharp; + + /** + * Sets the unsharp mask amount + * + * Value is an integer between 0 and 500, typically between 50 and 200 + * + * Unless used with {@link image_unsharp}, this setting has no effect + * + * Default value is 80 + * + * @access public + * @var integer + */ + var $image_unsharp_amount; + + /** + * Sets the unsharp mask radius + * + * Value is an integer between 0 and 50, typically between 0.5 and 1 + * It is not recommended to change it, the default works best + * + * Unless used with {@link image_unsharp}, this setting has no effect + * + * From PHP 5.1, imageconvolution is used, and this setting has no effect + * + * Default value is 0.5 + * + * @access public + * @var integer + */ + var $image_unsharp_radius; + + /** + * Sets the unsharp mask threshold + * + * Value is an integer between 0 and 255, typically between 0 and 5 + * + * Unless used with {@link image_unsharp}, this setting has no effect + * + * Default value is 1 + * + * @access public + * @var integer + */ + var $image_unsharp_threshold; + + /** + * Adds a text label on the image + * + * Value is a string, any text. Text will not word-wrap, although you can use breaklines in your text "\n" + * + * If set, this setting allow the use of all other settings starting with image_text_ + * + * Replacement tokens can be used in the string: + *
+     * gd_version    src_name       src_name_body src_name_ext
+     * src_pathname  src_mime       src_x         src_y
+     * src_type      src_bits       src_pixels
+     * src_size      src_size_kb    src_size_mb   src_size_human
+     * dst_path      dst_name_body  dst_pathname
+     * dst_name      dst_name_ext   dst_x         dst_y
+     * date          time           host          server        ip
+     * 
+ * The tokens must be enclosed in square brackets: [dst_x] will be replaced by the width of the picture + * + * Default value is null + * + * @access public + * @var string; + */ + var $image_text; + + /** + * Sets the text direction for the text label + * + * Value is either 'h' or 'v', as in horizontal and vertical + * + * Note that if you use a TrueType font, you can use {@link image_text_angle} instead + * + * Default value is h (horizontal) + * + * @access public + * @var string; + */ + var $image_text_direction; + + /** + * Sets the text color for the text label + * + * Value is an hexadecimal color, such as #FFFFFF + * + * Default value is #FFFFFF (white) + * + * @access public + * @var string; + */ + var $image_text_color; + + /** + * Sets the text opacity in the text label + * + * Value is a percentage, as an integer between 0 (transparent) and 100 (opaque) + * + * Default value is 100 + * + * @access public + * @var integer + */ + var $image_text_opacity; + + /** + * Sets the text background color for the text label + * + * Value is an hexadecimal color, such as #FFFFFF + * + * Default value is null (no background) + * + * @access public + * @var string; + */ + var $image_text_background; + + /** + * Sets the text background opacity in the text label + * + * Value is a percentage, as an integer between 0 (transparent) and 100 (opaque) + * + * Default value is 100 + * + * @access public + * @var integer + */ + var $image_text_background_opacity; + + /** + * Sets the text font in the text label + * + * Value is a an integer between 1 and 5 for GD built-in fonts. 1 is the smallest font, 5 the biggest + * Value can also be a string, which represents the path to a GDF or TTF font (TrueType). + * + * Default value is 5 + * + * @access public + * @var mixed; + */ + var $image_text_font; + + /** + * Sets the text font size for TrueType fonts + * + * Value is a an integer, and represents the font size in pixels (GD1) or points (GD1) + * + * Note that this setting is only applicable to TrueType fonts, and has no effects with GD fonts + * + * Default value is 16 + * + * @access public + * @var integer; + */ + var $image_text_size; + + /** + * Sets the text angle for TrueType fonts + * + * Value is a an integer between 0 and 360, in degrees, with 0 degrees being left-to-right reading text. + * + * Note that this setting is only applicable to TrueType fonts, and has no effects with GD fonts + * For GD fonts, you can use {@link image_text_direction} instead + * + * Default value is null (so it is determined by the value of {@link image_text_direction}) + * + * @access public + * @var integer; + */ + var $image_text_angle; + + /** + * Sets the text label position within the image + * + * Value is one or two out of 'TBLR' (top, bottom, left, right) + * + * The positions are as following: + *
+     *                        TL  T  TR
+     *                        L       R
+     *                        BL  B  BR
+     * 
+ * + * Default value is null (centered, horizontal and vertical) + * + * Note that is {@link image_text_x} and {@link image_text_y} are used, this setting has no effect + * + * @access public + * @var string; + */ + var $image_text_position; + + /** + * Sets the text label absolute X position within the image + * + * Value is in pixels, representing the distance between the left of the image and the label + * If a negative value is used, it will represent the distance between the right of the image and the label + * + * Default value is null (so {@link image_text_position} is used) + * + * @access public + * @var integer + */ + var $image_text_x; + + /** + * Sets the text label absolute Y position within the image + * + * Value is in pixels, representing the distance between the top of the image and the label + * If a negative value is used, it will represent the distance between the bottom of the image and the label + * + * Default value is null (so {@link image_text_position} is used) + * + * @access public + * @var integer + */ + var $image_text_y; + + /** + * Sets the text label padding + * + * Value is in pixels, representing the distance between the text and the label background border + * + * Default value is 0 + * + * This setting can be overriden by {@link image_text_padding_x} and {@link image_text_padding_y} + * + * @access public + * @var integer + */ + var $image_text_padding; + + /** + * Sets the text label horizontal padding + * + * Value is in pixels, representing the distance between the text and the left and right label background borders + * + * Default value is null + * + * If set, this setting overrides the horizontal part of {@link image_text_padding} + * + * @access public + * @var integer + */ + var $image_text_padding_x; + + /** + * Sets the text label vertical padding + * + * Value is in pixels, representing the distance between the text and the top and bottom label background borders + * + * Default value is null + * + * If set, his setting overrides the vertical part of {@link image_text_padding} + * + * @access public + * @var integer + */ + var $image_text_padding_y; + + /** + * Sets the text alignment + * + * Value is a string, which can be either 'L', 'C' or 'R' + * + * Default value is 'C' + * + * This setting is relevant only if the text has several lines. + * + * Note that this setting is only applicable to GD fonts, and has no effects with TrueType fonts + * + * @access public + * @var string; + */ + var $image_text_alignment; + + /** + * Sets the text line spacing + * + * Value is an integer, in pixels + * + * Default value is 0 + * + * This setting is relevant only if the text has several lines. + * + * Note that this setting is only applicable to GD fonts, and has no effects with TrueType fonts + * + * @access public + * @var integer + */ + var $image_text_line_spacing; + + /** + * Sets the height of the reflection + * + * Value is an integer in pixels, or a string which format can be in pixels or percentage. + * For instance, values can be : 40, '40', '40px' or '40%' + * + * Default value is null, no reflection + * + * @access public + * @var mixed; + */ + var $image_reflection_height; + + /** + * Sets the space between the source image and its relection + * + * Value is an integer in pixels, which can be negative + * + * Default value is 2 + * + * This setting is relevant only if {@link image_reflection_height} is set + * + * @access public + * @var integer + */ + var $image_reflection_space; + + /** + * Sets the initial opacity of the reflection + * + * Value is an integer between 0 (no opacity) and 100 (full opacity). + * The reflection will start from {@link image_reflection_opacity} and end up at 0 + * + * Default value is 60 + * + * This setting is relevant only if {@link image_reflection_height} is set + * + * @access public + * @var integer + */ + var $image_reflection_opacity; + + /** + * Automatically rotates the image according to EXIF data (JPEG only) + * + * Default value is true + * + * @access public + * @var boolean; + */ + var $image_auto_rotate; + + /** + * Flips the image vertically or horizontally + * + * Value is either 'h' or 'v', as in horizontal and vertical + * + * Default value is null (no flip) + * + * @access public + * @var string; + */ + var $image_flip; + + /** + * Rotates the image by increments of 45 degrees + * + * Value is either 90, 180 or 270 + * + * Default value is null (no rotation) + * + * @access public + * @var string; + */ + var $image_rotate; + + /** + * Crops an image + * + * Values are four dimensions, or two, or one (CSS style) + * They represent the amount cropped top, right, bottom and left. + * These values can either be in an array, or a space separated string. + * Each value can be in pixels (with or without 'px'), or percentage (of the source image) + * + * For instance, are valid: + *
+     * $foo->image_crop = 20                  OR array(20);
+     * $foo->image_crop = '20px'              OR array('20px');
+     * $foo->image_crop = '20 40'             OR array('20', 40);
+     * $foo->image_crop = '-20 25%'           OR array(-20, '25%');
+     * $foo->image_crop = '20px 25%'          OR array('20px', '25%');
+     * $foo->image_crop = '20% 25%'           OR array('20%', '25%');
+     * $foo->image_crop = '20% 25% 10% 30%'   OR array('20%', '25%', '10%', '30%');
+     * $foo->image_crop = '20px 25px 2px 2px' OR array('20px', '25%px', '2px', '2px');
+     * $foo->image_crop = '20 25% 40px 10%'   OR array(20, '25%', '40px', '10%');
+     * 
+ * + * If a value is negative, the image will be expanded, and the extra parts will be filled with black + * + * Default value is null (no cropping) + * + * @access public + * @var string OR array; + */ + var $image_crop; + + /** + * Crops an image, before an eventual resizing + * + * See {@link image_crop} for valid formats + * + * Default value is null (no cropping) + * + * @access public + * @var string OR array; + */ + var $image_precrop; + + /** + * Adds a bevel border on the image + * + * Value is a positive integer, representing the thickness of the bevel + * + * If the bevel colors are the same as the background, it makes a fade out effect + * + * Default value is null (no bevel) + * + * @access public + * @var integer + */ + var $image_bevel; + + /** + * Top and left bevel color + * + * Value is a color, in hexadecimal format + * This setting is used only if {@link image_bevel} is set + * + * Default value is #FFFFFF + * + * @access public + * @var string; + */ + var $image_bevel_color1; + + /** + * Right and bottom bevel color + * + * Value is a color, in hexadecimal format + * This setting is used only if {@link image_bevel} is set + * + * Default value is #000000 + * + * @access public + * @var string; + */ + var $image_bevel_color2; + + /** + * Adds a single-color border on the outer of the image + * + * Values are four dimensions, or two, or one (CSS style) + * They represent the border thickness top, right, bottom and left. + * These values can either be in an array, or a space separated string. + * Each value can be in pixels (with or without 'px'), or percentage (of the source image) + * + * See {@link image_crop} for valid formats + * + * If a value is negative, the image will be cropped. + * Note that the dimensions of the picture will be increased by the borders' thickness + * + * Default value is null (no border) + * + * @access public + * @var integer + */ + var $image_border; + + /** + * Border color + * + * Value is a color, in hexadecimal format. + * This setting is used only if {@link image_border} is set + * + * Default value is #FFFFFF + * + * @access public + * @var string; + */ + var $image_border_color; + + /** + * Sets the opacity for the borders + * + * Value is a percentage, as an integer between 0 (transparent) and 100 (opaque) + * + * Unless used with {@link image_border}, this setting has no effect + * + * Default value is 100 + * + * @access public + * @var integer + */ + var $image_border_opacity; + + /** + * Adds a fading-to-transparent border on the image + * + * Values are four dimensions, or two, or one (CSS style) + * They represent the border thickness top, right, bottom and left. + * These values can either be in an array, or a space separated string. + * Each value can be in pixels (with or without 'px'), or percentage (of the source image) + * + * See {@link image_crop} for valid formats + * + * Note that the dimensions of the picture will not be increased by the borders' thickness + * + * Default value is null (no border) + * + * @access public + * @var integer + */ + var $image_border_transparent; + + /** + * Adds a multi-color frame on the outer of the image + * + * Value is an integer. Two values are possible for now: + * 1 for flat border, meaning that the frame is mirrored horizontally and vertically + * 2 for crossed border, meaning that the frame will be inversed, as in a bevel effect + * + * The frame will be composed of colored lines set in {@link image_frame_colors} + * + * Note that the dimensions of the picture will be increased by the borders' thickness + * + * Default value is null (no frame) + * + * @access public + * @var integer + */ + var $image_frame; + + /** + * Sets the colors used to draw a frame + * + * Values is a list of n colors in hexadecimal format. + * These values can either be in an array, or a space separated string. + * + * The colors are listed in the following order: from the outset of the image to its center + * + * For instance, are valid: + *
+     * $foo->image_frame_colors = '#FFFFFF #999999 #666666 #000000';
+     * $foo->image_frame_colors = array('#FFFFFF', '#999999', '#666666', '#000000');
+     * 
+ * + * This setting is used only if {@link image_frame} is set + * + * Default value is '#FFFFFF #999999 #666666 #000000' + * + * @access public + * @var string OR array; + */ + var $image_frame_colors; + + /** + * Sets the opacity for the frame + * + * Value is a percentage, as an integer between 0 (transparent) and 100 (opaque) + * + * Unless used with {@link image_frame}, this setting has no effect + * + * Default value is 100 + * + * @access public + * @var integer + */ + var $image_frame_opacity; + + /** + * Adds a watermark on the image + * + * Value is a local image filename, relative or absolute. GIF, JPG, BMP, WEBP and PNG are supported, as well as PNG and WEBP alpha. + * + * If set, this setting allow the use of all other settings starting with image_watermark_ + * + * Default value is null + * + * @access public + * @var string; + */ + var $image_watermark; + + /** + * Sets the watermarkposition within the image + * + * Value is one or two out of 'TBLR' (top, bottom, left, right) + * + * The positions are as following: TL T TR + * L R + * BL B BR + * + * Default value is null (centered, horizontal and vertical) + * + * Note that is {@link image_watermark_x} and {@link image_watermark_y} are used, this setting has no effect + * + * @access public + * @var string; + */ + var $image_watermark_position; + + /** + * Sets the watermark absolute X position within the image + * + * Value is in pixels, representing the distance between the top of the image and the watermark + * If a negative value is used, it will represent the distance between the bottom of the image and the watermark + * + * Default value is null (so {@link image_watermark_position} is used) + * + * @access public + * @var integer + */ + var $image_watermark_x; + + /** + * Sets the twatermark absolute Y position within the image + * + * Value is in pixels, representing the distance between the left of the image and the watermark + * If a negative value is used, it will represent the distance between the right of the image and the watermark + * + * Default value is null (so {@link image_watermark_position} is used) + * + * @access public + * @var integer + */ + var $image_watermark_y; + + /** + * Prevents the watermark to be resized up if it is smaller than the image + * + * If the watermark if smaller than the destination image, taking in account the desired watermark position + * then it will be resized up to fill in the image (minus the {@link image_watermark_x} or {@link image_watermark_y} values) + * + * If you don't want your watermark to be resized in any way, then + * set {@link image_watermark_no_zoom_in} and {@link image_watermark_no_zoom_out} to true + * If you want your watermark to be resized up or doan to fill in the image better, then + * set {@link image_watermark_no_zoom_in} and {@link image_watermark_no_zoom_out} to false + * + * Default value is true (so the watermark will not be resized up, which is the behaviour most people expect) + * + * @access public + * @var integer + */ + var $image_watermark_no_zoom_in; + + /** + * Prevents the watermark to be resized down if it is bigger than the image + * + * If the watermark if bigger than the destination image, taking in account the desired watermark position + * then it will be resized down to fit in the image (minus the {@link image_watermark_x} or {@link image_watermark_y} values) + * + * If you don't want your watermark to be resized in any way, then + * set {@link image_watermark_no_zoom_in} and {@link image_watermark_no_zoom_out} to true + * If you want your watermark to be resized up or doan to fill in the image better, then + * set {@link image_watermark_no_zoom_in} and {@link image_watermark_no_zoom_out} to false + * + * Default value is false (so the watermark may be shrinked to fit in the image) + * + * @access public + * @var integer + */ + var $image_watermark_no_zoom_out; + + /** + * List of MIME types per extension + * + * @access private + * @var array + */ + var $mime_types; + + /** + * Allowed MIME types + * + * Default is a selection of safe mime-types, but you might want to change it + * + * Simple wildcards are allowed, such as image/* or application/* + * If there is only one MIME type allowed, then it can be a string instead of an array + * + * @access public + * @var array OR string + */ + var $allowed; + + /** + * Forbidden MIME types + * + * Default is a selection of safe mime-types, but you might want to change it + * To only check for forbidden MIME types, and allow everything else, set {@link allowed} to array('* / *') without the spaces + * + * Simple wildcards are allowed, such as image/* or application/* + * If there is only one MIME type forbidden, then it can be a string instead of an array + * + * @access public + * @var array OR string + */ + var $forbidden; + + /** + * Blacklisted file extensions + * + * List of blacklisted extensions, that are enforced if {@link no_script} is true + * + * @access public + * @var array + */ + var $blacklist; + + + /** + * Array of translated error messages + * + * By default, the language is english (en_GB) + * Translations can be in separate files, in a lang/ subdirectory + * + * @access public + * @var array + */ + var $translation; + + /** + * Language selected for the translations + * + * By default, the language is english ("en_GB") + * + * @access public + * @var array + */ + var $lang; + + /** + * Init or re-init all the processing variables to their default values + * + * This function is called in the constructor, and after each call of {@link process} + * + * @access private + */ + function init() { + + // overiddable variables + $this->file_new_name_body = null; // replace the name body + $this->file_name_body_add = null; // append to the name body + $this->file_name_body_pre = null; // prepend to the name body + $this->file_new_name_ext = null; // replace the file extension + $this->file_safe_name = true; // format safely the filename + $this->file_force_extension = true; // forces extension if there isn't one + $this->file_overwrite = false; // allows overwritting if the file already exists + $this->file_auto_rename = true; // auto-rename if the file already exists + $this->dir_auto_create = true; // auto-creates directory if missing + $this->dir_auto_chmod = true; // auto-chmod directory if not writeable + $this->dir_chmod = 0755; // default chmod to use + + $this->no_script = true; // turns scripts into test files + $this->mime_check = true; // checks the mime type against the allowed list + + // these are the different MIME detection methods. if one of these method doesn't work on your + // system, you can deactivate it here; just set it to false + $this->mime_fileinfo = true; // MIME detection with Fileinfo PECL extension + $this->mime_file = true; // MIME detection with UNIX file() command + $this->mime_magic = true; // MIME detection with mime_magic (mime_content_type()) + $this->mime_getimagesize = true; // MIME detection with getimagesize() + + // get the default max size from php.ini + $this->file_max_size_raw = trim(ini_get('upload_max_filesize')); + $this->file_max_size = $this->getsize($this->file_max_size_raw); + + $this->image_resize = false; // resize the image + $this->image_convert = ''; // convert. values :''; 'png'; 'jpeg'; 'gif'; 'bmp' + + $this->image_x = 150; + $this->image_y = 150; + $this->image_ratio = false; // keeps aspect ratio within x and y dimensions + $this->image_ratio_crop = false; // keeps aspect ratio within x and y dimensions, filling the space + $this->image_ratio_fill = false; // keeps aspect ratio within x and y dimensions, fitting the image in the space + $this->image_ratio_pixels = false; // keeps aspect ratio, calculating x and y to reach the number of pixels + $this->image_ratio_x = false; // calculate the $image_x if true + $this->image_ratio_y = false; // calculate the $image_y if true + $this->image_ratio_no_zoom_in = false; + $this->image_ratio_no_zoom_out = false; + $this->image_no_enlarging = false; + $this->image_no_shrinking = false; + + $this->png_compression = null; + $this->webp_quality = 85; + $this->jpeg_quality = 85; + $this->jpeg_size = null; + $this->image_interlace = false; + $this->image_is_transparent = false; + $this->image_transparent_color = null; + $this->image_background_color = null; + $this->image_default_color = '#ffffff'; + $this->image_is_palette = false; + + $this->image_max_width = null; + $this->image_max_height = null; + $this->image_max_pixels = null; + $this->image_max_ratio = null; + $this->image_min_width = null; + $this->image_min_height = null; + $this->image_min_pixels = null; + $this->image_min_ratio = null; + + $this->image_brightness = null; + $this->image_contrast = null; + $this->image_opacity = null; + $this->image_threshold = null; + $this->image_tint_color = null; + $this->image_overlay_color = null; + $this->image_overlay_opacity = null; + $this->image_negative = false; + $this->image_greyscale = false; + $this->image_pixelate = null; + $this->image_unsharp = false; + $this->image_unsharp_amount = 80; + $this->image_unsharp_radius = 0.5; + $this->image_unsharp_threshold = 1; + + $this->image_text = null; + $this->image_text_direction = null; + $this->image_text_color = '#FFFFFF'; + $this->image_text_opacity = 100; + $this->image_text_background = null; + $this->image_text_background_opacity = 100; + $this->image_text_font = 5; + $this->image_text_size = 16; + $this->image_text_angle = null; + $this->image_text_x = null; + $this->image_text_y = null; + $this->image_text_position = null; + $this->image_text_padding = 0; + $this->image_text_padding_x = null; + $this->image_text_padding_y = null; + $this->image_text_alignment = 'C'; + $this->image_text_line_spacing = 0; + + $this->image_reflection_height = null; + $this->image_reflection_space = 2; + $this->image_reflection_opacity = 60; + + $this->image_watermark = null; + $this->image_watermark_x = null; + $this->image_watermark_y = null; + $this->image_watermark_position = null; + $this->image_watermark_no_zoom_in = true; + $this->image_watermark_no_zoom_out = false; + + $this->image_flip = null; + $this->image_auto_rotate = true; + $this->image_rotate = null; + $this->image_crop = null; + $this->image_precrop = null; + + $this->image_bevel = null; + $this->image_bevel_color1 = '#FFFFFF'; + $this->image_bevel_color2 = '#000000'; + $this->image_border = null; + $this->image_border_color = '#FFFFFF'; + $this->image_border_opacity = 100; + $this->image_border_transparent = null; + $this->image_frame = null; + $this->image_frame_colors = '#FFFFFF #999999 #666666 #000000'; + $this->image_frame_opacity = 100; + + $this->forbidden = array(); + $this->allowed = array( + 'application/arj', + 'application/excel', + 'application/gnutar', + 'application/mspowerpoint', + 'application/msword', + 'application/octet-stream', + 'application/onenote', + 'application/pdf', + 'application/plain', + 'application/postscript', + 'application/powerpoint', + 'application/rar', + 'application/rtf', + 'application/vnd.ms-excel', + 'application/vnd.ms-excel.addin.macroEnabled.12', + 'application/vnd.ms-excel.sheet.binary.macroEnabled.12', + 'application/vnd.ms-excel.sheet.macroEnabled.12', + 'application/vnd.ms-excel.template.macroEnabled.12', + 'application/vnd.ms-office', + 'application/vnd.ms-officetheme', + 'application/vnd.ms-powerpoint', + 'application/vnd.ms-powerpoint.addin.macroEnabled.12', + 'application/vnd.ms-powerpoint.presentation.macroEnabled.12', + 'application/vnd.ms-powerpoint.slide.macroEnabled.12', + 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12', + 'application/vnd.ms-powerpoint.template.macroEnabled.12', + 'application/vnd.ms-word', + 'application/vnd.ms-word.document.macroEnabled.12', + 'application/vnd.ms-word.template.macroEnabled.12', + 'application/vnd.oasis.opendocument.chart', + 'application/vnd.oasis.opendocument.database', + 'application/vnd.oasis.opendocument.formula', + 'application/vnd.oasis.opendocument.graphics', + 'application/vnd.oasis.opendocument.graphics-template', + 'application/vnd.oasis.opendocument.image', + 'application/vnd.oasis.opendocument.presentation', + 'application/vnd.oasis.opendocument.presentation-template', + 'application/vnd.oasis.opendocument.spreadsheet', + 'application/vnd.oasis.opendocument.spreadsheet-template', + 'application/vnd.oasis.opendocument.text', + 'application/vnd.oasis.opendocument.text-master', + 'application/vnd.oasis.opendocument.text-template', + 'application/vnd.oasis.opendocument.text-web', + 'application/vnd.openofficeorg.extension', + 'application/vnd.openxmlformats-officedocument.presentationml.presentation', + 'application/vnd.openxmlformats-officedocument.presentationml.slide', + 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', + 'application/vnd.openxmlformats-officedocument.presentationml.template', + 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', + 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', + 'application/vocaltec-media-file', + 'application/wordperfect', + 'application/haansoftxlsx', + 'application/x-bittorrent', + 'application/x-bzip', + 'application/x-bzip2', + 'application/x-compressed', + 'application/x-excel', + 'application/x-gzip', + 'application/x-latex', + 'application/x-midi', + 'application/xml', + 'application/x-msexcel', + 'application/x-rar', + 'application/x-rar-compressed', + 'application/x-rtf', + 'application/x-shockwave-flash', + 'application/x-sit', + 'application/x-stuffit', + 'application/x-troff-msvideo', + 'application/x-zip', + 'application/x-zip-compressed', + 'application/zip', + 'audio/*', + 'image/*', + 'multipart/x-gzip', + 'multipart/x-zip', + 'text/plain', + 'text/rtf', + 'text/richtext', + 'text/xml', + 'video/*', + 'text/csv', + 'text/x-c', + 'text/x-csv', + 'text/comma-separated-values', + 'text/x-comma-separated-values', + 'application/csv', + 'application/x-csv', + ); + + $this->mime_types = array( + 'jpg' => 'image/jpeg', + 'jpeg' => 'image/jpeg', + 'jpe' => 'image/jpeg', + 'gif' => 'image/gif', + 'webp' => 'image/webp', + 'png' => 'image/png', + 'bmp' => 'image/bmp', + 'flif' => 'image/flif', + 'flv' => 'video/x-flv', + 'js' => 'application/x-javascript', + 'json' => 'application/json', + 'tiff' => 'image/tiff', + 'css' => 'text/css', + 'xml' => 'application/xml', + 'doc' => 'application/msword', + 'xls' => 'application/vnd.ms-excel', + 'xlt' => 'application/vnd.ms-excel', + 'xlm' => 'application/vnd.ms-excel', + 'xld' => 'application/vnd.ms-excel', + 'xla' => 'application/vnd.ms-excel', + 'xlc' => 'application/vnd.ms-excel', + 'xlw' => 'application/vnd.ms-excel', + 'xll' => 'application/vnd.ms-excel', + 'ppt' => 'application/vnd.ms-powerpoint', + 'pps' => 'application/vnd.ms-powerpoint', + 'rtf' => 'application/rtf', + 'pdf' => 'application/pdf', + 'html' => 'text/html', + 'htm' => 'text/html', + 'php' => 'text/html', + 'txt' => 'text/plain', + 'mpeg' => 'video/mpeg', + 'mpg' => 'video/mpeg', + 'mpe' => 'video/mpeg', + 'mp3' => 'audio/mpeg3', + 'wav' => 'audio/wav', + 'aiff' => 'audio/aiff', + 'aif' => 'audio/aiff', + 'avi' => 'video/msvideo', + 'wmv' => 'video/x-ms-wmv', + 'mov' => 'video/quicktime', + 'zip' => 'application/zip', + 'tar' => 'application/x-tar', + 'swf' => 'application/x-shockwave-flash', + 'odt' => 'application/vnd.oasis.opendocument.text', + 'ott' => 'application/vnd.oasis.opendocument.text-template', + 'oth' => 'application/vnd.oasis.opendocument.text-web', + 'odm' => 'application/vnd.oasis.opendocument.text-master', + 'odg' => 'application/vnd.oasis.opendocument.graphics', + 'otg' => 'application/vnd.oasis.opendocument.graphics-template', + 'odp' => 'application/vnd.oasis.opendocument.presentation', + 'otp' => 'application/vnd.oasis.opendocument.presentation-template', + 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', + 'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template', + 'odc' => 'application/vnd.oasis.opendocument.chart', + 'odf' => 'application/vnd.oasis.opendocument.formula', + 'odb' => 'application/vnd.oasis.opendocument.database', + 'odi' => 'application/vnd.oasis.opendocument.image', + 'oxt' => 'application/vnd.openofficeorg.extension', + 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'docm' => 'application/vnd.ms-word.document.macroEnabled.12', + 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', + 'dotm' => 'application/vnd.ms-word.template.macroEnabled.12', + 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'xlsm' => 'application/vnd.ms-excel.sheet.macroEnabled.12', + 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', + 'xltm' => 'application/vnd.ms-excel.template.macroEnabled.12', + 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12', + 'xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12', + 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', + 'pptm' => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12', + 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', + 'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12', + 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template', + 'potm' => 'application/vnd.ms-powerpoint.template.macroEnabled.12', + 'ppam' => 'application/vnd.ms-powerpoint.addin.macroEnabled.12', + 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide', + 'sldm' => 'application/vnd.ms-powerpoint.slide.macroEnabled.12', + 'thmx' => 'application/vnd.ms-officetheme', + 'onetoc' => 'application/onenote', + 'onetoc2' => 'application/onenote', + 'onetmp' => 'application/onenote', + 'onepkg' => 'application/onenote', + 'csv' => 'text/csv', + ); + + $this->blacklist = array( + 'php', + 'php7', + 'php6', + 'php5', + 'php4', + 'php3', + 'phtml', + 'pht', + 'phpt', + 'phtm', + 'phps', + 'inc', + 'pl', + 'py', + 'cgi', + 'asp', + 'js', + 'sh', + 'phar', + ); + + } + + /** + * Constructor, for PHP5+ + */ + function __construct($file, $lang = 'en_GB') { + $this->upload($file, $lang); + } + + /** + * Constructor, for PHP4. Checks if the file has been uploaded + * + * The constructor takes $_FILES['form_field'] array as argument + * where form_field is the form field name + * + * The constructor will check if the file has been uploaded in its temporary location, and + * accordingly will set {@link uploaded} (and {@link error} is an error occurred) + * + * If the file has been uploaded, the constructor will populate all the variables holding the upload + * information (none of the processing class variables are used here). + * You can have access to information about the file (name, size, MIME type...). + * + * + * Alternatively, you can set the first argument to be a local filename (string) + * This allows processing of a local file, as if the file was uploaded + * + * The optional second argument allows you to set the language for the error messages + * + * @access private + * @param array $file $_FILES['form_field'] + * or string $file Local filename + * @param string $lang Optional language code + */ + function upload($file, $lang = 'en_GB') { + + $this->version = '03/08/2019'; + + $this->file_src_name = ''; + $this->file_src_name_body = ''; + $this->file_src_name_ext = ''; + $this->file_src_mime = ''; + $this->file_src_size = ''; + $this->file_src_error = ''; + $this->file_src_pathname = ''; + $this->file_src_temp = ''; + + $this->file_dst_path = ''; + $this->file_dst_name = ''; + $this->file_dst_name_body = ''; + $this->file_dst_name_ext = ''; + $this->file_dst_pathname = ''; + + $this->image_src_x = null; + $this->image_src_y = null; + $this->image_src_bits = null; + $this->image_src_type = null; + $this->image_src_pixels = null; + $this->image_dst_x = 0; + $this->image_dst_y = 0; + $this->image_dst_type = ''; + + $this->uploaded = true; + $this->no_upload_check = false; + $this->processed = false; + $this->error = ''; + $this->log = ''; + $this->allowed = array(); + $this->forbidden = array(); + $this->file_is_image = false; + $this->init(); + $info = null; + $mime_from_browser = null; + + // sets default language + $this->translation = array(); + $this->translation['file_error'] = 'File error. Please try again.'; + $this->translation['local_file_missing'] = 'Local file doesn\'t exist.'; + $this->translation['local_file_not_readable'] = 'Local file is not readable.'; + $this->translation['uploaded_too_big_ini'] = 'File upload error (the uploaded file exceeds the upload_max_filesize directive in php.ini).'; + $this->translation['uploaded_too_big_html'] = 'File upload error (the uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form).'; + $this->translation['uploaded_partial'] = 'File upload error (the uploaded file was only partially uploaded).'; + $this->translation['uploaded_missing'] = 'File upload error (no file was uploaded).'; + $this->translation['uploaded_no_tmp_dir'] = 'File upload error (missing a temporary folder).'; + $this->translation['uploaded_cant_write'] = 'File upload error (failed to write file to disk).'; + $this->translation['uploaded_err_extension'] = 'File upload error (file upload stopped by extension).'; + $this->translation['uploaded_unknown'] = 'File upload error (unknown error code).'; + $this->translation['try_again'] = 'File upload error. Please try again.'; + $this->translation['file_too_big'] = 'File too big.'; + $this->translation['no_mime'] = 'MIME type can\'t be detected.'; + $this->translation['incorrect_file'] = 'Incorrect type of file.'; + $this->translation['image_too_wide'] = 'Image too wide.'; + $this->translation['image_too_narrow'] = 'Image too narrow.'; + $this->translation['image_too_high'] = 'Image too tall.'; + $this->translation['image_too_short'] = 'Image too short.'; + $this->translation['ratio_too_high'] = 'Image ratio too high (image too wide).'; + $this->translation['ratio_too_low'] = 'Image ratio too low (image too high).'; + $this->translation['too_many_pixels'] = 'Image has too many pixels.'; + $this->translation['not_enough_pixels'] = 'Image has not enough pixels.'; + $this->translation['file_not_uploaded'] = 'File not uploaded. Can\'t carry on a process.'; + $this->translation['already_exists'] = '%s already exists. Please change the file name.'; + $this->translation['temp_file_missing'] = 'No correct temp source file. Can\'t carry on a process.'; + $this->translation['source_missing'] = 'No correct uploaded source file. Can\'t carry on a process.'; + $this->translation['destination_dir'] = 'Destination directory can\'t be created. Can\'t carry on a process.'; + $this->translation['destination_dir_missing'] = 'Destination directory doesn\'t exist. Can\'t carry on a process.'; + $this->translation['destination_path_not_dir'] = 'Destination path is not a directory. Can\'t carry on a process.'; + $this->translation['destination_dir_write'] = 'Destination directory can\'t be made writeable. Can\'t carry on a process.'; + $this->translation['destination_path_write'] = 'Destination path is not a writeable. Can\'t carry on a process.'; + $this->translation['temp_file'] = 'Can\'t create the temporary file. Can\'t carry on a process.'; + $this->translation['source_not_readable'] = 'Source file is not readable. Can\'t carry on a process.'; + $this->translation['no_create_support'] = 'No create from %s support.'; + $this->translation['create_error'] = 'Error in creating %s image from source.'; + $this->translation['source_invalid'] = 'Can\'t read image source. Not an image?.'; + $this->translation['gd_missing'] = 'GD doesn\'t seem to be present.'; + $this->translation['watermark_no_create_support'] = 'No create from %s support, can\'t read watermark.'; + $this->translation['watermark_create_error'] = 'No %s read support, can\'t create watermark.'; + $this->translation['watermark_invalid'] = 'Unknown image format, can\'t read watermark.'; + $this->translation['file_create'] = 'No %s create support.'; + $this->translation['no_conversion_type'] = 'No conversion type defined.'; + $this->translation['copy_failed'] = 'Error copying file on the server. copy() failed.'; + $this->translation['reading_failed'] = 'Error reading the file.'; + + // determines the language + $this->lang = $lang; + if ($this->lang != 'en_GB' && file_exists(dirname(__FILE__).'/lang') && file_exists(dirname(__FILE__).'/lang/class.upload.' . $lang . '.php')) { + $translation = null; + include(dirname(__FILE__).'/lang/class.upload.' . $lang . '.php'); + if (is_array($translation)) { + $this->translation = array_merge($this->translation, $translation); + } else { + $this->lang = 'en_GB'; + } + } + + + // determines the supported MIME types, and matching image format + $this->image_supported = array(); + if ($this->gdversion()) { + if (imagetypes() & IMG_GIF) { + $this->image_supported['image/gif'] = 'gif'; + } + if (imagetypes() & IMG_JPG) { + $this->image_supported['image/jpg'] = 'jpg'; + $this->image_supported['image/jpeg'] = 'jpg'; + $this->image_supported['image/pjpeg'] = 'jpg'; + } + if (imagetypes() & IMG_PNG) { + $this->image_supported['image/png'] = 'png'; + $this->image_supported['image/x-png'] = 'png'; + } + if (imagetypes() & IMG_WEBP) { + $this->image_supported['image/webp'] = 'webp'; + $this->image_supported['image/x-webp'] = 'webp'; + } + if (imagetypes() & IMG_WBMP) { + $this->image_supported['image/bmp'] = 'bmp'; + $this->image_supported['image/x-ms-bmp'] = 'bmp'; + $this->image_supported['image/x-windows-bmp'] = 'bmp'; + } + } + + // display some system information + if (empty($this->log)) { + $this->log .= 'system information
'; + if ($this->function_enabled('ini_get_all')) { + $inis = ini_get_all(); + $open_basedir = (array_key_exists('open_basedir', $inis) && array_key_exists('local_value', $inis['open_basedir']) && !empty($inis['open_basedir']['local_value'])) ? $inis['open_basedir']['local_value'] : false; + } else { + $open_basedir = false; + } + $gd = $this->gdversion() ? $this->gdversion(true) : 'GD not present'; + $supported = trim((in_array('png', $this->image_supported) ? 'png' : '') . ' ' . + (in_array('webp', $this->image_supported) ? 'webp' : '') . ' ' . + (in_array('jpg', $this->image_supported) ? 'jpg' : '') . ' ' . + (in_array('gif', $this->image_supported) ? 'gif' : '') . ' ' . + (in_array('bmp', $this->image_supported) ? 'bmp' : '')); + $this->log .= '- class version : ' . $this->version . '
'; + $this->log .= '- operating system : ' . PHP_OS . '
'; + $this->log .= '- PHP version : ' . PHP_VERSION . '
'; + $this->log .= '- GD version : ' . $gd . '
'; + $this->log .= '- supported image types : ' . (!empty($supported) ? $supported : 'none') . '
'; + $this->log .= '- open_basedir : ' . (!empty($open_basedir) ? $open_basedir : 'no restriction') . '
'; + $this->log .= '- upload_max_filesize : ' . $this->file_max_size_raw . ' (' . $this->file_max_size . ' bytes)
'; + $this->log .= '- language : ' . $this->lang . '
'; + } + + if (!$file) { + $this->uploaded = false; + $this->error = $this->translate('file_error'); + } + + // check if we sent a local filename or a PHP stream rather than a $_FILE element + if (!is_array($file)) { + if (empty($file)) { + $this->uploaded = false; + $this->error = $this->translate('file_error'); + } else { + $file = (string) $file; + if (substr($file, 0, 4) == 'php:' || substr($file, 0, 5) == 'data:' || substr($file, 0, 7) == 'base64:') { + $data = null; + + // this is a PHP stream, i.e.not uploaded + if (substr($file, 0, 4) == 'php:') { + $file = preg_replace('/^php:(.*)/i', '$1', $file); + if (!$file) $file = $_SERVER['HTTP_X_FILE_NAME']; + if (!$file) $file = 'unknown'; + $data = file_get_contents('php://input'); + $this->log .= 'source is a PHP stream ' . $file . ' of length ' . strlen($data) . '
'; + + // this is the raw file data, base64-encoded, i.e.not uploaded + } else if (substr($file, 0, 7) == 'base64:') { + $data = base64_decode(preg_replace('/^base64:(.*)/i', '$1', $file)); + $file = 'base64'; + $this->log .= 'source is a base64 string of length ' . strlen($data) . '
'; + + // this is the raw file data, base64-encoded, i.e.not uploaded + } else if (substr($file, 0, 5) == 'data:' && strpos($file, 'base64,') !== false) { + $data = base64_decode(preg_replace('/^data:.*base64,(.*)/i', '$1', $file)); + $file = 'base64'; + $this->log .= 'source is a base64 data string of length ' . strlen($data) . '
'; + + // this is the raw file data, i.e.not uploaded + } else if (substr($file, 0, 5) == 'data:') { + $data = preg_replace('/^data:(.*)/i', '$1', $file); + $file = 'data'; + $this->log .= 'source is a data string of length ' . strlen($data) . '
'; + } + + if (!$data) { + $this->log .= '- source is empty!
'; + $this->uploaded = false; + $this->error = $this->translate('source_invalid'); + } + + $this->no_upload_check = true; + + if ($this->uploaded) { + $this->log .= '- requires a temp file ... '; + $hash = $this->temp_dir() . md5($file . rand(1, 1000)); + if ($data && file_put_contents($hash, $data)) { + $this->file_src_pathname = $hash; + $this->log .= ' file created
'; + $this->log .= '    temp file is: ' . $this->file_src_pathname . '
'; + } else { + $this->log .= ' failed
'; + $this->uploaded = false; + $this->error = $this->translate('temp_file'); + } + } + + if ($this->uploaded) { + $this->file_src_name = $file; + $this->log .= '- local file OK
'; + preg_match('/\.([^\.]*$)/', $this->file_src_name, $extension); + if (is_array($extension) && sizeof($extension) > 0) { + $this->file_src_name_ext = strtolower($extension[1]); + $this->file_src_name_body = substr($this->file_src_name, 0, ((strlen($this->file_src_name) - strlen($this->file_src_name_ext)))-1); + } else { + $this->file_src_name_ext = ''; + $this->file_src_name_body = $this->file_src_name; + } + $this->file_src_size = (file_exists($this->file_src_pathname) ? filesize($this->file_src_pathname) : 0); + } + $this->file_src_error = 0; + + } else { + // this is a local filename, i.e.not uploaded + $this->log .= 'source is a local file ' . $file . '
'; + $this->no_upload_check = true; + + if ($this->uploaded && !file_exists($file)) { + $this->uploaded = false; + $this->error = $this->translate('local_file_missing'); + } + + if ($this->uploaded && !is_readable($file)) { + $this->uploaded = false; + $this->error = $this->translate('local_file_not_readable'); + } + + if ($this->uploaded) { + $this->file_src_pathname = $file; + $this->file_src_name = basename($file); + $this->log .= '- local file OK
'; + preg_match('/\.([^\.]*$)/', $this->file_src_name, $extension); + if (is_array($extension) && sizeof($extension) > 0) { + $this->file_src_name_ext = strtolower($extension[1]); + $this->file_src_name_body = substr($this->file_src_name, 0, ((strlen($this->file_src_name) - strlen($this->file_src_name_ext)))-1); + } else { + $this->file_src_name_ext = ''; + $this->file_src_name_body = $this->file_src_name; + } + $this->file_src_size = (file_exists($this->file_src_pathname) ? filesize($this->file_src_pathname) : 0); + } + $this->file_src_error = 0; + } + } + } else { + // this is an element from $_FILE, i.e. an uploaded file + $this->log .= 'source is an uploaded file
'; + if ($this->uploaded) { + $this->file_src_error = trim((int) $file['error']); + switch($this->file_src_error) { + case UPLOAD_ERR_OK: + // all is OK + $this->log .= '- upload OK
'; + break; + case UPLOAD_ERR_INI_SIZE: + $this->uploaded = false; + $this->error = $this->translate('uploaded_too_big_ini'); + break; + case UPLOAD_ERR_FORM_SIZE: + $this->uploaded = false; + $this->error = $this->translate('uploaded_too_big_html'); + break; + case UPLOAD_ERR_PARTIAL: + $this->uploaded = false; + $this->error = $this->translate('uploaded_partial'); + break; + case UPLOAD_ERR_NO_FILE: + $this->uploaded = false; + $this->error = $this->translate('uploaded_missing'); + break; + case @UPLOAD_ERR_NO_TMP_DIR: + $this->uploaded = false; + $this->error = $this->translate('uploaded_no_tmp_dir'); + break; + case @UPLOAD_ERR_CANT_WRITE: + $this->uploaded = false; + $this->error = $this->translate('uploaded_cant_write'); + break; + case @UPLOAD_ERR_EXTENSION: + $this->uploaded = false; + $this->error = $this->translate('uploaded_err_extension'); + break; + default: + $this->uploaded = false; + $this->error = $this->translate('uploaded_unknown') . ' ('.$this->file_src_error.')'; + } + } + + if ($this->uploaded) { + $this->file_src_pathname = (string) $file['tmp_name']; + $this->file_src_name = (string) $file['name']; + if ($this->file_src_name == '') { + $this->uploaded = false; + $this->error = $this->translate('try_again'); + } + } + + if ($this->uploaded) { + $this->log .= '- file name OK
'; + preg_match('/\.([^\.]*$)/', $this->file_src_name, $extension); + if (is_array($extension) && sizeof($extension) > 0) { + $this->file_src_name_ext = strtolower($extension[1]); + $this->file_src_name_body = substr($this->file_src_name, 0, ((strlen($this->file_src_name) - strlen($this->file_src_name_ext)))-1); + } else { + $this->file_src_name_ext = ''; + $this->file_src_name_body = $this->file_src_name; + } + $this->file_src_size = (int) $file['size']; + $mime_from_browser = (string) $file['type']; + } + } + + if ($this->uploaded) { + $this->log .= 'determining MIME type
'; + $this->file_src_mime = null; + + // checks MIME type with Fileinfo PECL extension + if (!$this->file_src_mime || !is_string($this->file_src_mime) || empty($this->file_src_mime) || strpos($this->file_src_mime, '/') === false) { + if ($this->mime_fileinfo) { + $this->log .= '- Checking MIME type with Fileinfo PECL extension
'; + if ($this->function_enabled('finfo_open')) { + $path = null; + if ($this->mime_fileinfo !== '') { + if ($this->mime_fileinfo === true) { + if (getenv('MAGIC') === false) { + if (substr(PHP_OS, 0, 3) == 'WIN') { + $path = realpath(ini_get('extension_dir') . '/../') . '/extras/magic'; + $this->log .= '    MAGIC path defaults to ' . $path . '
'; + } + } else { + $path = getenv('MAGIC'); + $this->log .= '    MAGIC path is set to ' . $path . ' from MAGIC variable
'; + } + } else { + $path = $this->mime_fileinfo; + $this->log .= '    MAGIC path is set to ' . $path . '
'; + } + } + if ($path) { + $f = @finfo_open(FILEINFO_MIME, $path); + } else { + $this->log .= '    MAGIC path will not be used
'; + $f = @finfo_open(FILEINFO_MIME); + } + if (is_resource($f)) { + $mime = finfo_file($f, realpath($this->file_src_pathname)); + finfo_close($f); + $this->file_src_mime = $mime; + $this->log .= '    MIME type detected as ' . $this->file_src_mime . ' by Fileinfo PECL extension
'; + if (preg_match("/^([\.\w-]+)\/([\.\w-]+)(.*)$/i", $this->file_src_mime)) { + $this->file_src_mime = preg_replace("/^([\.\w-]+)\/([\.\w-]+)(.*)$/i", '$1/$2', $this->file_src_mime); + $this->log .= '- MIME validated as ' . $this->file_src_mime . '
'; + } else { + $this->file_src_mime = null; + } + } else { + $this->log .= '    Fileinfo PECL extension failed (finfo_open)
'; + } + } elseif (@class_exists('finfo', false)) { + $f = new finfo( FILEINFO_MIME ); + if ($f) { + $this->file_src_mime = $f->file(realpath($this->file_src_pathname)); + $this->log .= '- MIME type detected as ' . $this->file_src_mime . ' by Fileinfo PECL extension
'; + if (preg_match("/^([\.\w-]+)\/([\.\w-]+)(.*)$/i", $this->file_src_mime)) { + $this->file_src_mime = preg_replace("/^([\.\w-]+)\/([\.\w-]+)(.*)$/i", '$1/$2', $this->file_src_mime); + $this->log .= '- MIME validated as ' . $this->file_src_mime . '
'; + } else { + $this->file_src_mime = null; + } + } else { + $this->log .= '    Fileinfo PECL extension failed (finfo)
'; + } + } else { + $this->log .= '    Fileinfo PECL extension not available
'; + } + } else { + $this->log .= '- Fileinfo PECL extension deactivated
'; + } + } + + // checks MIME type with shell if unix access is authorized + if (!$this->file_src_mime || !is_string($this->file_src_mime) || empty($this->file_src_mime) || strpos($this->file_src_mime, '/') === false) { + if ($this->mime_file) { + $this->log .= '- Checking MIME type with UNIX file() command
'; + if (substr(PHP_OS, 0, 3) != 'WIN') { + if ($this->function_enabled('exec') && $this->function_enabled('escapeshellarg')) { + if (strlen($mime = @exec("file -bi ".escapeshellarg($this->file_src_pathname))) != 0) { + $this->file_src_mime = trim($mime); + $this->log .= '    MIME type detected as ' . $this->file_src_mime . ' by UNIX file() command
'; + if (preg_match("/^([\.\w-]+)\/([\.\w-]+)(.*)$/i", $this->file_src_mime)) { + $this->file_src_mime = preg_replace("/^([\.\w-]+)\/([\.\w-]+)(.*)$/i", '$1/$2', $this->file_src_mime); + $this->log .= '- MIME validated as ' . $this->file_src_mime . '
'; + } else { + $this->file_src_mime = null; + } + } else { + $this->log .= '    UNIX file() command failed
'; + } + } else { + $this->log .= '    PHP exec() function is disabled
'; + } + } else { + $this->log .= '    UNIX file() command not availabled
'; + } + } else { + $this->log .= '- UNIX file() command is deactivated
'; + } + } + + // checks MIME type with mime_magic + if (!$this->file_src_mime || !is_string($this->file_src_mime) || empty($this->file_src_mime) || strpos($this->file_src_mime, '/') === false) { + if ($this->mime_magic) { + $this->log .= '- Checking MIME type with mime.magic file (mime_content_type())
'; + if ($this->function_enabled('mime_content_type')) { + $this->file_src_mime = mime_content_type($this->file_src_pathname); + $this->log .= '    MIME type detected as ' . $this->file_src_mime . ' by mime_content_type()
'; + if (preg_match("/^([\.\w-]+)\/([\.\w-]+)(.*)$/i", $this->file_src_mime)) { + $this->file_src_mime = preg_replace("/^([\.\w-]+)\/([\.\w-]+)(.*)$/i", '$1/$2', $this->file_src_mime); + $this->log .= '- MIME validated as ' . $this->file_src_mime . '
'; + } else { + $this->file_src_mime = null; + } + } else { + $this->log .= '    mime_content_type() is not available
'; + } + } else { + $this->log .= '- mime.magic file (mime_content_type()) is deactivated
'; + } + } + + // checks MIME type with getimagesize() + if (!$this->file_src_mime || !is_string($this->file_src_mime) || empty($this->file_src_mime) || strpos($this->file_src_mime, '/') === false) { + if ($this->mime_getimagesize) { + $this->log .= '- Checking MIME type with getimagesize()
'; + $info = getimagesize($this->file_src_pathname); + if (is_array($info) && array_key_exists('mime', $info)) { + $this->file_src_mime = trim($info['mime']); + if (empty($this->file_src_mime)) { + $this->log .= '    MIME empty, guessing from type
'; + $mime = (is_array($info) && array_key_exists(2, $info) ? $info[2] : null); // 1 = GIF, 2 = JPG, 3 = PNG + $this->file_src_mime = ($mime==IMAGETYPE_GIF ? 'image/gif' : + ($mime==IMAGETYPE_JPEG ? 'image/jpeg' : + ($mime==IMAGETYPE_PNG ? 'image/png' : + ($mime==IMAGETYPE_WEBP ? 'image/webp' : + ($mime==IMAGETYPE_BMP ? 'image/bmp' : null))))); + } + $this->log .= '    MIME type detected as ' . $this->file_src_mime . ' by PHP getimagesize() function
'; + if (preg_match("/^([\.\w-]+)\/([\.\w-]+)(.*)$/i", $this->file_src_mime)) { + $this->file_src_mime = preg_replace("/^([\.\w-]+)\/([\.\w-]+)(.*)$/i", '$1/$2', $this->file_src_mime); + $this->log .= '- MIME validated as ' . $this->file_src_mime . '
'; + } else { + $this->file_src_mime = null; + } + } else { + $this->log .= '    getimagesize() failed
'; + } + } else { + $this->log .= '- getimagesize() is deactivated
'; + } + } + + // default to MIME from browser (or Flash) + if (!empty($mime_from_browser) && !$this->file_src_mime || !is_string($this->file_src_mime) || empty($this->file_src_mime)) { + $this->file_src_mime =$mime_from_browser; + $this->log .= '- MIME type detected as ' . $this->file_src_mime . ' by browser
'; + if (preg_match("/^([\.\w-]+)\/([\.\w-]+)(.*)$/i", $this->file_src_mime)) { + $this->file_src_mime = preg_replace("/^([\.\w-]+)\/([\.\w-]+)(.*)$/i", '$1/$2', $this->file_src_mime); + $this->log .= '- MIME validated as ' . $this->file_src_mime . '
'; + } else { + $this->file_src_mime = null; + } + } + + // we need to work some magic if we upload via Flash + if ($this->file_src_mime == 'application/octet-stream' || !$this->file_src_mime || !is_string($this->file_src_mime) || empty($this->file_src_mime) || strpos($this->file_src_mime, '/') === false) { + if ($this->file_src_mime == 'application/octet-stream') $this->log .= '- Flash may be rewriting MIME as application/octet-stream
'; + $this->log .= '- Try to guess MIME type from file extension (' . $this->file_src_name_ext . '): '; + if (array_key_exists($this->file_src_name_ext, $this->mime_types)) $this->file_src_mime = $this->mime_types[$this->file_src_name_ext]; + if ($this->file_src_mime == 'application/octet-stream') { + $this->log .= 'doesn\'t look like anything known
'; + } else { + $this->log .= 'MIME type set to ' . $this->file_src_mime . '
'; + } + } + + if (!$this->file_src_mime || !is_string($this->file_src_mime) || empty($this->file_src_mime) || strpos($this->file_src_mime, '/') === false) { + $this->log .= '- MIME type couldn\'t be detected! (' . (string) $this->file_src_mime . ')
'; + } + + // determine whether the file is an image + if ($this->file_src_mime && is_string($this->file_src_mime) && !empty($this->file_src_mime) && array_key_exists($this->file_src_mime, $this->image_supported)) { + $this->file_is_image = true; + $this->image_src_type = $this->image_supported[$this->file_src_mime]; + } + + // if the file is an image, we gather some useful data + if ($this->file_is_image) { + if ($h = fopen($this->file_src_pathname, 'r')) { + fclose($h); + $info = getimagesize($this->file_src_pathname); + if (is_array($info)) { + $this->image_src_x = $info[0]; + $this->image_src_y = $info[1]; + $this->image_dst_x = $this->image_src_x; + $this->image_dst_y = $this->image_src_y; + $this->image_src_pixels = $this->image_src_x * $this->image_src_y; + $this->image_src_bits = array_key_exists('bits', $info) ? $info['bits'] : null; + } else { + $this->file_is_image = false; + $this->uploaded = false; + $this->log .= '- can\'t retrieve image information, image may have been tampered with
'; + $this->error = $this->translate('source_invalid'); + } + } else { + $this->log .= '- can\'t read source file directly. open_basedir restriction in place?
'; + } + } + + $this->log .= 'source variables
'; + $this->log .= '- You can use all these before calling process()
'; + $this->log .= '    file_src_name : ' . $this->file_src_name . '
'; + $this->log .= '    file_src_name_body : ' . $this->file_src_name_body . '
'; + $this->log .= '    file_src_name_ext : ' . $this->file_src_name_ext . '
'; + $this->log .= '    file_src_pathname : ' . $this->file_src_pathname . '
'; + $this->log .= '    file_src_mime : ' . $this->file_src_mime . '
'; + $this->log .= '    file_src_size : ' . $this->file_src_size . ' (max= ' . $this->file_max_size . ')
'; + $this->log .= '    file_src_error : ' . $this->file_src_error . '
'; + + if ($this->file_is_image) { + $this->log .= '- source file is an image
'; + $this->log .= '    image_src_x : ' . $this->image_src_x . '
'; + $this->log .= '    image_src_y : ' . $this->image_src_y . '
'; + $this->log .= '    image_src_pixels : ' . $this->image_src_pixels . '
'; + $this->log .= '    image_src_type : ' . $this->image_src_type . '
'; + $this->log .= '    image_src_bits : ' . $this->image_src_bits . '
'; + } + } + + } + + /** + * Returns the version of GD + * + * @access public + * @param boolean $full Optional flag to get precise version + * @return float GD version + */ + function gdversion($full = false) { + static $gd_version = null; + static $gd_full_version = null; + if ($gd_version === null) { + if ($this->function_enabled('gd_info')) { + $gd = gd_info(); + $gd = $gd["GD Version"]; + $regex = "/([\d\.]+)/i"; + } else { + ob_start(); + phpinfo(8); + $gd = ob_get_contents(); + ob_end_clean(); + $regex = "/\bgd\s+version\b[^\d\n\r]+?([\d\.]+)/i"; + } + if (preg_match($regex, $gd, $m)) { + $gd_full_version = (string) $m[1]; + $gd_version = (float) $m[1]; + } else { + $gd_full_version = 'none'; + $gd_version = 0; + } + } + if ($full) { + return $gd_full_version; + } else { + return $gd_version; + } + } + + /** + * Checks if a function is available + * + * @access private + * @param string $func Function name + * @return boolean Success + */ + function function_enabled($func) { + // cache the list of disabled functions + static $disabled = null; + if ($disabled === null) $disabled = array_map('trim', array_map('strtolower', explode(',', ini_get('disable_functions')))); + // cache the list of functions blacklisted by suhosin + static $blacklist = null; + if ($blacklist === null) $blacklist = extension_loaded('suhosin') ? array_map('trim', array_map('strtolower', explode(',', ini_get(' suhosin.executor.func.blacklist')))) : array(); + // checks if the function is really enabled + return (function_exists($func) && !in_array($func, $disabled) && !in_array($func, $blacklist)); + } + + /** + * Creates directories recursively + * + * @access private + * @param string $path Path to create + * @param integer $mode Optional permissions + * @return boolean Success + */ + function rmkdir($path, $mode = 0755) { + return is_dir($path) || ( $this->rmkdir(dirname($path), $mode) && $this->_mkdir($path, $mode) ); + } + + /** + * Creates directory + * + * @access private + * @param string $path Path to create + * @param integer $mode Optional permissions + * @return boolean Success + */ + function _mkdir($path, $mode = 0755) { + $old = umask(0); + $res = @mkdir($path, $mode); + umask($old); + return $res; + } + + /** + * Translate error messages + * + * @access private + * @param string $str Message to translate + * @param array $tokens Optional token values + * @return string Translated string + */ + function translate($str, $tokens = array()) { + if (array_key_exists($str, $this->translation)) $str = $this->translation[$str]; + if (is_array($tokens) && sizeof($tokens) > 0) $str = vsprintf($str, $tokens); + return $str; + } + + /** + * Returns the temp directory + * + * @access private + * @return string Temp directory string + */ + function temp_dir() { + $dir = ''; + if ($this->function_enabled('sys_get_temp_dir')) $dir = sys_get_temp_dir(); + if (!$dir && $tmp=getenv('TMP')) $dir = $tmp; + if (!$dir && $tmp=getenv('TEMP')) $dir = $tmp; + if (!$dir && $tmp=getenv('TMPDIR')) $dir = $tmp; + if (!$dir) { + $tmp = tempnam(__FILE__,''); + if (file_exists($tmp)) { + unlink($tmp); + $dir = dirname($tmp); + } + } + if (!$dir) return ''; + $slash = (strtolower(substr(PHP_OS, 0, 3)) === 'win' ? '\\' : '/'); + if (substr($dir, -1) != $slash) $dir = $dir . $slash; + return $dir; + } + + /** + * Sanitize a file name + * + * @access private + * @param string $filename File name + * @return string Sanitized file name + */ + function sanitize($filename) { + // remove HTML tags + $filename = strip_tags($filename); + // remove non-breaking spaces + $filename = preg_replace("#\x{00a0}#siu", ' ', $filename); + // remove illegal file system characters + $filename = str_replace(array_map('chr', range(0, 31)), '', $filename); + // remove dangerous characters for file names + $chars = array("?", "[", "]", "/", "\\", "=", "<", ">", ":", ";", ",", "'", "\"", "&", "’", "%20", + "+", "$", "#", "*", "(", ")", "|", "~", "`", "!", "{", "}", "%", "+", "^", chr(0)); + $filename = str_replace($chars, '-', $filename); + // remove break/tabs/return carriage + $filename = preg_replace('/[\r\n\t -]+/', '-', $filename); + // convert some special letters + $convert = array('Þ' => 'TH', 'þ' => 'th', 'Ð' => 'DH', 'ð' => 'dh', 'ß' => 'ss', + 'Œ' => 'OE', 'œ' => 'oe', 'Æ' => 'AE', 'æ' => 'ae', 'µ' => 'u'); + $filename = strtr($filename, $convert); + // remove foreign accents by converting to HTML entities, and then remove the code + $filename = html_entity_decode( $filename, ENT_QUOTES, "utf-8" ); + $filename = htmlentities($filename, ENT_QUOTES, "utf-8"); + $filename = preg_replace("/(&)([a-z])([a-z]+;)/i", '$2', $filename); + // clean up, and remove repetitions + $filename = preg_replace('/_+/', '_', $filename); + $filename = preg_replace(array('/ +/', '/-+/'), '-', $filename); + $filename = preg_replace(array('/-*\.-*/', '/\.{2,}/'), '.', $filename); + // cut to 255 characters + $length = 255 - strlen($this->file_dst_name_ext) + 1; + $filename = extension_loaded('mbstring') ? mb_strcut($filename, 0, $length, mb_detect_encoding($filename)) : substr($filename, 0, $length); + // remove bad characters at start and end + $filename = trim($filename, '.-_'); + return $filename; + } + + /** + * Decodes colors + * + * @access private + * @param string $color Color string + * @return array RGB colors + */ + function getcolors($color) { + $color = str_replace('#', '', $color); + if (strlen($color) == 3) $color = str_repeat(substr($color, 0, 1), 2) . str_repeat(substr($color, 1, 1), 2) . str_repeat(substr($color, 2, 1), 2); + $r = sscanf($color, "%2x%2x%2x"); + $red = (is_array($r) && array_key_exists(0, $r) && is_numeric($r[0]) ? $r[0] : 0); + $green = (is_array($r) && array_key_exists(1, $r) && is_numeric($r[1]) ? $r[1] : 0); + $blue = (is_array($r) && array_key_exists(2, $r) && is_numeric($r[2]) ? $r[2] : 0); + return array($red, $green, $blue); + } + + /** + * Decodes sizes + * + * @access private + * @param string $size Size in bytes, or shorthand byte options + * @return integer Size in bytes + */ + function getsize($size) { + if ($size === null) return null; + $last = is_string($size) ? strtolower(substr($size, -1)) : null; + $size = (int) $size; + switch($last) { + case 'g': + $size *= 1024; + case 'm': + $size *= 1024; + case 'k': + $size *= 1024; + } + return $size; + } + + /** + * Decodes offsets + * + * @access private + * @param misc $offsets Offsets, as an integer, a string or an array + * @param integer $x Reference picture width + * @param integer $y Reference picture height + * @param boolean $round Round offsets before returning them + * @param boolean $negative Allow negative offsets to be returned + * @return array Array of four offsets (TRBL) + */ + function getoffsets($offsets, $x, $y, $round = true, $negative = true) { + if (!is_array($offsets)) $offsets = explode(' ', $offsets); + if (sizeof($offsets) == 4) { + $ct = $offsets[0]; $cr = $offsets[1]; $cb = $offsets[2]; $cl = $offsets[3]; + } else if (sizeof($offsets) == 2) { + $ct = $offsets[0]; $cr = $offsets[1]; $cb = $offsets[0]; $cl = $offsets[1]; + } else { + $ct = $offsets[0]; $cr = $offsets[0]; $cb = $offsets[0]; $cl = $offsets[0]; + } + if (strpos($ct, '%')>0) $ct = $y * (str_replace('%','',$ct) / 100); + if (strpos($cr, '%')>0) $cr = $x * (str_replace('%','',$cr) / 100); + if (strpos($cb, '%')>0) $cb = $y * (str_replace('%','',$cb) / 100); + if (strpos($cl, '%')>0) $cl = $x * (str_replace('%','',$cl) / 100); + if (strpos($ct, 'px')>0) $ct = str_replace('px','',$ct); + if (strpos($cr, 'px')>0) $cr = str_replace('px','',$cr); + if (strpos($cb, 'px')>0) $cb = str_replace('px','',$cb); + if (strpos($cl, 'px')>0) $cl = str_replace('px','',$cl); + $ct = (int) $ct; $cr = (int) $cr; $cb = (int) $cb; $cl = (int) $cl; + if ($round) { + $ct = round($ct); + $cr = round($cr); + $cb = round($cb); + $cl = round($cl); + } + if (!$negative) { + if ($ct < 0) $ct = 0; + if ($cr < 0) $cr = 0; + if ($cb < 0) $cb = 0; + if ($cl < 0) $cl = 0; + } + return array($ct, $cr, $cb, $cl); + } + + /** + * Creates a container image + * + * @access private + * @param integer $x Width + * @param integer $y Height + * @param boolean $fill Optional flag to draw the background color or not + * @param boolean $trsp Optional flag to set the background to be transparent + * @return resource Container image + */ + function imagecreatenew($x, $y, $fill = true, $trsp = false) { + if ($x < 1) $x = 1; if ($y < 1) $y = 1; + if ($this->gdversion() >= 2 && !$this->image_is_palette) { + // create a true color image + $dst_im = imagecreatetruecolor($x, $y); + // this preserves transparency in PNG and WEBP, in true color + if (empty($this->image_background_color) || $trsp) { + imagealphablending($dst_im, false ); + imagefilledrectangle($dst_im, 0, 0, $x, $y, imagecolorallocatealpha($dst_im, 0, 0, 0, 127)); + } + } else { + // creates a palette image + $dst_im = imagecreate($x, $y); + // preserves transparency for palette images, if the original image has transparency + if (($fill && $this->image_is_transparent && empty($this->image_background_color)) || $trsp) { + imagefilledrectangle($dst_im, 0, 0, $x, $y, $this->image_transparent_color); + imagecolortransparent($dst_im, $this->image_transparent_color); + } + } + // fills with background color if any is set + if ($fill && !empty($this->image_background_color) && !$trsp) { + list($red, $green, $blue) = $this->getcolors($this->image_background_color); + $background_color = imagecolorallocate($dst_im, $red, $green, $blue); + imagefilledrectangle($dst_im, 0, 0, $x, $y, $background_color); + } + return $dst_im; + } + + + /** + * Transfers an image from the container to the destination image + * + * @access private + * @param resource $src_im Container image + * @param resource $dst_im Destination image + * @return resource Destination image + */ + function imagetransfer($src_im, $dst_im) { + $this->imageunset($dst_im); + $dst_im = & $src_im; + return $dst_im; + } + + /** + * Destroy GD ressource + * + * @access private + * @param resource $im Image + */ + function imageunset($im) { + if (is_resource($im)) { + imagedestroy($im); + } else if (is_object($im) && $im instanceOf \GdImage) { + unset($im); + } + } + + /** + * Merges two images + * + * If the output format is PNG or WEBP, then we do it pixel per pixel to retain the alpha channel + * + * @access private + * @param resource $dst_img Destination image + * @param resource $src_img Overlay image + * @param int $dst_x x-coordinate of destination point + * @param int $dst_y y-coordinate of destination point + * @param int $src_x x-coordinate of source point + * @param int $src_y y-coordinate of source point + * @param int $src_w Source width + * @param int $src_h Source height + * @param int $pct Optional percentage of the overlay, between 0 and 100 (default: 100) + * @return resource Destination image + */ + function imagecopymergealpha(&$dst_im, &$src_im, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h, $pct = 0) { + $dst_x = (int) $dst_x; + $dst_y = (int) $dst_y; + $src_x = (int) $src_x; + $src_y = (int) $src_y; + $src_w = (int) $src_w; + $src_h = (int) $src_h; + $pct = (int) $pct; + $dst_w = imagesx($dst_im); + $dst_h = imagesy($dst_im); + + for ($y = $src_y; $y < $src_h; $y++) { + for ($x = $src_x; $x < $src_w; $x++) { + + if ($x + $dst_x >= 0 && $x + $dst_x < $dst_w && $x + $src_x >= 0 && $x + $src_x < $src_w + && $y + $dst_y >= 0 && $y + $dst_y < $dst_h && $y + $src_y >= 0 && $y + $src_y < $src_h) { + + $dst_pixel = imagecolorsforindex($dst_im, imagecolorat($dst_im, $x + $dst_x, $y + $dst_y)); + $src_pixel = imagecolorsforindex($src_im, imagecolorat($src_im, $x + $src_x, $y + $src_y)); + + $src_alpha = 1 - ($src_pixel['alpha'] / 127); + $dst_alpha = 1 - ($dst_pixel['alpha'] / 127); + $opacity = $src_alpha * $pct / 100; + if ($dst_alpha >= $opacity) $alpha = $dst_alpha; + if ($dst_alpha < $opacity) $alpha = $opacity; + if ($alpha > 1) $alpha = 1; + + if ($opacity > 0) { + $dst_red = round(( ($dst_pixel['red'] * $dst_alpha * (1 - $opacity)) ) ); + $dst_green = round(( ($dst_pixel['green'] * $dst_alpha * (1 - $opacity)) ) ); + $dst_blue = round(( ($dst_pixel['blue'] * $dst_alpha * (1 - $opacity)) ) ); + $src_red = round((($src_pixel['red'] * $opacity)) ); + $src_green = round((($src_pixel['green'] * $opacity)) ); + $src_blue = round((($src_pixel['blue'] * $opacity)) ); + $red = round(($dst_red + $src_red ) / ($dst_alpha * (1 - $opacity) + $opacity)); + $green = round(($dst_green + $src_green) / ($dst_alpha * (1 - $opacity) + $opacity)); + $blue = round(($dst_blue + $src_blue ) / ($dst_alpha * (1 - $opacity) + $opacity)); + if ($red > 255) $red = 255; + if ($green > 255) $green = 255; + if ($blue > 255) $blue = 255; + $alpha = round((1 - $alpha) * 127); + $color = imagecolorallocatealpha($dst_im, $red, $green, $blue, $alpha); + imagesetpixel($dst_im, $x + $dst_x, $y + $dst_y, $color); + } + } + } + } + return true; + } + + + + /** + * Actually uploads the file, and act on it according to the set processing class variables + * + * This function copies the uploaded file to the given location, eventually performing actions on it. + * Typically, you can call {@link process} several times for the same file, + * for instance to create a resized image and a thumbnail of the same file. + * The original uploaded file remains intact in its temporary location, so you can use {@link process} several times. + * You will be able to delete the uploaded file with {@link clean} when you have finished all your {@link process} calls. + * + * According to the processing class variables set in the calling file, the file can be renamed, + * and if it is an image, can be resized or converted. + * + * When the processing is completed, and the file copied to its new location, the + * processing class variables will be reset to their default value. + * This allows you to set new properties, and perform another {@link process} on the same uploaded file + * + * If the function is called with a null or empty argument, then it will return the content of the picture + * + * It will set {@link processed} (and {@link error} is an error occurred) + * + * @access public + * @param string $server_path Optional path location of the uploaded file, with an ending slash + * @return string Optional content of the image + */ + function process($server_path = null) { + $this->error = ''; + $this->processed = true; + $return_mode = false; + $return_content = null; + + // clean up dst variables + $this->file_dst_path = ''; + $this->file_dst_pathname = ''; + $this->file_dst_name = ''; + $this->file_dst_name_body = ''; + $this->file_dst_name_ext = ''; + + // clean up some parameters + $this->file_max_size = $this->getsize($this->file_max_size); + $this->jpeg_size = $this->getsize($this->jpeg_size); + + // copy some variables as we need to keep them clean + $file_src_name = $this->file_src_name; + $file_src_name_body = $this->file_src_name_body; + $file_src_name_ext = $this->file_src_name_ext; + + if (!$this->uploaded) { + $this->error = $this->translate('file_not_uploaded'); + $this->processed = false; + } + + if ($this->processed) { + if (empty($server_path) || is_null($server_path)) { + $this->log .= 'process file and return the content
'; + $return_mode = true; + } else { + if(strtolower(substr(PHP_OS, 0, 3)) === 'win') { + if (substr($server_path, -1, 1) != '\\') $server_path = $server_path . '\\'; + } else { + if (substr($server_path, -1, 1) != '/') $server_path = $server_path . '/'; + } + $this->log .= 'process file to ' . $server_path . '
'; + } + } + + if ($this->processed) { + // checks file max size + if ($this->file_src_size > $this->file_max_size) { + $this->processed = false; + $this->error = $this->translate('file_too_big') . ' : ' . $this->file_src_size . ' > ' . $this->file_max_size; + } else { + $this->log .= '- file size OK
'; + } + } + + if ($this->processed) { + // if we have an image without extension, set it + if ($this->file_force_extension && $this->file_is_image && !$this->file_src_name_ext) $file_src_name_ext = $this->image_src_type; + // turn dangerous scripts into text files + if ($this->no_script) { + // if the file has no extension, we try to guess it from the MIME type + if ($this->file_force_extension && empty($file_src_name_ext)) { + if ($key = array_search($this->file_src_mime, $this->mime_types)) { + $file_src_name_ext = $key; + $file_src_name = $file_src_name_body . '.' . $file_src_name_ext; + $this->log .= '- file renamed as ' . $file_src_name_body . '.' . $file_src_name_ext . '!
'; + } + } + // if the file is text based, or has a dangerous extension, we rename it as .txt + if ((((substr($this->file_src_mime, 0, 5) == 'text/' && $this->file_src_mime != 'text/rtf') || strpos($this->file_src_mime, 'javascript') !== false) && (substr($file_src_name, -4) != '.txt')) + || preg_match('/\.(' . implode('|', $this->blacklist) . ')$/i', $this->file_src_name) + || $this->file_force_extension && empty($file_src_name_ext)) { + $this->file_src_mime = 'text/plain'; + if ($this->file_src_name_ext) $file_src_name_body = $file_src_name_body . '.' . $this->file_src_name_ext; + $file_src_name_ext = 'txt'; + $file_src_name = $file_src_name_body . '.' . $file_src_name_ext; + $this->log .= '- script renamed as ' . $file_src_name_body . '.' . $file_src_name_ext . '!
'; + } + } + + if ($this->mime_check && empty($this->file_src_mime)) { + $this->processed = false; + $this->error = $this->translate('no_mime'); + } else if ($this->mime_check && !empty($this->file_src_mime) && strpos($this->file_src_mime, '/') !== false) { + list($m1, $m2) = explode('/', $this->file_src_mime); + $allowed = false; + // check wether the mime type is allowed + if (!is_array($this->allowed)) $this->allowed = array($this->allowed); + foreach($this->allowed as $k => $v) { + list($v1, $v2) = explode('/', $v); + if (($v1 == '*' && $v2 == '*') || ($v1 == $m1 && ($v2 == $m2 || $v2 == '*'))) { + $allowed = true; + break; + } + } + // check wether the mime type is forbidden + if (!is_array($this->forbidden)) $this->forbidden = array($this->forbidden); + foreach($this->forbidden as $k => $v) { + list($v1, $v2) = explode('/', $v); + if (($v1 == '*' && $v2 == '*') || ($v1 == $m1 && ($v2 == $m2 || $v2 == '*'))) { + $allowed = false; + break; + } + } + if (!$allowed) { + $this->processed = false; + $this->error = $this->translate('incorrect_file'); + } else { + $this->log .= '- file mime OK : ' . $this->file_src_mime . '
'; + } + } else { + $this->log .= '- file mime (not checked) : ' . $this->file_src_mime . '
'; + } + + // if the file is an image, we can check on its dimensions + // these checks are not available if open_basedir restrictions are in place + if ($this->file_is_image) { + if (is_numeric($this->image_src_x) && is_numeric($this->image_src_y)) { + $ratio = $this->image_src_x / $this->image_src_y; + if (!is_null($this->image_max_width) && $this->image_src_x > $this->image_max_width) { + $this->processed = false; + $this->error = $this->translate('image_too_wide'); + } + if (!is_null($this->image_min_width) && $this->image_src_x < $this->image_min_width) { + $this->processed = false; + $this->error = $this->translate('image_too_narrow'); + } + if (!is_null($this->image_max_height) && $this->image_src_y > $this->image_max_height) { + $this->processed = false; + $this->error = $this->translate('image_too_high'); + } + if (!is_null($this->image_min_height) && $this->image_src_y < $this->image_min_height) { + $this->processed = false; + $this->error = $this->translate('image_too_short'); + } + if (!is_null($this->image_max_ratio) && $ratio > $this->image_max_ratio) { + $this->processed = false; + $this->error = $this->translate('ratio_too_high'); + } + if (!is_null($this->image_min_ratio) && $ratio < $this->image_min_ratio) { + $this->processed = false; + $this->error = $this->translate('ratio_too_low'); + } + if (!is_null($this->image_max_pixels) && $this->image_src_pixels > $this->image_max_pixels) { + $this->processed = false; + $this->error = $this->translate('too_many_pixels'); + } + if (!is_null($this->image_min_pixels) && $this->image_src_pixels < $this->image_min_pixels) { + $this->processed = false; + $this->error = $this->translate('not_enough_pixels'); + } + } else { + $this->log .= '- no image properties available, can\'t enforce dimension checks : ' . $this->file_src_mime . '
'; + } + } + } + + if ($this->processed) { + $this->file_dst_path = $server_path; + + // repopulate dst variables from src + $this->file_dst_name = $file_src_name; + $this->file_dst_name_body = $file_src_name_body; + $this->file_dst_name_ext = $file_src_name_ext; + if ($this->file_overwrite) $this->file_auto_rename = false; + + if ($this->image_convert && $this->file_is_image) { // if we convert as an image + $this->file_dst_name_ext = $this->image_convert; + $this->log .= '- new file name ext : ' . $this->file_dst_name_ext . '
'; + } + if (!is_null($this->file_new_name_body)) { // rename file body + $this->file_dst_name_body = $this->file_new_name_body; + $this->log .= '- new file name body : ' . $this->file_new_name_body . '
'; + } + if (!is_null($this->file_new_name_ext)) { // rename file ext + $this->file_dst_name_ext = $this->file_new_name_ext; + $this->log .= '- new file name ext : ' . $this->file_new_name_ext . '
'; + } + if (!is_null($this->file_name_body_add)) { // append a string to the name + $this->file_dst_name_body = $this->file_dst_name_body . $this->file_name_body_add; + $this->log .= '- file name body append : ' . $this->file_name_body_add . '
'; + } + if (!is_null($this->file_name_body_pre)) { // prepend a string to the name + $this->file_dst_name_body = $this->file_name_body_pre . $this->file_dst_name_body; + $this->log .= '- file name body prepend : ' . $this->file_name_body_pre . '
'; + } + if ($this->file_safe_name) { // sanitize the name + $this->file_dst_name_body = $this->sanitize($this->file_dst_name_body); + $this->log .= '- file name safe format
'; + } + + $this->log .= '- destination variables
'; + if (empty($this->file_dst_path) || is_null($this->file_dst_path)) { + $this->log .= '    file_dst_path : n/a
'; + } else { + $this->log .= '    file_dst_path : ' . $this->file_dst_path . '
'; + } + $this->log .= '    file_dst_name_body : ' . $this->file_dst_name_body . '
'; + $this->log .= '    file_dst_name_ext : ' . $this->file_dst_name_ext . '
'; + + // set the destination file name + $this->file_dst_name = $this->file_dst_name_body . (!empty($this->file_dst_name_ext) ? '.' . $this->file_dst_name_ext : ''); + + if (!$return_mode) { + if (!$this->file_auto_rename) { + $this->log .= '- no auto_rename if same filename exists
'; + $this->file_dst_pathname = $this->file_dst_path . $this->file_dst_name; + } else { + $this->log .= '- checking for auto_rename
'; + $this->file_dst_pathname = $this->file_dst_path . $this->file_dst_name; + $body = $this->file_dst_name_body; + $ext = ''; + // if we have changed the extension, then we add our increment before + if ($file_src_name_ext != $this->file_src_name_ext) { + if (substr($this->file_dst_name_body, -1 - strlen($this->file_src_name_ext)) == '.' . $this->file_src_name_ext) { + $body = substr($this->file_dst_name_body, 0, strlen($this->file_dst_name_body) - 1 - strlen($this->file_src_name_ext)); + $ext = '.' . $this->file_src_name_ext; + } + } + $cpt = 1; + while (@file_exists($this->file_dst_pathname)) { + $this->file_dst_name_body = $body . '_' . $cpt . $ext; + $this->file_dst_name = $this->file_dst_name_body . (!empty($this->file_dst_name_ext) ? '.' . $this->file_dst_name_ext : ''); + $cpt++; + $this->file_dst_pathname = $this->file_dst_path . $this->file_dst_name; + } + if ($cpt>1) $this->log .= '    auto_rename to ' . $this->file_dst_name . '
'; + } + + $this->log .= '- destination file details
'; + $this->log .= '    file_dst_name : ' . $this->file_dst_name . '
'; + $this->log .= '    file_dst_pathname : ' . $this->file_dst_pathname . '
'; + + if ($this->file_overwrite) { + $this->log .= '- no overwrite checking
'; + } else { + if (@file_exists($this->file_dst_pathname)) { + $this->processed = false; + $this->error = $this->translate('already_exists', array($this->file_dst_name)); + } else { + $this->log .= '- ' . $this->file_dst_name . ' doesn\'t exist already
'; + } + } + } + } + + if ($this->processed) { + // if we have already moved the uploaded file, we use the temporary copy as source file, and check if it exists + if (!empty($this->file_src_temp)) { + $this->log .= '- use the temp file instead of the original file since it is a second process
'; + $this->file_src_pathname = $this->file_src_temp; + if (!file_exists($this->file_src_pathname)) { + $this->processed = false; + $this->error = $this->translate('temp_file_missing'); + } + // if we haven't a temp file, and that we do check on uploads, we use is_uploaded_file() + } else if (!$this->no_upload_check) { + if (!is_uploaded_file($this->file_src_pathname)) { + $this->processed = false; + $this->error = $this->translate('source_missing'); + } + // otherwise, if we don't check on uploaded files (local file for instance), we use file_exists() + } else { + if (!file_exists($this->file_src_pathname)) { + $this->processed = false; + $this->error = $this->translate('source_missing'); + } + } + + // checks if the destination directory exists, and attempt to create it + if (!$return_mode) { + if ($this->processed && !file_exists($this->file_dst_path)) { + if ($this->dir_auto_create) { + $this->log .= '- ' . $this->file_dst_path . ' doesn\'t exist. Attempting creation:'; + if (!$this->rmkdir($this->file_dst_path, $this->dir_chmod)) { + $this->log .= ' failed
'; + $this->processed = false; + $this->error = $this->translate('destination_dir'); + } else { + $this->log .= ' success
'; + } + } else { + $this->error = $this->translate('destination_dir_missing'); + } + } + + if ($this->processed && !is_dir($this->file_dst_path)) { + $this->processed = false; + $this->error = $this->translate('destination_path_not_dir'); + } + + // checks if the destination directory is writeable, and attempt to make it writeable + $hash = md5($this->file_dst_name_body . rand(1, 1000)); + if ($this->processed && !($f = @fopen($this->file_dst_path . $hash . (!empty($this->file_dst_name_ext) ? '.' . $this->file_dst_name_ext : ''), 'a+'))) { + if ($this->dir_auto_chmod) { + $this->log .= '- ' . $this->file_dst_path . ' is not writeable. Attempting chmod:'; + if (!@chmod($this->file_dst_path, $this->dir_chmod)) { + $this->log .= ' failed
'; + $this->processed = false; + $this->error = $this->translate('destination_dir_write'); + } else { + $this->log .= ' success
'; + if (!($f = @fopen($this->file_dst_path . $hash . (!empty($this->file_dst_name_ext) ? '.' . $this->file_dst_name_ext : ''), 'a+'))) { // we re-check + $this->processed = false; + $this->error = $this->translate('destination_dir_write'); + } else { + @fclose($f); + } + } + } else { + $this->processed = false; + $this->error = $this->translate('destination_path_write'); + } + } else { + if ($this->processed) @fclose($f); + @unlink($this->file_dst_path . $hash . (!empty($this->file_dst_name_ext) ? '.' . $this->file_dst_name_ext : '')); + } + + + // if we have an uploaded file, and if it is the first process, and if we can't access the file directly (open_basedir restriction) + // then we create a temp file that will be used as the source file in subsequent processes + // the third condition is there to check if the file is not accessible *directly* (it already has positively gone through is_uploaded_file(), so it exists) + if (!$this->no_upload_check && empty($this->file_src_temp) && !@file_exists($this->file_src_pathname)) { + $this->log .= '- attempting to use a temp file:'; + $hash = md5($this->file_dst_name_body . rand(1, 1000)); + if (move_uploaded_file($this->file_src_pathname, $this->file_dst_path . $hash . (!empty($this->file_dst_name_ext) ? '.' . $this->file_dst_name_ext : ''))) { + $this->file_src_pathname = $this->file_dst_path . $hash . (!empty($this->file_dst_name_ext) ? '.' . $this->file_dst_name_ext : ''); + $this->file_src_temp = $this->file_src_pathname; + $this->log .= ' file created
'; + $this->log .= '    temp file is: ' . $this->file_src_temp . '
'; + } else { + $this->log .= ' failed
'; + $this->processed = false; + $this->error = $this->translate('temp_file'); + } + } + } + } + + if ($this->processed) { + + // check if we need to autorotate, to automatically pre-rotates the image according to EXIF data (JPEG only) + $auto_flip = false; + $auto_rotate = 0; + if ($this->file_is_image && $this->image_auto_rotate && $this->image_src_type == 'jpg' && $this->function_enabled('exif_read_data')) { + $exif = @exif_read_data($this->file_src_pathname); + if (is_array($exif) && isset($exif['Orientation'])) { + $orientation = $exif['Orientation']; + switch($orientation) { + case 1: + $this->log .= '- EXIF orientation = 1 : default
'; + break; + case 2: + $auto_flip = 'v'; + $this->log .= '- EXIF orientation = 2 : vertical flip
'; + break; + case 3: + $auto_rotate = 180; + $this->log .= '- EXIF orientation = 3 : 180 rotate left
'; + break; + case 4: + $auto_flip = 'h'; + $this->log .= '- EXIF orientation = 4 : horizontal flip
'; + break; + case 5: + $auto_flip = 'h'; + $auto_rotate = 90; + $this->log .= '- EXIF orientation = 5 : horizontal flip + 90 rotate right
'; + break; + case 6: + $auto_rotate = 90; + $this->log .= '- EXIF orientation = 6 : 90 rotate right
'; + break; + case 7: + $auto_flip = 'v'; + $auto_rotate = 90; + $this->log .= '- EXIF orientation = 7 : vertical flip + 90 rotate right
'; + break; + case 8: + $auto_rotate = 270; + $this->log .= '- EXIF orientation = 8 : 90 rotate left
'; + break; + default: + $this->log .= '- EXIF orientation = '.$orientation.' : unknown
'; + break; + } + } else { + $this->log .= '- EXIF data is invalid or missing
'; + } + } else { + if (!$this->image_auto_rotate) { + $this->log .= '- auto-rotate deactivated
'; + } else if (!$this->image_src_type == 'jpg') { + $this->log .= '- auto-rotate applies only to JPEG images
'; + } else if (!$this->function_enabled('exif_read_data')) { + $this->log .= '- auto-rotate requires function exif_read_data to be enabled
'; + } + } + + // do we do some image manipulation? + $image_manipulation = ($this->file_is_image && ( + $this->image_resize + || $this->image_convert != '' + || is_numeric($this->image_brightness) + || is_numeric($this->image_contrast) + || is_numeric($this->image_opacity) + || is_numeric($this->image_threshold) + || !empty($this->image_tint_color) + || !empty($this->image_overlay_color) + || $this->image_pixelate + || $this->image_unsharp + || !empty($this->image_text) + || $this->image_greyscale + || $this->image_negative + || !empty($this->image_watermark) + || $auto_rotate || $auto_flip + || is_numeric($this->image_rotate) + || is_numeric($this->jpeg_size) + || !empty($this->image_flip) + || !empty($this->image_crop) + || !empty($this->image_precrop) + || !empty($this->image_border) + || !empty($this->image_border_transparent) + || $this->image_frame > 0 + || $this->image_bevel > 0 + || $this->image_reflection_height)); + + // we do a quick check to ensure the file is really an image + // we can do this only now, as it would have failed before in case of open_basedir + if ($image_manipulation && !@getimagesize($this->file_src_pathname)) { + $this->log .= '- the file is not an image!
'; + $image_manipulation = false; + } + + if ($image_manipulation) { + + // make sure GD doesn't complain too much + @ini_set("gd.jpeg_ignore_warning", 1); + + // checks if the source file is readable + if ($this->processed && !($f = @fopen($this->file_src_pathname, 'r'))) { + $this->processed = false; + $this->error = $this->translate('source_not_readable'); + } else { + @fclose($f); + } + + // we now do all the image manipulations + $this->log .= '- image resizing or conversion wanted
'; + if ($this->gdversion()) { + switch($this->image_src_type) { + case 'jpg': + if (!$this->function_enabled('imagecreatefromjpeg')) { + $this->processed = false; + $this->error = $this->translate('no_create_support', array('JPEG')); + } else { + $image_src = @imagecreatefromjpeg($this->file_src_pathname); + if (!$image_src) { + $this->processed = false; + $this->error = $this->translate('create_error', array('JPEG')); + } else { + $this->log .= '- source image is JPEG
'; + } + } + break; + case 'png': + if (!$this->function_enabled('imagecreatefrompng')) { + $this->processed = false; + $this->error = $this->translate('no_create_support', array('PNG')); + } else { + $image_src = @imagecreatefrompng($this->file_src_pathname); + if (!$image_src) { + $this->processed = false; + $this->error = $this->translate('create_error', array('PNG')); + } else { + $this->log .= '- source image is PNG
'; + } + } + break; + case 'webp': + if (!$this->function_enabled('imagecreatefromwebp')) { + $this->processed = false; + $this->error = $this->translate('no_create_support', array('WEBP')); + } else { + $image_src = @imagecreatefromwebp($this->file_src_pathname); + if (!$image_src) { + $this->processed = false; + $this->error = $this->translate('create_error', array('WEBP')); + } else { + $this->log .= '- source image is WEBP
'; + } + } + break; + case 'gif': + if (!$this->function_enabled('imagecreatefromgif')) { + $this->processed = false; + $this->error = $this->translate('no_create_support', array('GIF')); + } else { + $image_src = @imagecreatefromgif($this->file_src_pathname); + if (!$image_src) { + $this->processed = false; + $this->error = $this->translate('create_error', array('GIF')); + } else { + $this->log .= '- source image is GIF
'; + } + } + break; + case 'bmp': + if (!method_exists($this, 'imagecreatefrombmp')) { + $this->processed = false; + $this->error = $this->translate('no_create_support', array('BMP')); + } else { + $image_src = @$this->imagecreatefrombmp($this->file_src_pathname); + if (!$image_src) { + $this->processed = false; + $this->error = $this->translate('create_error', array('BMP')); + } else { + $this->log .= '- source image is BMP
'; + } + } + break; + default: + $this->processed = false; + $this->error = $this->translate('source_invalid'); + } + } else { + $this->processed = false; + $this->error = $this->translate('gd_missing'); + } + + if ($this->processed && $image_src) { + + // we have to set image_convert if it is not already + if (empty($this->image_convert)) { + $this->log .= '- setting destination file type to ' . $this->image_src_type . '
'; + $this->image_convert = $this->image_src_type; + } + + if (!in_array($this->image_convert, $this->image_supported)) { + $this->image_convert = 'jpg'; + } + + // we set the default color to be the background color if we don't output in a transparent format + if ($this->image_convert != 'png' && $this->image_convert != 'webp' && $this->image_convert != 'gif' && !empty($this->image_default_color) && empty($this->image_background_color)) $this->image_background_color = $this->image_default_color; + if (!empty($this->image_background_color)) $this->image_default_color = $this->image_background_color; + if (empty($this->image_default_color)) $this->image_default_color = '#FFFFFF'; + + $this->image_src_x = imagesx($image_src); + $this->image_src_y = imagesy($image_src); + $gd_version = $this->gdversion(); + $ratio_crop = null; + + if (!imageistruecolor($image_src)) { // $this->image_src_type == 'gif' + $this->log .= '- image is detected as having a palette
'; + $this->image_is_palette = true; + $this->image_transparent_color = imagecolortransparent($image_src); + if ($this->image_transparent_color >= 0 && imagecolorstotal($image_src) > $this->image_transparent_color) { + $this->image_is_transparent = true; + $this->log .= '    palette image is detected as transparent
'; + } + // if the image has a palette (GIF), we convert it to true color, preserving transparency + $this->log .= '    convert palette image to true color
'; + $true_color = imagecreatetruecolor($this->image_src_x, $this->image_src_y); + imagealphablending($true_color, false); + imagesavealpha($true_color, true); + for ($x = 0; $x < $this->image_src_x; $x++) { + for ($y = 0; $y < $this->image_src_y; $y++) { + if ($this->image_transparent_color >= 0 && imagecolorat($image_src, $x, $y) == $this->image_transparent_color) { + imagesetpixel($true_color, $x, $y, 127 << 24); + } else { + $rgb = imagecolorsforindex($image_src, imagecolorat($image_src, $x, $y)); + imagesetpixel($true_color, $x, $y, ($rgb['alpha'] << 24) | ($rgb['red'] << 16) | ($rgb['green'] << 8) | $rgb['blue']); + } + } + } + $image_src = $this->imagetransfer($true_color, $image_src); + imagealphablending($image_src, false); + imagesavealpha($image_src, true); + $this->image_is_palette = false; + } + + $image_dst = & $image_src; + + // auto-flip image, according to EXIF data (JPEG only) + if ($gd_version >= 2 && !empty($auto_flip)) { + $this->log .= '- auto-flip image : ' . ($auto_flip == 'v' ? 'vertical' : 'horizontal') . '
'; + $tmp = $this->imagecreatenew($this->image_src_x, $this->image_src_y); + for ($x = 0; $x < $this->image_src_x; $x++) { + for ($y = 0; $y < $this->image_src_y; $y++){ + if (strpos($auto_flip, 'v') !== false) { + imagecopy($tmp, $image_dst, $this->image_src_x - $x - 1, $y, $x, $y, 1, 1); + } else { + imagecopy($tmp, $image_dst, $x, $this->image_src_y - $y - 1, $x, $y, 1, 1); + } + } + } + // we transfert tmp into image_dst + $image_dst = $this->imagetransfer($tmp, $image_dst); + } + + // auto-rotate image, according to EXIF data (JPEG only) + if ($gd_version >= 2 && is_numeric($auto_rotate)) { + if (!in_array($auto_rotate, array(0, 90, 180, 270))) $auto_rotate = 0; + if ($auto_rotate != 0) { + if ($auto_rotate == 90 || $auto_rotate == 270) { + $tmp = $this->imagecreatenew($this->image_src_y, $this->image_src_x); + } else { + $tmp = $this->imagecreatenew($this->image_src_x, $this->image_src_y); + } + $this->log .= '- auto-rotate image : ' . $auto_rotate . '
'; + for ($x = 0; $x < $this->image_src_x; $x++) { + for ($y = 0; $y < $this->image_src_y; $y++){ + if ($auto_rotate == 90) { + imagecopy($tmp, $image_dst, $y, $x, $x, $this->image_src_y - $y - 1, 1, 1); + } else if ($auto_rotate == 180) { + imagecopy($tmp, $image_dst, $x, $y, $this->image_src_x - $x - 1, $this->image_src_y - $y - 1, 1, 1); + } else if ($auto_rotate == 270) { + imagecopy($tmp, $image_dst, $y, $x, $this->image_src_x - $x - 1, $y, 1, 1); + } else { + imagecopy($tmp, $image_dst, $x, $y, $x, $y, 1, 1); + } + } + } + if ($auto_rotate == 90 || $auto_rotate == 270) { + $t = $this->image_src_y; + $this->image_src_y = $this->image_src_x; + $this->image_src_x = $t; + } + // we transfert tmp into image_dst + $image_dst = $this->imagetransfer($tmp, $image_dst); + } + } + + // pre-crop image, before resizing + if ((!empty($this->image_precrop))) { + list($ct, $cr, $cb, $cl) = $this->getoffsets($this->image_precrop, $this->image_src_x, $this->image_src_y, true, true); + $this->log .= '- pre-crop image : ' . $ct . ' ' . $cr . ' ' . $cb . ' ' . $cl . '
'; + $this->image_src_x = $this->image_src_x - $cl - $cr; + $this->image_src_y = $this->image_src_y - $ct - $cb; + if ($this->image_src_x < 1) $this->image_src_x = 1; + if ($this->image_src_y < 1) $this->image_src_y = 1; + $tmp = $this->imagecreatenew($this->image_src_x, $this->image_src_y); + + // we copy the image into the recieving image + imagecopy($tmp, $image_dst, 0, 0, $cl, $ct, $this->image_src_x, $this->image_src_y); + + // if we crop with negative margins, we have to make sure the extra bits are the right color, or transparent + if ($ct < 0 || $cr < 0 || $cb < 0 || $cl < 0 ) { + // use the background color if present + if (!empty($this->image_background_color)) { + list($red, $green, $blue) = $this->getcolors($this->image_background_color); + $fill = imagecolorallocate($tmp, $red, $green, $blue); + } else { + $fill = imagecolorallocatealpha($tmp, 0, 0, 0, 127); + } + // fills eventual negative margins + if ($ct < 0) imagefilledrectangle($tmp, 0, 0, $this->image_src_x, -$ct, $fill); + if ($cr < 0) imagefilledrectangle($tmp, $this->image_src_x + $cr, 0, $this->image_src_x, $this->image_src_y, $fill); + if ($cb < 0) imagefilledrectangle($tmp, 0, $this->image_src_y + $cb, $this->image_src_x, $this->image_src_y, $fill); + if ($cl < 0) imagefilledrectangle($tmp, 0, 0, -$cl, $this->image_src_y, $fill); + } + + // we transfert tmp into image_dst + $image_dst = $this->imagetransfer($tmp, $image_dst); + } + + // resize image (and move image_src_x, image_src_y dimensions into image_dst_x, image_dst_y) + if ($this->image_resize) { + $this->log .= '- resizing...
'; + $this->image_dst_x = $this->image_x; + $this->image_dst_y = $this->image_y; + + // backward compatibility for soon to be deprecated settings + if ($this->image_ratio_no_zoom_in) { + $this->image_ratio = true; + $this->image_no_enlarging = true; + } else if ($this->image_ratio_no_zoom_out) { + $this->image_ratio = true; + $this->image_no_shrinking = true; + } + + // keeps aspect ratio with x calculated from y + if ($this->image_ratio_x) { + $this->log .= '    calculate x size
'; + $this->image_dst_x = round(($this->image_src_x * $this->image_y) / $this->image_src_y); + $this->image_dst_y = $this->image_y; + + // keeps aspect ratio with y calculated from x + } else if ($this->image_ratio_y) { + $this->log .= '    calculate y size
'; + $this->image_dst_x = $this->image_x; + $this->image_dst_y = round(($this->image_src_y * $this->image_x) / $this->image_src_x); + + // keeps aspect ratio, calculating x and y so that the image is approx the set number of pixels + } else if (is_numeric($this->image_ratio_pixels)) { + $this->log .= '    calculate x/y size to match a number of pixels
'; + $pixels = $this->image_src_y * $this->image_src_x; + $diff = sqrt($this->image_ratio_pixels / $pixels); + $this->image_dst_x = round($this->image_src_x * $diff); + $this->image_dst_y = round($this->image_src_y * $diff); + + // keeps aspect ratio with x and y dimensions, filling the space + } else if ($this->image_ratio_crop) { + if (!is_string($this->image_ratio_crop)) $this->image_ratio_crop = ''; + $this->image_ratio_crop = strtolower($this->image_ratio_crop); + if (($this->image_src_x/$this->image_x) > ($this->image_src_y/$this->image_y)) { + $this->image_dst_y = $this->image_y; + $this->image_dst_x = intval($this->image_src_x*($this->image_y / $this->image_src_y)); + $ratio_crop = array(); + $ratio_crop['x'] = $this->image_dst_x - $this->image_x; + if (strpos($this->image_ratio_crop, 'l') !== false) { + $ratio_crop['l'] = 0; + $ratio_crop['r'] = $ratio_crop['x']; + } else if (strpos($this->image_ratio_crop, 'r') !== false) { + $ratio_crop['l'] = $ratio_crop['x']; + $ratio_crop['r'] = 0; + } else { + $ratio_crop['l'] = round($ratio_crop['x']/2); + $ratio_crop['r'] = $ratio_crop['x'] - $ratio_crop['l']; + } + $this->log .= '    ratio_crop_x : ' . $ratio_crop['x'] . ' (' . $ratio_crop['l'] . ';' . $ratio_crop['r'] . ')
'; + if (is_null($this->image_crop)) $this->image_crop = array(0, 0, 0, 0); + } else { + $this->image_dst_x = $this->image_x; + $this->image_dst_y = intval($this->image_src_y*($this->image_x / $this->image_src_x)); + $ratio_crop = array(); + $ratio_crop['y'] = $this->image_dst_y - $this->image_y; + if (strpos($this->image_ratio_crop, 't') !== false) { + $ratio_crop['t'] = 0; + $ratio_crop['b'] = $ratio_crop['y']; + } else if (strpos($this->image_ratio_crop, 'b') !== false) { + $ratio_crop['t'] = $ratio_crop['y']; + $ratio_crop['b'] = 0; + } else { + $ratio_crop['t'] = round($ratio_crop['y']/2); + $ratio_crop['b'] = $ratio_crop['y'] - $ratio_crop['t']; + } + $this->log .= '    ratio_crop_y : ' . $ratio_crop['y'] . ' (' . $ratio_crop['t'] . ';' . $ratio_crop['b'] . ')
'; + if (is_null($this->image_crop)) $this->image_crop = array(0, 0, 0, 0); + } + + // keeps aspect ratio with x and y dimensions, fitting the image in the space, and coloring the rest + } else if ($this->image_ratio_fill) { + if (!is_string($this->image_ratio_fill)) $this->image_ratio_fill = ''; + $this->image_ratio_fill = strtolower($this->image_ratio_fill); + if (($this->image_src_x/$this->image_x) < ($this->image_src_y/$this->image_y)) { + $this->image_dst_y = $this->image_y; + $this->image_dst_x = intval($this->image_src_x*($this->image_y / $this->image_src_y)); + $ratio_crop = array(); + $ratio_crop['x'] = $this->image_dst_x - $this->image_x; + if (strpos($this->image_ratio_fill, 'l') !== false) { + $ratio_crop['l'] = 0; + $ratio_crop['r'] = $ratio_crop['x']; + } else if (strpos($this->image_ratio_fill, 'r') !== false) { + $ratio_crop['l'] = $ratio_crop['x']; + $ratio_crop['r'] = 0; + } else { + $ratio_crop['l'] = round($ratio_crop['x']/2); + $ratio_crop['r'] = $ratio_crop['x'] - $ratio_crop['l']; + } + $this->log .= '    ratio_fill_x : ' . $ratio_crop['x'] . ' (' . $ratio_crop['l'] . ';' . $ratio_crop['r'] . ')
'; + if (is_null($this->image_crop)) $this->image_crop = array(0, 0, 0, 0); + } else { + $this->image_dst_x = $this->image_x; + $this->image_dst_y = intval($this->image_src_y*($this->image_x / $this->image_src_x)); + $ratio_crop = array(); + $ratio_crop['y'] = $this->image_dst_y - $this->image_y; + if (strpos($this->image_ratio_fill, 't') !== false) { + $ratio_crop['t'] = 0; + $ratio_crop['b'] = $ratio_crop['y']; + } else if (strpos($this->image_ratio_fill, 'b') !== false) { + $ratio_crop['t'] = $ratio_crop['y']; + $ratio_crop['b'] = 0; + } else { + $ratio_crop['t'] = round($ratio_crop['y']/2); + $ratio_crop['b'] = $ratio_crop['y'] - $ratio_crop['t']; + } + $this->log .= '    ratio_fill_y : ' . $ratio_crop['y'] . ' (' . $ratio_crop['t'] . ';' . $ratio_crop['b'] . ')
'; + if (is_null($this->image_crop)) $this->image_crop = array(0, 0, 0, 0); + } + + // keeps aspect ratio with x and y dimensions + } else if ($this->image_ratio) { + if (($this->image_src_x/$this->image_x) > ($this->image_src_y/$this->image_y)) { + $this->image_dst_x = $this->image_x; + $this->image_dst_y = intval($this->image_src_y*($this->image_x / $this->image_src_x)); + } else { + $this->image_dst_y = $this->image_y; + $this->image_dst_x = intval($this->image_src_x*($this->image_y / $this->image_src_y)); + } + + // resize to provided exact dimensions + } else { + $this->log .= '    use plain sizes
'; + $this->image_dst_x = $this->image_x; + $this->image_dst_y = $this->image_y; + } + + if ($this->image_dst_x < 1) $this->image_dst_x = 1; + if ($this->image_dst_y < 1) $this->image_dst_y = 1; + $this->log .= '    image_src_x y : ' . $this->image_src_x . ' x ' . $this->image_src_y . '
'; + $this->log .= '    image_dst_x y : ' . $this->image_dst_x . ' x ' . $this->image_dst_y . '
'; + + // make sure we don't enlarge the image if we don't want to + if ($this->image_no_enlarging && ($this->image_src_x < $this->image_dst_x || $this->image_src_y < $this->image_dst_y)) { + $this->log .= '    cancel resizing, as it would enlarge the image!
'; + $this->image_dst_x = $this->image_src_x; + $this->image_dst_y = $this->image_src_y; + $ratio_crop = null; + } + + // make sure we don't shrink the image if we don't want to + if ($this->image_no_shrinking && ($this->image_src_x > $this->image_dst_x || $this->image_src_y > $this->image_dst_y)) { + $this->log .= '    cancel resizing, as it would shrink the image!
'; + $this->image_dst_x = $this->image_src_x; + $this->image_dst_y = $this->image_src_y; + $ratio_crop = null; + } + + // resize the image + if ($this->image_dst_x != $this->image_src_x || $this->image_dst_y != $this->image_src_y) { + $tmp = $this->imagecreatenew($this->image_dst_x, $this->image_dst_y); + + if ($gd_version >= 2) { + $res = imagecopyresampled($tmp, $image_src, 0, 0, 0, 0, $this->image_dst_x, $this->image_dst_y, $this->image_src_x, $this->image_src_y); + } else { + $res = imagecopyresized($tmp, $image_src, 0, 0, 0, 0, $this->image_dst_x, $this->image_dst_y, $this->image_src_x, $this->image_src_y); + } + + $this->log .= '    resized image object created
'; + // we transfert tmp into image_dst + $image_dst = $this->imagetransfer($tmp, $image_dst); + } + + } else { + $this->image_dst_x = $this->image_src_x; + $this->image_dst_y = $this->image_src_y; + } + + // crop image (and also crops if image_ratio_crop is used) + if ((!empty($this->image_crop) || !is_null($ratio_crop))) { + list($ct, $cr, $cb, $cl) = $this->getoffsets($this->image_crop, $this->image_dst_x, $this->image_dst_y, true, true); + // we adjust the cropping if we use image_ratio_crop + if (!is_null($ratio_crop)) { + if (array_key_exists('t', $ratio_crop)) $ct += $ratio_crop['t']; + if (array_key_exists('r', $ratio_crop)) $cr += $ratio_crop['r']; + if (array_key_exists('b', $ratio_crop)) $cb += $ratio_crop['b']; + if (array_key_exists('l', $ratio_crop)) $cl += $ratio_crop['l']; + } + if ($ct != 0 || $cr != 0 || $cb != 0 || $cl != 0) { + $this->log .= '- crop image : ' . $ct . ' ' . $cr . ' ' . $cb . ' ' . $cl . '
'; + $this->image_dst_x = $this->image_dst_x - $cl - $cr; + $this->image_dst_y = $this->image_dst_y - $ct - $cb; + if ($this->image_dst_x < 1) $this->image_dst_x = 1; + if ($this->image_dst_y < 1) $this->image_dst_y = 1; + $tmp = $this->imagecreatenew($this->image_dst_x, $this->image_dst_y); + + // we copy the image into the recieving image + imagecopy($tmp, $image_dst, 0, 0, $cl, $ct, $this->image_dst_x, $this->image_dst_y); + + // if we crop with negative margins, we have to make sure the extra bits are the right color, or transparent + if ($ct < 0 || $cr < 0 || $cb < 0 || $cl < 0 ) { + // use the background color if present + if (!empty($this->image_background_color)) { + list($red, $green, $blue) = $this->getcolors($this->image_background_color); + $fill = imagecolorallocate($tmp, $red, $green, $blue); + } else { + $fill = imagecolorallocatealpha($tmp, 0, 0, 0, 127); + } + // fills eventual negative margins + if ($ct < 0) imagefilledrectangle($tmp, 0, 0, $this->image_dst_x, -$ct-1, $fill); + if ($cr < 0) imagefilledrectangle($tmp, $this->image_dst_x + $cr, 0, $this->image_dst_x, $this->image_dst_y, $fill); + if ($cb < 0) imagefilledrectangle($tmp, 0, $this->image_dst_y + $cb, $this->image_dst_x, $this->image_dst_y, $fill); + if ($cl < 0) imagefilledrectangle($tmp, 0, 0, -$cl-1, $this->image_dst_y, $fill); + } + + // we transfert tmp into image_dst + $image_dst = $this->imagetransfer($tmp, $image_dst); + } + } + + // flip image + if ($gd_version >= 2 && !empty($this->image_flip)) { + $this->image_flip = strtolower($this->image_flip); + $this->log .= '- flip image : ' . $this->image_flip . '
'; + $tmp = $this->imagecreatenew($this->image_dst_x, $this->image_dst_y); + for ($x = 0; $x < $this->image_dst_x; $x++) { + for ($y = 0; $y < $this->image_dst_y; $y++){ + if (strpos($this->image_flip, 'v') !== false) { + imagecopy($tmp, $image_dst, $this->image_dst_x - $x - 1, $y, $x, $y, 1, 1); + } else { + imagecopy($tmp, $image_dst, $x, $this->image_dst_y - $y - 1, $x, $y, 1, 1); + } + } + } + // we transfert tmp into image_dst + $image_dst = $this->imagetransfer($tmp, $image_dst); + } + + // rotate image + if ($gd_version >= 2 && is_numeric($this->image_rotate)) { + if (!in_array($this->image_rotate, array(0, 90, 180, 270))) $this->image_rotate = 0; + if ($this->image_rotate != 0) { + if ($this->image_rotate == 90 || $this->image_rotate == 270) { + $tmp = $this->imagecreatenew($this->image_dst_y, $this->image_dst_x); + } else { + $tmp = $this->imagecreatenew($this->image_dst_x, $this->image_dst_y); + } + $this->log .= '- rotate image : ' . $this->image_rotate . '
'; + for ($x = 0; $x < $this->image_dst_x; $x++) { + for ($y = 0; $y < $this->image_dst_y; $y++){ + if ($this->image_rotate == 90) { + imagecopy($tmp, $image_dst, $y, $x, $x, $this->image_dst_y - $y - 1, 1, 1); + } else if ($this->image_rotate == 180) { + imagecopy($tmp, $image_dst, $x, $y, $this->image_dst_x - $x - 1, $this->image_dst_y - $y - 1, 1, 1); + } else if ($this->image_rotate == 270) { + imagecopy($tmp, $image_dst, $y, $x, $this->image_dst_x - $x - 1, $y, 1, 1); + } else { + imagecopy($tmp, $image_dst, $x, $y, $x, $y, 1, 1); + } + } + } + if ($this->image_rotate == 90 || $this->image_rotate == 270) { + $t = $this->image_dst_y; + $this->image_dst_y = $this->image_dst_x; + $this->image_dst_x = $t; + } + // we transfert tmp into image_dst + $image_dst = $this->imagetransfer($tmp, $image_dst); + } + } + + // pixelate image + if ((is_numeric($this->image_pixelate) && $this->image_pixelate > 0)) { + $this->log .= '- pixelate image (' . $this->image_pixelate . 'px)
'; + $filter = $this->imagecreatenew($this->image_dst_x, $this->image_dst_y); + if ($gd_version >= 2) { + imagecopyresampled($filter, $image_dst, 0, 0, 0, 0, round($this->image_dst_x / $this->image_pixelate), round($this->image_dst_y / $this->image_pixelate), $this->image_dst_x, $this->image_dst_y); + imagecopyresampled($image_dst, $filter, 0, 0, 0, 0, $this->image_dst_x, $this->image_dst_y, round($this->image_dst_x / $this->image_pixelate), round($this->image_dst_y / $this->image_pixelate)); + } else { + imagecopyresized($filter, $image_dst, 0, 0, 0, 0, round($this->image_dst_x / $this->image_pixelate), round($this->image_dst_y / $this->image_pixelate), $this->image_dst_x, $this->image_dst_y); + imagecopyresized($image_dst, $filter, 0, 0, 0, 0, $this->image_dst_x, $this->image_dst_y, round($this->image_dst_x / $this->image_pixelate), round($this->image_dst_y / $this->image_pixelate)); + } + $this->imageunset($filter); + } + + // unsharp mask + if ($gd_version >= 2 && $this->image_unsharp && is_numeric($this->image_unsharp_amount) && is_numeric($this->image_unsharp_radius) && is_numeric($this->image_unsharp_threshold)) { + // Unsharp Mask for PHP - version 2.1.1 + // Unsharp mask algorithm by Torstein Hønsi 2003-07. + // Used with permission + // Modified to support alpha transparency + if ($this->image_unsharp_amount > 500) $this->image_unsharp_amount = 500; + $this->image_unsharp_amount = $this->image_unsharp_amount * 0.016; + if ($this->image_unsharp_radius > 50) $this->image_unsharp_radius = 50; + $this->image_unsharp_radius = $this->image_unsharp_radius * 2; + if ($this->image_unsharp_threshold > 255) $this->image_unsharp_threshold = 255; + $this->image_unsharp_radius = abs(round($this->image_unsharp_radius)); + if ($this->image_unsharp_radius != 0) { + $this->image_dst_x = imagesx($image_dst); $this->image_dst_y = imagesy($image_dst); + $canvas = $this->imagecreatenew($this->image_dst_x, $this->image_dst_y, false, true); + $blur = $this->imagecreatenew($this->image_dst_x, $this->image_dst_y, false, true); + if ($this->function_enabled('imageconvolution')) { // PHP >= 5.1 + $matrix = array(array( 1, 2, 1 ), array( 2, 4, 2 ), array( 1, 2, 1 )); + imagecopy($blur, $image_dst, 0, 0, 0, 0, $this->image_dst_x, $this->image_dst_y); + imageconvolution($blur, $matrix, 16, 0); + } else { + for ($i = 0; $i < $this->image_unsharp_radius; $i++) { + imagecopy($blur, $image_dst, 0, 0, 1, 0, $this->image_dst_x - 1, $this->image_dst_y); // left + $this->imagecopymergealpha($blur, $image_dst, 1, 0, 0, 0, $this->image_dst_x, $this->image_dst_y, 50); // right + $this->imagecopymergealpha($blur, $image_dst, 0, 0, 0, 0, $this->image_dst_x, $this->image_dst_y, 50); // center + imagecopy($canvas, $blur, 0, 0, 0, 0, $this->image_dst_x, $this->image_dst_y); + $this->imagecopymergealpha($blur, $canvas, 0, 0, 0, 1, $this->image_dst_x, $this->image_dst_y - 1, 33.33333 ); // up + $this->imagecopymergealpha($blur, $canvas, 0, 1, 0, 0, $this->image_dst_x, $this->image_dst_y, 25); // down + } + } + $p_new = array(); + if($this->image_unsharp_threshold>0) { + for ($x = 0; $x < $this->image_dst_x-1; $x++) { + for ($y = 0; $y < $this->image_dst_y; $y++) { + $p_orig = imagecolorsforindex($image_dst, imagecolorat($image_dst, $x, $y)); + $p_blur = imagecolorsforindex($blur, imagecolorat($blur, $x, $y)); + $p_new['red'] = (abs($p_orig['red'] - $p_blur['red']) >= $this->image_unsharp_threshold) ? max(0, min(255, ($this->image_unsharp_amount * ($p_orig['red'] - $p_blur['red'])) + $p_orig['red'])) : $p_orig['red']; + $p_new['green'] = (abs($p_orig['green'] - $p_blur['green']) >= $this->image_unsharp_threshold) ? max(0, min(255, ($this->image_unsharp_amount * ($p_orig['green'] - $p_blur['green'])) + $p_orig['green'])) : $p_orig['green']; + $p_new['blue'] = (abs($p_orig['blue'] - $p_blur['blue']) >= $this->image_unsharp_threshold) ? max(0, min(255, ($this->image_unsharp_amount * ($p_orig['blue'] - $p_blur['blue'])) + $p_orig['blue'])) : $p_orig['blue']; + if (($p_orig['red'] != $p_new['red']) || ($p_orig['green'] != $p_new['green']) || ($p_orig['blue'] != $p_new['blue'])) { + $color = imagecolorallocatealpha($image_dst, $p_new['red'], $p_new['green'], $p_new['blue'], $p_orig['alpha']); + imagesetpixel($image_dst, $x, $y, $color); + } + } + } + } else { + for ($x = 0; $x < $this->image_dst_x; $x++) { + for ($y = 0; $y < $this->image_dst_y; $y++) { + $p_orig = imagecolorsforindex($image_dst, imagecolorat($image_dst, $x, $y)); + $p_blur = imagecolorsforindex($blur, imagecolorat($blur, $x, $y)); + $p_new['red'] = ($this->image_unsharp_amount * ($p_orig['red'] - $p_blur['red'])) + $p_orig['red']; + if ($p_new['red']>255) { $p_new['red']=255; } elseif ($p_new['red']<0) { $p_new['red']=0; } + $p_new['green'] = ($this->image_unsharp_amount * ($p_orig['green'] - $p_blur['green'])) + $p_orig['green']; + if ($p_new['green']>255) { $p_new['green']=255; } elseif ($p_new['green']<0) { $p_new['green']=0; } + $p_new['blue'] = ($this->image_unsharp_amount * ($p_orig['blue'] - $p_blur['blue'])) + $p_orig['blue']; + if ($p_new['blue']>255) { $p_new['blue']=255; } elseif ($p_new['blue']<0) { $p_new['blue']=0; } + $color = imagecolorallocatealpha($image_dst, $p_new['red'], $p_new['green'], $p_new['blue'], $p_orig['alpha']); + imagesetpixel($image_dst, $x, $y, $color); + } + } + } + $this->imageunset($canvas); + $this->imageunset($blur); + } + } + + // add color overlay + if ($gd_version >= 2 && (is_numeric($this->image_overlay_opacity) && $this->image_overlay_opacity > 0 && !empty($this->image_overlay_color))) { + $this->log .= '- apply color overlay
'; + list($red, $green, $blue) = $this->getcolors($this->image_overlay_color); + $filter = imagecreatetruecolor($this->image_dst_x, $this->image_dst_y); + $color = imagecolorallocate($filter, $red, $green, $blue); + imagefilledrectangle($filter, 0, 0, $this->image_dst_x, $this->image_dst_y, $color); + $this->imagecopymergealpha($image_dst, $filter, 0, 0, 0, 0, $this->image_dst_x, $this->image_dst_y, $this->image_overlay_opacity); + $this->imageunset($filter); + } + + // add brightness, contrast and tint, turns to greyscale and inverts colors + if ($gd_version >= 2 && ($this->image_negative || $this->image_greyscale || is_numeric($this->image_threshold)|| is_numeric($this->image_brightness) || is_numeric($this->image_contrast) || !empty($this->image_tint_color))) { + $this->log .= '- apply tint, light, contrast correction, negative, greyscale and threshold
'; + if (!empty($this->image_tint_color)) list($tint_red, $tint_green, $tint_blue) = $this->getcolors($this->image_tint_color); + //imagealphablending($image_dst, true); + for($y=0; $y < $this->image_dst_y; $y++) { + for($x=0; $x < $this->image_dst_x; $x++) { + if ($this->image_greyscale) { + $pixel = imagecolorsforindex($image_dst, imagecolorat($image_dst, $x, $y)); + $r = $g = $b = round((0.2125 * $pixel['red']) + (0.7154 * $pixel['green']) + (0.0721 * $pixel['blue'])); + $color = imagecolorallocatealpha($image_dst, $r, $g, $b, $pixel['alpha']); + imagesetpixel($image_dst, $x, $y, $color); + unset($color); unset($pixel); + } + if (is_numeric($this->image_threshold)) { + $pixel = imagecolorsforindex($image_dst, imagecolorat($image_dst, $x, $y)); + $c = (round($pixel['red'] + $pixel['green'] + $pixel['blue']) / 3) - 127; + $r = $g = $b = ($c > $this->image_threshold ? 255 : 0); + $color = imagecolorallocatealpha($image_dst, $r, $g, $b, $pixel['alpha']); + imagesetpixel($image_dst, $x, $y, $color); + unset($color); unset($pixel); + } + if (is_numeric($this->image_brightness)) { + $pixel = imagecolorsforindex($image_dst, imagecolorat($image_dst, $x, $y)); + $r = max(min(round($pixel['red'] + (($this->image_brightness * 2))), 255), 0); + $g = max(min(round($pixel['green'] + (($this->image_brightness * 2))), 255), 0); + $b = max(min(round($pixel['blue'] + (($this->image_brightness * 2))), 255), 0); + $color = imagecolorallocatealpha($image_dst, $r, $g, $b, $pixel['alpha']); + imagesetpixel($image_dst, $x, $y, $color); + unset($color); unset($pixel); + } + if (is_numeric($this->image_contrast)) { + $pixel = imagecolorsforindex($image_dst, imagecolorat($image_dst, $x, $y)); + $r = max(min(round(($this->image_contrast + 128) * $pixel['red'] / 128), 255), 0); + $g = max(min(round(($this->image_contrast + 128) * $pixel['green'] / 128), 255), 0); + $b = max(min(round(($this->image_contrast + 128) * $pixel['blue'] / 128), 255), 0); + $color = imagecolorallocatealpha($image_dst, $r, $g, $b, $pixel['alpha']); + imagesetpixel($image_dst, $x, $y, $color); + unset($color); unset($pixel); + } + if (!empty($this->image_tint_color)) { + $pixel = imagecolorsforindex($image_dst, imagecolorat($image_dst, $x, $y)); + $r = min(round($tint_red * $pixel['red'] / 169), 255); + $g = min(round($tint_green * $pixel['green'] / 169), 255); + $b = min(round($tint_blue * $pixel['blue'] / 169), 255); + $color = imagecolorallocatealpha($image_dst, $r, $g, $b, $pixel['alpha']); + imagesetpixel($image_dst, $x, $y, $color); + unset($color); unset($pixel); + } + if (!empty($this->image_negative)) { + $pixel = imagecolorsforindex($image_dst, imagecolorat($image_dst, $x, $y)); + $r = round(255 - $pixel['red']); + $g = round(255 - $pixel['green']); + $b = round(255 - $pixel['blue']); + $color = imagecolorallocatealpha($image_dst, $r, $g, $b, $pixel['alpha']); + imagesetpixel($image_dst, $x, $y, $color); + unset($color); unset($pixel); + } + } + } + } + + // adds a border + if ($gd_version >= 2 && !empty($this->image_border)) { + list($ct, $cr, $cb, $cl) = $this->getoffsets($this->image_border, $this->image_dst_x, $this->image_dst_y, true, false); + $this->log .= '- add border : ' . $ct . ' ' . $cr . ' ' . $cb . ' ' . $cl . '
'; + $this->image_dst_x = $this->image_dst_x + $cl + $cr; + $this->image_dst_y = $this->image_dst_y + $ct + $cb; + if (!empty($this->image_border_color)) list($red, $green, $blue) = $this->getcolors($this->image_border_color); + $opacity = (is_numeric($this->image_border_opacity) ? (int) (127 - $this->image_border_opacity / 100 * 127): 0); + // we now create an image, that we fill with the border color + $tmp = $this->imagecreatenew($this->image_dst_x, $this->image_dst_y); + $background = imagecolorallocatealpha($tmp, $red, $green, $blue, $opacity); + imagefilledrectangle($tmp, 0, 0, $this->image_dst_x, $this->image_dst_y, $background); + // we then copy the source image into the new image, without merging so that only the border is actually kept + imagecopy($tmp, $image_dst, $cl, $ct, 0, 0, $this->image_dst_x - $cr - $cl, $this->image_dst_y - $cb - $ct); + // we transfert tmp into image_dst + $image_dst = $this->imagetransfer($tmp, $image_dst); + } + + // adds a fading-to-transparent border + if ($gd_version >= 2 && !empty($this->image_border_transparent)) { + list($ct, $cr, $cb, $cl) = $this->getoffsets($this->image_border_transparent, $this->image_dst_x, $this->image_dst_y, true, false); + $this->log .= '- add transparent border : ' . $ct . ' ' . $cr . ' ' . $cb . ' ' . $cl . '
'; + // we now create an image, that we fill with the border color + $tmp = $this->imagecreatenew($this->image_dst_x, $this->image_dst_y); + // we then copy the source image into the new image, without the borders + imagecopy($tmp, $image_dst, $cl, $ct, $cl, $ct, $this->image_dst_x - $cr - $cl, $this->image_dst_y - $cb - $ct); + // we now add the top border + $opacity = 100; + for ($y = $ct - 1; $y >= 0; $y--) { + $il = (int) ($ct > 0 ? ($cl * ($y / $ct)) : 0); + $ir = (int) ($ct > 0 ? ($cr * ($y / $ct)) : 0); + for ($x = $il; $x < $this->image_dst_x - $ir; $x++) { + $pixel = imagecolorsforindex($image_dst, imagecolorat($image_dst, $x, $y)); + $alpha = (1 - ($pixel['alpha'] / 127)) * $opacity / 100; + if ($alpha > 0) { + if ($alpha > 1) $alpha = 1; + $color = imagecolorallocatealpha($tmp, $pixel['red'] , $pixel['green'], $pixel['blue'], round((1 - $alpha) * 127)); + imagesetpixel($tmp, $x, $y, $color); + } + } + if ($opacity > 0) $opacity = $opacity - (100 / $ct); + } + // we now add the right border + $opacity = 100; + for ($x = $this->image_dst_x - $cr; $x < $this->image_dst_x; $x++) { + $it = (int) ($cr > 0 ? ($ct * (($this->image_dst_x - $x - 1) / $cr)) : 0); + $ib = (int) ($cr > 0 ? ($cb * (($this->image_dst_x - $x - 1) / $cr)) : 0); + for ($y = $it; $y < $this->image_dst_y - $ib; $y++) { + $pixel = imagecolorsforindex($image_dst, imagecolorat($image_dst, $x, $y)); + $alpha = (1 - ($pixel['alpha'] / 127)) * $opacity / 100; + if ($alpha > 0) { + if ($alpha > 1) $alpha = 1; + $color = imagecolorallocatealpha($tmp, $pixel['red'] , $pixel['green'], $pixel['blue'], round((1 - $alpha) * 127)); + imagesetpixel($tmp, $x, $y, $color); + } + } + if ($opacity > 0) $opacity = $opacity - (100 / $cr); + } + // we now add the bottom border + $opacity = 100; + for ($y = $this->image_dst_y - $cb; $y < $this->image_dst_y; $y++) { + $il = (int) ($cb > 0 ? ($cl * (($this->image_dst_y - $y - 1) / $cb)) : 0); + $ir = (int) ($cb > 0 ? ($cr * (($this->image_dst_y - $y - 1) / $cb)) : 0); + for ($x = $il; $x < $this->image_dst_x - $ir; $x++) { + $pixel = imagecolorsforindex($image_dst, imagecolorat($image_dst, $x, $y)); + $alpha = (1 - ($pixel['alpha'] / 127)) * $opacity / 100; + if ($alpha > 0) { + if ($alpha > 1) $alpha = 1; + $color = imagecolorallocatealpha($tmp, $pixel['red'] , $pixel['green'], $pixel['blue'], round((1 - $alpha) * 127)); + imagesetpixel($tmp, $x, $y, $color); + } + } + if ($opacity > 0) $opacity = $opacity - (100 / $cb); + } + // we now add the left border + $opacity = 100; + for ($x = $cl - 1; $x >= 0; $x--) { + $it = (int) ($cl > 0 ? ($ct * ($x / $cl)) : 0); + $ib = (int) ($cl > 0 ? ($cb * ($x / $cl)) : 0); + for ($y = $it; $y < $this->image_dst_y - $ib; $y++) { + $pixel = imagecolorsforindex($image_dst, imagecolorat($image_dst, $x, $y)); + $alpha = (1 - ($pixel['alpha'] / 127)) * $opacity / 100; + if ($alpha > 0) { + if ($alpha > 1) $alpha = 1; + $color = imagecolorallocatealpha($tmp, $pixel['red'] , $pixel['green'], $pixel['blue'], round((1 - $alpha) * 127)); + imagesetpixel($tmp, $x, $y, $color); + } + } + if ($opacity > 0) $opacity = $opacity - (100 / $cl); + } + // we transfert tmp into image_dst + $image_dst = $this->imagetransfer($tmp, $image_dst); + } + + // add frame border + if ($gd_version >= 2 && is_numeric($this->image_frame)) { + if (is_array($this->image_frame_colors)) { + $vars = $this->image_frame_colors; + $this->log .= '- add frame : ' . implode(' ', $this->image_frame_colors) . '
'; + } else { + $this->log .= '- add frame : ' . $this->image_frame_colors . '
'; + $vars = explode(' ', $this->image_frame_colors); + } + $nb = sizeof($vars); + $this->image_dst_x = $this->image_dst_x + ($nb * 2); + $this->image_dst_y = $this->image_dst_y + ($nb * 2); + $tmp = $this->imagecreatenew($this->image_dst_x, $this->image_dst_y); + imagecopy($tmp, $image_dst, $nb, $nb, 0, 0, $this->image_dst_x - ($nb * 2), $this->image_dst_y - ($nb * 2)); + $opacity = (is_numeric($this->image_frame_opacity) ? (int) (127 - $this->image_frame_opacity / 100 * 127): 0); + for ($i=0; $i<$nb; $i++) { + list($red, $green, $blue) = $this->getcolors($vars[$i]); + $c = imagecolorallocatealpha($tmp, $red, $green, $blue, $opacity); + if ($this->image_frame == 1) { + imageline($tmp, $i, $i, $this->image_dst_x - $i -1, $i, $c); + imageline($tmp, $this->image_dst_x - $i -1, $this->image_dst_y - $i -1, $this->image_dst_x - $i -1, $i, $c); + imageline($tmp, $this->image_dst_x - $i -1, $this->image_dst_y - $i -1, $i, $this->image_dst_y - $i -1, $c); + imageline($tmp, $i, $i, $i, $this->image_dst_y - $i -1, $c); + } else { + imageline($tmp, $i, $i, $this->image_dst_x - $i -1, $i, $c); + imageline($tmp, $this->image_dst_x - $nb + $i, $this->image_dst_y - $nb + $i, $this->image_dst_x - $nb + $i, $nb - $i, $c); + imageline($tmp, $this->image_dst_x - $nb + $i, $this->image_dst_y - $nb + $i, $nb - $i, $this->image_dst_y - $nb + $i, $c); + imageline($tmp, $i, $i, $i, $this->image_dst_y - $i -1, $c); + } + } + // we transfert tmp into image_dst + $image_dst = $this->imagetransfer($tmp, $image_dst); + } + + // add bevel border + if ($gd_version >= 2 && $this->image_bevel > 0) { + if (empty($this->image_bevel_color1)) $this->image_bevel_color1 = '#FFFFFF'; + if (empty($this->image_bevel_color2)) $this->image_bevel_color2 = '#000000'; + list($red1, $green1, $blue1) = $this->getcolors($this->image_bevel_color1); + list($red2, $green2, $blue2) = $this->getcolors($this->image_bevel_color2); + $tmp = $this->imagecreatenew($this->image_dst_x, $this->image_dst_y); + imagecopy($tmp, $image_dst, 0, 0, 0, 0, $this->image_dst_x, $this->image_dst_y); + imagealphablending($tmp, true); + for ($i=0; $i<$this->image_bevel; $i++) { + $alpha = round(($i / $this->image_bevel) * 127); + $c1 = imagecolorallocatealpha($tmp, $red1, $green1, $blue1, $alpha); + $c2 = imagecolorallocatealpha($tmp, $red2, $green2, $blue2, $alpha); + imageline($tmp, $i, $i, $this->image_dst_x - $i -1, $i, $c1); + imageline($tmp, $this->image_dst_x - $i -1, $this->image_dst_y - $i, $this->image_dst_x - $i -1, $i, $c2); + imageline($tmp, $this->image_dst_x - $i -1, $this->image_dst_y - $i -1, $i, $this->image_dst_y - $i -1, $c2); + imageline($tmp, $i, $i, $i, $this->image_dst_y - $i -1, $c1); + } + // we transfert tmp into image_dst + $image_dst = $this->imagetransfer($tmp, $image_dst); + } + + // add watermark image + if ($this->image_watermark!='' && file_exists($this->image_watermark)) { + $this->log .= '- add watermark
'; + $this->image_watermark_position = strtolower($this->image_watermark_position); + $watermark_info = getimagesize($this->image_watermark); + $watermark_type = (array_key_exists(2, $watermark_info) ? $watermark_info[2] : null); // 1 = GIF, 2 = JPG, 3 = PNG + $watermark_checked = false; + if ($watermark_type == IMAGETYPE_GIF) { + if (!$this->function_enabled('imagecreatefromgif')) { + $this->error = $this->translate('watermark_no_create_support', array('GIF')); + } else { + $filter = @imagecreatefromgif($this->image_watermark); + if (!$filter) { + $this->error = $this->translate('watermark_create_error', array('GIF')); + } else { + $this->log .= '    watermark source image is GIF
'; + $watermark_checked = true; + } + } + } else if ($watermark_type == IMAGETYPE_JPEG) { + if (!$this->function_enabled('imagecreatefromjpeg')) { + $this->error = $this->translate('watermark_no_create_support', array('JPEG')); + } else { + $filter = @imagecreatefromjpeg($this->image_watermark); + if (!$filter) { + $this->error = $this->translate('watermark_create_error', array('JPEG')); + } else { + $this->log .= '    watermark source image is JPEG
'; + $watermark_checked = true; + } + } + } else if ($watermark_type == IMAGETYPE_PNG) { + if (!$this->function_enabled('imagecreatefrompng')) { + $this->error = $this->translate('watermark_no_create_support', array('PNG')); + } else { + $filter = @imagecreatefrompng($this->image_watermark); + if (!$filter) { + $this->error = $this->translate('watermark_create_error', array('PNG')); + } else { + $this->log .= '    watermark source image is PNG
'; + $watermark_checked = true; + } + } + } else if ($watermark_type == IMAGETYPE_WEBP) { + if (!$this->function_enabled('imagecreatefromwebp')) { + $this->error = $this->translate('watermark_no_create_support', array('WEBP')); + } else { + $filter = @imagecreatefromwebp($this->image_watermark); + if (!$filter) { + $this->error = $this->translate('watermark_create_error', array('WEBP')); + } else { + $this->log .= '    watermark source image is WEBP
'; + $watermark_checked = true; + } + } + } else if ($watermark_type == IMAGETYPE_BMP) { + if (!method_exists($this, 'imagecreatefrombmp')) { + $this->error = $this->translate('watermark_no_create_support', array('BMP')); + } else { + $filter = @$this->imagecreatefrombmp($this->image_watermark); + if (!$filter) { + $this->error = $this->translate('watermark_create_error', array('BMP')); + } else { + $this->log .= '    watermark source image is BMP
'; + $watermark_checked = true; + } + } + } else { + $this->error = $this->translate('watermark_invalid'); + } + if ($watermark_checked) { + $watermark_dst_width = $watermark_src_width = imagesx($filter); + $watermark_dst_height = $watermark_src_height = imagesy($filter); + + // if watermark is too large/tall, resize it first + if ((!$this->image_watermark_no_zoom_out && ($watermark_dst_width > $this->image_dst_x || $watermark_dst_height > $this->image_dst_y)) + || (!$this->image_watermark_no_zoom_in && $watermark_dst_width < $this->image_dst_x && $watermark_dst_height < $this->image_dst_y)) { + $canvas_width = $this->image_dst_x - abs($this->image_watermark_x); + $canvas_height = $this->image_dst_y - abs($this->image_watermark_y); + if (($watermark_src_width/$canvas_width) > ($watermark_src_height/$canvas_height)) { + $watermark_dst_width = $canvas_width; + $watermark_dst_height = intval($watermark_src_height*($canvas_width / $watermark_src_width)); + } else { + $watermark_dst_height = $canvas_height; + $watermark_dst_width = intval($watermark_src_width*($canvas_height / $watermark_src_height)); + } + $this->log .= '    watermark resized from '.$watermark_src_width.'x'.$watermark_src_height.' to '.$watermark_dst_width.'x'.$watermark_dst_height.'
'; + + } + // determine watermark position + $watermark_x = 0; + $watermark_y = 0; + if (is_numeric($this->image_watermark_x)) { + if ($this->image_watermark_x < 0) { + $watermark_x = $this->image_dst_x - $watermark_dst_width + $this->image_watermark_x; + } else { + $watermark_x = $this->image_watermark_x; + } + } else { + if (strpos($this->image_watermark_position, 'r') !== false) { + $watermark_x = $this->image_dst_x - $watermark_dst_width; + } else if (strpos($this->image_watermark_position, 'l') !== false) { + $watermark_x = 0; + } else { + $watermark_x = ($this->image_dst_x - $watermark_dst_width) / 2; + } + } + if (is_numeric($this->image_watermark_y)) { + if ($this->image_watermark_y < 0) { + $watermark_y = $this->image_dst_y - $watermark_dst_height + $this->image_watermark_y; + } else { + $watermark_y = $this->image_watermark_y; + } + } else { + if (strpos($this->image_watermark_position, 'b') !== false) { + $watermark_y = $this->image_dst_y - $watermark_dst_height; + } else if (strpos($this->image_watermark_position, 't') !== false) { + $watermark_y = 0; + } else { + $watermark_y = ($this->image_dst_y - $watermark_dst_height) / 2; + } + } + imagealphablending($image_dst, true); + imagecopyresampled($image_dst, $filter, $watermark_x, $watermark_y, 0, 0, $watermark_dst_width, $watermark_dst_height, $watermark_src_width, $watermark_src_height); + } else { + $this->error = $this->translate('watermark_invalid'); + } + } + + // add text + if (!empty($this->image_text)) { + $this->log .= '- add text
'; + + // calculate sizes in human readable format + $src_size = $this->file_src_size / 1024; + $src_size_mb = number_format($src_size / 1024, 1, ".", " "); + $src_size_kb = number_format($src_size, 1, ".", " "); + $src_size_human = ($src_size > 1024 ? $src_size_mb . " MB" : $src_size_kb . " kb"); + + $this->image_text = str_replace( + array('[src_name]', + '[src_name_body]', + '[src_name_ext]', + '[src_pathname]', + '[src_mime]', + '[src_size]', + '[src_size_kb]', + '[src_size_mb]', + '[src_size_human]', + '[src_x]', + '[src_y]', + '[src_pixels]', + '[src_type]', + '[src_bits]', + '[dst_path]', + '[dst_name_body]', + '[dst_name_ext]', + '[dst_name]', + '[dst_pathname]', + '[dst_x]', + '[dst_y]', + '[date]', + '[time]', + '[host]', + '[server]', + '[ip]', + '[gd_version]'), + array($this->file_src_name, + $this->file_src_name_body, + $this->file_src_name_ext, + $this->file_src_pathname, + $this->file_src_mime, + $this->file_src_size, + $src_size_kb, + $src_size_mb, + $src_size_human, + $this->image_src_x, + $this->image_src_y, + $this->image_src_pixels, + $this->image_src_type, + $this->image_src_bits, + $this->file_dst_path, + $this->file_dst_name_body, + $this->file_dst_name_ext, + $this->file_dst_name, + $this->file_dst_pathname, + $this->image_dst_x, + $this->image_dst_y, + date('Y-m-d'), + date('H:i:s'), + (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'n/a'), + (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'n/a'), + (isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : 'n/a'), + $this->gdversion(true)), + $this->image_text); + + if (!is_numeric($this->image_text_padding)) $this->image_text_padding = 0; + if (!is_numeric($this->image_text_line_spacing)) $this->image_text_line_spacing = 0; + if (!is_numeric($this->image_text_padding_x)) $this->image_text_padding_x = $this->image_text_padding; + if (!is_numeric($this->image_text_padding_y)) $this->image_text_padding_y = $this->image_text_padding; + $this->image_text_position = strtolower($this->image_text_position); + $this->image_text_direction = strtolower($this->image_text_direction); + $this->image_text_alignment = strtolower($this->image_text_alignment); + + $font_type = 'gd'; + + // if the font is a string with a GDF font path, we assume that we might want to load a font + if (!is_numeric($this->image_text_font) && strlen($this->image_text_font) > 4 && substr(strtolower($this->image_text_font), -4) == '.gdf') { + if (strpos($this->image_text_font, '/') === false) $this->image_text_font = "./" . $this->image_text_font; + $this->log .= '    try to load font ' . $this->image_text_font . '... '; + if ($this->image_text_font = @imageloadfont($this->image_text_font)) { + $this->log .= 'success
'; + } else { + $this->log .= 'error
'; + $this->image_text_font = 5; + } + } + + // if the font is a string with a TTF font path, we check if we can access the font file + if (!is_numeric($this->image_text_font) && strlen($this->image_text_font) > 4 && substr(strtolower($this->image_text_font), -4) == '.ttf') { + $this->log .= '    try to load font ' . $this->image_text_font . '... '; + if (strpos($this->image_text_font, '/') === false) $this->image_text_font = "./" . $this->image_text_font; + if (file_exists($this->image_text_font) && is_readable($this->image_text_font)) { + $this->log .= 'success
'; + $font_type = 'tt'; + } else { + $this->log .= 'error
'; + $this->image_text_font = 5; + } + } + + // get the text bounding box (GD fonts) + if ($font_type == 'gd') { + $text = explode("\n", $this->image_text); + $char_width = imagefontwidth($this->image_text_font); + $char_height = imagefontheight($this->image_text_font); + $text_height = 0; + $text_width = 0; + $line_height = 0; + $line_width = 0; + foreach ($text as $k => $v) { + if ($this->image_text_direction == 'v') { + $h = ($char_width * strlen($v)); + if ($h > $text_height) $text_height = $h; + $line_width = $char_height; + $text_width += $line_width + ($k < (sizeof($text)-1) ? $this->image_text_line_spacing : 0); + } else { + $w = ($char_width * strlen($v)); + if ($w > $text_width) $text_width = $w; + $line_height = $char_height; + $text_height += $line_height + ($k < (sizeof($text)-1) ? $this->image_text_line_spacing : 0); + } + } + $text_width += (2 * $this->image_text_padding_x); + $text_height += (2 * $this->image_text_padding_y); + + // get the text bounding box (TrueType fonts) + } else if ($font_type == 'tt') { + $text = $this->image_text; + if (!$this->image_text_angle) $this->image_text_angle = $this->image_text_direction == 'v' ? 90 : 0; + $text_height = 0; + $text_width = 0; + $text_offset_x = 0; + $text_offset_y = 0; + $rect = imagettfbbox($this->image_text_size, $this->image_text_angle, $this->image_text_font, $text ); + if ($rect) { + $minX = min(array($rect[0],$rect[2],$rect[4],$rect[6])); + $maxX = max(array($rect[0],$rect[2],$rect[4],$rect[6])); + $minY = min(array($rect[1],$rect[3],$rect[5],$rect[7])); + $maxY = max(array($rect[1],$rect[3],$rect[5],$rect[7])); + $text_offset_x = abs($minX) - 1; + $text_offset_y = abs($minY) - 1; + $text_width = $maxX - $minX + (2 * $this->image_text_padding_x); + $text_height = $maxY - $minY + (2 * $this->image_text_padding_y); + } + } + + // position the text block + $text_x = 0; + $text_y = 0; + if (is_numeric($this->image_text_x)) { + if ($this->image_text_x < 0) { + $text_x = $this->image_dst_x - $text_width + $this->image_text_x; + } else { + $text_x = $this->image_text_x; + } + } else { + if (strpos($this->image_text_position, 'r') !== false) { + $text_x = $this->image_dst_x - $text_width; + } else if (strpos($this->image_text_position, 'l') !== false) { + $text_x = 0; + } else { + $text_x = ($this->image_dst_x - $text_width) / 2; + } + } + if (is_numeric($this->image_text_y)) { + if ($this->image_text_y < 0) { + $text_y = $this->image_dst_y - $text_height + $this->image_text_y; + } else { + $text_y = $this->image_text_y; + } + } else { + if (strpos($this->image_text_position, 'b') !== false) { + $text_y = $this->image_dst_y - $text_height; + } else if (strpos($this->image_text_position, 't') !== false) { + $text_y = 0; + } else { + $text_y = ($this->image_dst_y - $text_height) / 2; + } + } + + // add a background, maybe transparent + if (!empty($this->image_text_background)) { + list($red, $green, $blue) = $this->getcolors($this->image_text_background); + if ($gd_version >= 2 && (is_numeric($this->image_text_background_opacity)) && $this->image_text_background_opacity >= 0 && $this->image_text_background_opacity <= 100) { + $filter = imagecreatetruecolor($text_width, $text_height); + $background_color = imagecolorallocate($filter, $red, $green, $blue); + imagefilledrectangle($filter, 0, 0, $text_width, $text_height, $background_color); + $this->imagecopymergealpha($image_dst, $filter, $text_x, $text_y, 0, 0, $text_width, $text_height, $this->image_text_background_opacity); + $this->imageunset($filter); + } else { + $background_color = imagecolorallocate($image_dst ,$red, $green, $blue); + imagefilledrectangle($image_dst, $text_x, $text_y, $text_x + $text_width, $text_y + $text_height, $background_color); + } + } + + $text_x += $this->image_text_padding_x; + $text_y += $this->image_text_padding_y; + $t_width = $text_width - (2 * $this->image_text_padding_x); + $t_height = $text_height - (2 * $this->image_text_padding_y); + list($red, $green, $blue) = $this->getcolors($this->image_text_color); + + // add the text, maybe transparent + if ($gd_version >= 2 && (is_numeric($this->image_text_opacity)) && $this->image_text_opacity >= 0 && $this->image_text_opacity <= 100) { + if ($t_width < 0) $t_width = 0; + if ($t_height < 0) $t_height = 0; + $filter = $this->imagecreatenew($t_width, $t_height, false, true); + $text_color = imagecolorallocate($filter ,$red, $green, $blue); + + if ($font_type == 'gd') { + foreach ($text as $k => $v) { + if ($this->image_text_direction == 'v') { + imagestringup($filter, + $this->image_text_font, + $k * ($line_width + ($k > 0 && $k < (sizeof($text)) ? $this->image_text_line_spacing : 0)), + $text_height - (2 * $this->image_text_padding_y) - ($this->image_text_alignment == 'l' ? 0 : (($t_height - strlen($v) * $char_width) / ($this->image_text_alignment == 'r' ? 1 : 2))) , + $v, + $text_color); + } else { + imagestring($filter, + $this->image_text_font, + ($this->image_text_alignment == 'l' ? 0 : (($t_width - strlen($v) * $char_width) / ($this->image_text_alignment == 'r' ? 1 : 2))), + $k * ($line_height + ($k > 0 && $k < (sizeof($text)) ? $this->image_text_line_spacing : 0)), + $v, + $text_color); + } + } + } else if ($font_type == 'tt') { + imagettftext($filter, + $this->image_text_size, + $this->image_text_angle, + $text_offset_x, + $text_offset_y, + $text_color, + $this->image_text_font, + $text); + } + $this->imagecopymergealpha($image_dst, $filter, $text_x, $text_y, 0, 0, $t_width, $t_height, $this->image_text_opacity); + $this->imageunset($filter); + + } else { + $text_color = imagecolorallocate($image_dst ,$red, $green, $blue); + if ($font_type == 'gd') { + foreach ($text as $k => $v) { + if ($this->image_text_direction == 'v') { + imagestringup($image_dst, + $this->image_text_font, + $text_x + $k * ($line_width + ($k > 0 && $k < (sizeof($text)) ? $this->image_text_line_spacing : 0)), + $text_y + $text_height - (2 * $this->image_text_padding_y) - ($this->image_text_alignment == 'l' ? 0 : (($t_height - strlen($v) * $char_width) / ($this->image_text_alignment == 'r' ? 1 : 2))), + $v, + $text_color); + } else { + imagestring($image_dst, + $this->image_text_font, + $text_x + ($this->image_text_alignment == 'l' ? 0 : (($t_width - strlen($v) * $char_width) / ($this->image_text_alignment == 'r' ? 1 : 2))), + $text_y + $k * ($line_height + ($k > 0 && $k < (sizeof($text)) ? $this->image_text_line_spacing : 0)), + $v, + $text_color); + } + } + } else if ($font_type == 'tt') { + imagettftext($image_dst, + $this->image_text_size, + $this->image_text_angle, + $text_offset_x + ($this->image_dst_x / 2) - ($text_width / 2) + $this->image_text_padding_x, + $text_offset_y + ($this->image_dst_y / 2) - ($text_height / 2) + $this->image_text_padding_y, + $text_color, + $this->image_text_font, + $text); + } + } + } + + // add a reflection + if ($this->image_reflection_height) { + $this->log .= '- add reflection : ' . $this->image_reflection_height . '
'; + // we decode image_reflection_height, which can be a integer, a string in pixels or percentage + $image_reflection_height = $this->image_reflection_height; + if (strpos($image_reflection_height, '%')>0) $image_reflection_height = $this->image_dst_y * ((int) str_replace('%','',$image_reflection_height) / 100); + if (strpos($image_reflection_height, 'px')>0) $image_reflection_height = (int) str_replace('px','',$image_reflection_height); + $image_reflection_height = (int) $image_reflection_height; + if ($image_reflection_height > $this->image_dst_y) $image_reflection_height = $this->image_dst_y; + if (empty($this->image_reflection_opacity)) $this->image_reflection_opacity = 60; + // create the new destination image + $tmp = $this->imagecreatenew($this->image_dst_x, $this->image_dst_y + $image_reflection_height + $this->image_reflection_space, true); + $transparency = $this->image_reflection_opacity; + + // copy the original image + imagecopy($tmp, $image_dst, 0, 0, 0, 0, $this->image_dst_x, $this->image_dst_y + ($this->image_reflection_space < 0 ? $this->image_reflection_space : 0)); + + // we have to make sure the extra bit is the right color, or transparent + if ($image_reflection_height + $this->image_reflection_space > 0) { + // use the background color if present + if (!empty($this->image_background_color)) { + list($red, $green, $blue) = $this->getcolors($this->image_background_color); + $fill = imagecolorallocate($tmp, $red, $green, $blue); + } else { + $fill = imagecolorallocatealpha($tmp, 0, 0, 0, 127); + } + // fill in from the edge of the extra bit + imagefill($tmp, round($this->image_dst_x / 2), $this->image_dst_y + $image_reflection_height + $this->image_reflection_space - 1, $fill); + } + + // copy the reflection + for ($y = 0; $y < $image_reflection_height; $y++) { + for ($x = 0; $x < $this->image_dst_x; $x++) { + $pixel_b = imagecolorsforindex($tmp, imagecolorat($tmp, $x, $y + $this->image_dst_y + $this->image_reflection_space)); + $pixel_o = imagecolorsforindex($image_dst, imagecolorat($image_dst, $x, $this->image_dst_y - $y - 1 + ($this->image_reflection_space < 0 ? $this->image_reflection_space : 0))); + $alpha_o = 1 - ($pixel_o['alpha'] / 127); + $alpha_b = 1 - ($pixel_b['alpha'] / 127); + $opacity = $alpha_o * $transparency / 100; + if ($opacity > 0) { + $red = round((($pixel_o['red'] * $opacity) + ($pixel_b['red'] ) * $alpha_b) / ($alpha_b + $opacity)); + $green = round((($pixel_o['green'] * $opacity) + ($pixel_b['green']) * $alpha_b) / ($alpha_b + $opacity)); + $blue = round((($pixel_o['blue'] * $opacity) + ($pixel_b['blue'] ) * $alpha_b) / ($alpha_b + $opacity)); + $alpha = ($opacity + $alpha_b); + if ($alpha > 1) $alpha = 1; + $alpha = round((1 - $alpha) * 127); + $color = imagecolorallocatealpha($tmp, $red, $green, $blue, $alpha); + imagesetpixel($tmp, $x, $y + $this->image_dst_y + $this->image_reflection_space, $color); + } + } + if ($transparency > 0) $transparency = $transparency - ($this->image_reflection_opacity / $image_reflection_height); + } + + // copy the resulting image into the destination image + $this->image_dst_y = $this->image_dst_y + $image_reflection_height + $this->image_reflection_space; + $image_dst = $this->imagetransfer($tmp, $image_dst); + } + + // change opacity + if ($gd_version >= 2 && is_numeric($this->image_opacity) && $this->image_opacity < 100) { + $this->log .= '- change opacity
'; + // create the new destination image + $tmp = $this->imagecreatenew($this->image_dst_x, $this->image_dst_y, true); + for($y=0; $y < $this->image_dst_y; $y++) { + for($x=0; $x < $this->image_dst_x; $x++) { + $pixel = imagecolorsforindex($image_dst, imagecolorat($image_dst, $x, $y)); + $alpha = $pixel['alpha'] + round((127 - $pixel['alpha']) * (100 - $this->image_opacity) / 100); + if ($alpha > 127) $alpha = 127; + if ($alpha > 0) { + $color = imagecolorallocatealpha($tmp, $pixel['red'] , $pixel['green'], $pixel['blue'], $alpha); + imagesetpixel($tmp, $x, $y, $color); + } + } + } + // copy the resulting image into the destination image + $image_dst = $this->imagetransfer($tmp, $image_dst); + } + + // reduce the JPEG image to a set desired size + if (is_numeric($this->jpeg_size) && $this->jpeg_size > 0 && ($this->image_convert == 'jpeg' || $this->image_convert == 'jpg')) { + // inspired by: JPEGReducer class version 1, 25 November 2004, Author: Huda M ElMatsani, justhuda at netscape dot net + $this->log .= '- JPEG desired file size : ' . $this->jpeg_size . '
'; + // calculate size of each image. 75%, 50%, and 25% quality + ob_start(); imagejpeg($image_dst,null,75); $buffer = ob_get_contents(); ob_end_clean(); + $size75 = strlen($buffer); + ob_start(); imagejpeg($image_dst,null,50); $buffer = ob_get_contents(); ob_end_clean(); + $size50 = strlen($buffer); + ob_start(); imagejpeg($image_dst,null,25); $buffer = ob_get_contents(); ob_end_clean(); + $size25 = strlen($buffer); + + // make sure we won't divide by 0 + if ($size50 == $size25) $size50++; + if ($size75 == $size50 || $size75 == $size25) $size75++; + + // calculate gradient of size reduction by quality + $mgrad1 = 25 / ($size50-$size25); + $mgrad2 = 25 / ($size75-$size50); + $mgrad3 = 50 / ($size75-$size25); + $mgrad = ($mgrad1 + $mgrad2 + $mgrad3) / 3; + // result of approx. quality factor for expected size + $q_factor = round($mgrad * ($this->jpeg_size - $size50) + 50); + + if ($q_factor<1) { + $this->jpeg_quality=1; + } elseif ($q_factor>100) { + $this->jpeg_quality=100; + } else { + $this->jpeg_quality=$q_factor; + } + $this->log .= '    JPEG quality factor set to ' . $this->jpeg_quality . '
'; + } + + // converts image from true color, and fix transparency if needed + $this->log .= '- converting...
'; + $this->image_dst_type = $this->image_convert; + switch($this->image_convert) { + case 'gif': + // if the image is true color, we convert it to a palette + if (imageistruecolor($image_dst)) { + $this->log .= '    true color to palette
'; + // creates a black and white mask + $mask = array(array()); + for ($x = 0; $x < $this->image_dst_x; $x++) { + for ($y = 0; $y < $this->image_dst_y; $y++) { + $pixel = imagecolorsforindex($image_dst, imagecolorat($image_dst, $x, $y)); + $mask[$x][$y] = $pixel['alpha']; + } + } + list($red, $green, $blue) = $this->getcolors($this->image_default_color); + // first, we merge the image with the background color, so we know which colors we will have + for ($x = 0; $x < $this->image_dst_x; $x++) { + for ($y = 0; $y < $this->image_dst_y; $y++) { + if ($mask[$x][$y] > 0){ + // we have some transparency. we combine the color with the default color + $pixel = imagecolorsforindex($image_dst, imagecolorat($image_dst, $x, $y)); + $alpha = ($mask[$x][$y] / 127); + $pixel['red'] = round(($pixel['red'] * (1 -$alpha) + $red * ($alpha))); + $pixel['green'] = round(($pixel['green'] * (1 -$alpha) + $green * ($alpha))); + $pixel['blue'] = round(($pixel['blue'] * (1 -$alpha) + $blue * ($alpha))); + $color = imagecolorallocate($image_dst, $pixel['red'], $pixel['green'], $pixel['blue']); + imagesetpixel($image_dst, $x, $y, $color); + } + } + } + // transforms the true color image into palette, with its merged default color + if (empty($this->image_background_color)) { + imagetruecolortopalette($image_dst, true, 255); + $transparency = imagecolorallocate($image_dst, 254, 1, 253); + imagecolortransparent($image_dst, $transparency); + // make the transparent areas transparent + for ($x = 0; $x < $this->image_dst_x; $x++) { + for ($y = 0; $y < $this->image_dst_y; $y++) { + // we test wether we have enough opacity to justify keeping the color + if ($mask[$x][$y] > 120) imagesetpixel($image_dst, $x, $y, $transparency); + } + } + } + unset($mask); + } + break; + case 'jpg': + case 'bmp': + // if the image doesn't support any transparency, then we merge it with the default color + $this->log .= '    fills in transparency with default color
'; + list($red, $green, $blue) = $this->getcolors($this->image_default_color); + $transparency = imagecolorallocate($image_dst, $red, $green, $blue); + // make the transaparent areas transparent + for ($x = 0; $x < $this->image_dst_x; $x++) { + for ($y = 0; $y < $this->image_dst_y; $y++) { + // we test wether we have some transparency, in which case we will merge the colors + if (imageistruecolor($image_dst)) { + $rgba = imagecolorat($image_dst, $x, $y); + $pixel = array('red' => ($rgba >> 16) & 0xFF, + 'green' => ($rgba >> 8) & 0xFF, + 'blue' => $rgba & 0xFF, + 'alpha' => ($rgba & 0x7F000000) >> 24); + } else { + $pixel = imagecolorsforindex($image_dst, imagecolorat($image_dst, $x, $y)); + } + if ($pixel['alpha'] == 127) { + // we have full transparency. we make the pixel transparent + imagesetpixel($image_dst, $x, $y, $transparency); + } else if ($pixel['alpha'] > 0) { + // we have some transparency. we combine the color with the default color + $alpha = ($pixel['alpha'] / 127); + $pixel['red'] = round(($pixel['red'] * (1 -$alpha) + $red * ($alpha))); + $pixel['green'] = round(($pixel['green'] * (1 -$alpha) + $green * ($alpha))); + $pixel['blue'] = round(($pixel['blue'] * (1 -$alpha) + $blue * ($alpha))); + $color = imagecolorclosest($image_dst, $pixel['red'], $pixel['green'], $pixel['blue']); + imagesetpixel($image_dst, $x, $y, $color); + } + } + } + + break; + default: + break; + } + + // interlace options + if($this->image_interlace) imageinterlace($image_dst, true); + + // outputs image + $this->log .= '- saving image...
'; + switch($this->image_convert) { + case 'jpeg': + case 'jpg': + if (!$return_mode) { + $result = @imagejpeg($image_dst, $this->file_dst_pathname, $this->jpeg_quality); + } else { + ob_start(); + $result = @imagejpeg($image_dst, null, $this->jpeg_quality); + $return_content = ob_get_contents(); + ob_end_clean(); + } + if (!$result) { + $this->processed = false; + $this->error = $this->translate('file_create', array('JPEG')); + } else { + $this->log .= '    JPEG image created
'; + } + break; + case 'png': + imagealphablending( $image_dst, false ); + imagesavealpha( $image_dst, true ); + if (!$return_mode) { + if (is_numeric($this->png_compression) && version_compare(PHP_VERSION, '5.1.2') >= 0) { + $result = @imagepng($image_dst, $this->file_dst_pathname, $this->png_compression); + } else { + $result = @imagepng($image_dst, $this->file_dst_pathname); + } + } else { + ob_start(); + if (is_numeric($this->png_compression) && version_compare(PHP_VERSION, '5.1.2') >= 0) { + $result = @imagepng($image_dst, null, $this->png_compression); + } else { + $result = @imagepng($image_dst); + } + $return_content = ob_get_contents(); + ob_end_clean(); + } + if (!$result) { + $this->processed = false; + $this->error = $this->translate('file_create', array('PNG')); + } else { + $this->log .= '    PNG image created
'; + } + break; + case 'webp': + imagealphablending( $image_dst, false ); + imagesavealpha( $image_dst, true ); + if (!$return_mode) { + $result = @imagewebp($image_dst, $this->file_dst_pathname, $this->webp_quality); + } else { + ob_start(); + $result = @imagewebp($image_dst, null, $this->webp_quality); + $return_content = ob_get_contents(); + ob_end_clean(); + } + if (!$result) { + $this->processed = false; + $this->error = $this->translate('file_create', array('WEBP')); + } else { + $this->log .= '    WEBP image created
'; + } + break; + case 'gif': + if (!$return_mode) { + $result = @imagegif($image_dst, $this->file_dst_pathname); + } else { + ob_start(); + $result = @imagegif($image_dst); + $return_content = ob_get_contents(); + ob_end_clean(); + } + if (!$result) { + $this->processed = false; + $this->error = $this->translate('file_create', array('GIF')); + } else { + $this->log .= '    GIF image created
'; + } + break; + case 'bmp': + if (!$return_mode) { + $result = $this->imagebmp($image_dst, $this->file_dst_pathname); + } else { + ob_start(); + $result = $this->imagebmp($image_dst); + $return_content = ob_get_contents(); + ob_end_clean(); + } + if (!$result) { + $this->processed = false; + $this->error = $this->translate('file_create', array('BMP')); + } else { + $this->log .= '    BMP image created
'; + } + break; + + default: + $this->processed = false; + $this->error = $this->translate('no_conversion_type'); + } + if ($this->processed) { + $this->imageunset($image_src); + $this->imageunset($image_dst); + $this->log .= '    image objects destroyed
'; + } + } + + } else { + $this->log .= '- no image processing wanted
'; + + if (!$return_mode) { + // copy the file to its final destination. we don't use move_uploaded_file here + // if we happen to have open_basedir restrictions, it is a temp file that we copy, not the original uploaded file + if (!copy($this->file_src_pathname, $this->file_dst_pathname)) { + $this->processed = false; + $this->error = $this->translate('copy_failed'); + } + } else { + // returns the file, so that its content can be received by the caller + $return_content = @file_get_contents($this->file_src_pathname); + if ($return_content === false) { + $this->processed = false; + $this->error = $this->translate('reading_failed'); + } + } + } + } + + if ($this->processed) { + $this->log .= '- process OK
'; + } else { + $this->log .= '- error: ' . $this->error . '
'; + } + + // we reinit all the vars + $this->init(); + + // we may return the image content + if ($return_mode) return $return_content; + + } + + /** + * Deletes the uploaded file from its temporary location + * + * When PHP uploads a file, it stores it in a temporary location. + * When you {@link process} the file, you actually copy the resulting file to the given location, it doesn't alter the original file. + * Once you have processed the file as many times as you wanted, you can delete the uploaded file. + * If there is open_basedir restrictions, the uploaded file is in fact a temporary file + * + * You might want not to use this function if you work on local files, as it will delete the source file + * + * @access public + */ + function clean() { + $this->log .= 'cleanup
'; + $this->log .= '- delete temp file ' . $this->file_src_pathname . '
'; + @unlink($this->file_src_pathname); + } + + + /** + * Opens a BMP image + * + * This function has been written by DHKold, and is used with permission of the author + * + * @access public + */ + function imagecreatefrombmp($filename) { + if (! $f1 = fopen($filename,"rb")) return false; + + $file = unpack("vfile_type/Vfile_size/Vreserved/Vbitmap_offset", fread($f1,14)); + if ($file['file_type'] != 19778) return false; + + $bmp = unpack('Vheader_size/Vwidth/Vheight/vplanes/vbits_per_pixel'. + '/Vcompression/Vsize_bitmap/Vhoriz_resolution'. + '/Vvert_resolution/Vcolors_used/Vcolors_important', fread($f1,40)); + $bmp['colors'] = pow(2,$bmp['bits_per_pixel']); + if ($bmp['size_bitmap'] == 0) $bmp['size_bitmap'] = $file['file_size'] - $file['bitmap_offset']; + $bmp['bytes_per_pixel'] = $bmp['bits_per_pixel']/8; + $bmp['bytes_per_pixel2'] = ceil($bmp['bytes_per_pixel']); + $bmp['decal'] = ($bmp['width']*$bmp['bytes_per_pixel']/4); + $bmp['decal'] -= floor($bmp['width']*$bmp['bytes_per_pixel']/4); + $bmp['decal'] = 4-(4*$bmp['decal']); + if ($bmp['decal'] == 4) $bmp['decal'] = 0; + + $palette = array(); + if ($bmp['colors'] < 16777216) { + $palette = unpack('V'.$bmp['colors'], fread($f1,$bmp['colors']*4)); + } + + $im = fread($f1,$bmp['size_bitmap']); + $vide = chr(0); + + $res = imagecreatetruecolor($bmp['width'],$bmp['height']); + $P = 0; + $Y = $bmp['height']-1; + while ($Y >= 0) { + $X=0; + while ($X < $bmp['width']) { + if ($bmp['bits_per_pixel'] == 24) + $color = unpack("V",substr($im,$P,3).$vide); + elseif ($bmp['bits_per_pixel'] == 16) { + $color = unpack("n",substr($im,$P,2)); + $color[1] = $palette[$color[1]+1]; + } elseif ($bmp['bits_per_pixel'] == 8) { + $color = unpack("n",$vide.substr($im,$P,1)); + $color[1] = $palette[$color[1]+1]; + } elseif ($bmp['bits_per_pixel'] == 4) { + $color = unpack("n",$vide.substr($im,floor($P),1)); + if (($P*2)%2 == 0) $color[1] = ($color[1] >> 4) ; else $color[1] = ($color[1] & 0x0F); + $color[1] = $palette[$color[1]+1]; + } elseif ($bmp['bits_per_pixel'] == 1) { + $color = unpack("n",$vide.substr($im,floor($P),1)); + if (($P*8)%8 == 0) $color[1] = $color[1] >>7; + elseif (($P*8)%8 == 1) $color[1] = ($color[1] & 0x40)>>6; + elseif (($P*8)%8 == 2) $color[1] = ($color[1] & 0x20)>>5; + elseif (($P*8)%8 == 3) $color[1] = ($color[1] & 0x10)>>4; + elseif (($P*8)%8 == 4) $color[1] = ($color[1] & 0x8)>>3; + elseif (($P*8)%8 == 5) $color[1] = ($color[1] & 0x4)>>2; + elseif (($P*8)%8 == 6) $color[1] = ($color[1] & 0x2)>>1; + elseif (($P*8)%8 == 7) $color[1] = ($color[1] & 0x1); + $color[1] = $palette[$color[1]+1]; + } else + return false; + imagesetpixel($res,$X,$Y,$color[1]); + $X++; + $P += $bmp['bytes_per_pixel']; + } + $Y--; + $P+=$bmp['decal']; + } + fclose($f1); + return $res; + } + + /** + * Saves a BMP image + * + * This function has been published on the PHP website, and can be used freely + * + * @access public + */ + function imagebmp(&$im, $filename = "") { + + if (!$im) return false; + $w = imagesx($im); + $h = imagesy($im); + $result = ''; + + // if the image is not true color, we convert it first + if (!imageistruecolor($im)) { + $tmp = imagecreatetruecolor($w, $h); + imagecopy($tmp, $im, 0, 0, 0, 0, $w, $h); + $this->imageunset($im); + $im = & $tmp; + } + + $biBPLine = $w * 3; + $biStride = ($biBPLine + 3) & ~3; + $biSizeImage = $biStride * $h; + $bfOffBits = 54; + $bfSize = $bfOffBits + $biSizeImage; + + $result .= substr('BM', 0, 2); + $result .= pack ('VvvV', $bfSize, 0, 0, $bfOffBits); + $result .= pack ('VVVvvVVVVVV', 40, $w, $h, 1, 24, 0, $biSizeImage, 0, 0, 0, 0); + + $numpad = $biStride - $biBPLine; + for ($y = $h - 1; $y >= 0; --$y) { + for ($x = 0; $x < $w; ++$x) { + $col = imagecolorat ($im, $x, $y); + $result .= substr(pack ('V', $col), 0, 3); + } + for ($i = 0; $i < $numpad; ++$i) + $result .= pack ('C', 0); + } + + if($filename==""){ + echo $result; + } else { + $file = fopen($filename, "wb"); + fwrite($file, $result); + fclose($file); + } + return true; + } +} + +?> diff --git a/vendor/verot/class.upload.php/src/lang/class.upload.ca_CA.php b/vendor/verot/class.upload.php/src/lang/class.upload.ca_CA.php new file mode 100644 index 0000000..a8a8896 --- /dev/null +++ b/vendor/verot/class.upload.php/src/lang/class.upload.ca_CA.php @@ -0,0 +1,85 @@ + \ No newline at end of file diff --git a/vendor/verot/class.upload.php/src/lang/class.upload.cs_CS.php b/vendor/verot/class.upload.php/src/lang/class.upload.cs_CS.php new file mode 100644 index 0000000..24cab74 --- /dev/null +++ b/vendor/verot/class.upload.php/src/lang/class.upload.cs_CS.php @@ -0,0 +1,84 @@ + \ No newline at end of file diff --git a/vendor/verot/class.upload.php/src/lang/class.upload.da_DK.php b/vendor/verot/class.upload.php/src/lang/class.upload.da_DK.php new file mode 100644 index 0000000..8f17cf2 --- /dev/null +++ b/vendor/verot/class.upload.php/src/lang/class.upload.da_DK.php @@ -0,0 +1,87 @@ + diff --git a/vendor/verot/class.upload.php/src/lang/class.upload.de_DE.php b/vendor/verot/class.upload.php/src/lang/class.upload.de_DE.php new file mode 100644 index 0000000..d321492 --- /dev/null +++ b/vendor/verot/class.upload.php/src/lang/class.upload.de_DE.php @@ -0,0 +1,83 @@ + diff --git a/vendor/verot/class.upload.php/src/lang/class.upload.el_GR.php b/vendor/verot/class.upload.php/src/lang/class.upload.el_GR.php new file mode 100644 index 0000000..1825c79 --- /dev/null +++ b/vendor/verot/class.upload.php/src/lang/class.upload.el_GR.php @@ -0,0 +1,85 @@ + diff --git a/vendor/verot/class.upload.php/src/lang/class.upload.es_ES.php b/vendor/verot/class.upload.php/src/lang/class.upload.es_ES.php new file mode 100644 index 0000000..6faca9a --- /dev/null +++ b/vendor/verot/class.upload.php/src/lang/class.upload.es_ES.php @@ -0,0 +1,85 @@ + \ No newline at end of file diff --git a/vendor/verot/class.upload.php/src/lang/class.upload.et_EE.php b/vendor/verot/class.upload.php/src/lang/class.upload.et_EE.php new file mode 100644 index 0000000..f7177fa --- /dev/null +++ b/vendor/verot/class.upload.php/src/lang/class.upload.et_EE.php @@ -0,0 +1,85 @@ + \ No newline at end of file diff --git a/vendor/verot/class.upload.php/src/lang/class.upload.fa_IR.php b/vendor/verot/class.upload.php/src/lang/class.upload.fa_IR.php new file mode 100644 index 0000000..df69a1c --- /dev/null +++ b/vendor/verot/class.upload.php/src/lang/class.upload.fa_IR.php @@ -0,0 +1,88 @@ + + * @license http://opensource.org/licenses/gpl-license.php GNU Public License + * @copyright Morteza Karimi + * @package cmf + * @subpackage external + */ + + $translation = array(); + $translation['file_error'] = 'خطای فایل. لطفا دوباره تلاش کنید.'; + $translation['local_file_missing'] = 'فایل محلی وجود ندارد.'; + $translation['local_file_not_readable'] = 'فایل محلی قابل خواندن نیست.'; + $translation['uploaded_too_big_ini'] = 'خطای بارگذاری فایل (حجم فایل بارگذاری شده بیشتر از مقدار تعریف شده برای upload_max_filesize در php.ini است).'; + $translation['uploaded_too_big_html'] = 'خطای بارگذاری فایل (حجم فایل بارگذاری شده بیشتر از مقدار تعریف شده برای MAX_FILE_SIZE در کد html فرم ورودی است).'; + $translation['uploaded_partial'] = 'خطای بارگذاری فایل (تنها بخشی از فایل بارگذاری شده).'; + $translation['uploaded_missing'] = 'خطای بارگذاری فایل (هیچ فایلی بارگذاری نشده است).'; + $translation['uploaded_no_tmp_dir'] = 'خطای بارگذاری فایل (پوشه فایل موقت وجود ندارد).'; + $translation['uploaded_cant_write'] = 'خطای بارگذاری فایل (نوشتن فایل بر روی دیسک شکست خورد).'; + $translation['uploaded_err_extension'] = 'خطای بارگذاری فایل (بارگذاری فایل بخاطر پسوند فایل متوقف شد).'; + $translation['uploaded_unknown'] = 'خطای بارگذاری فایل (خطای نامشخص).'; + $translation['try_again'] = 'خطای بارگذاری فایل. دوباره تلاش کنید.'; + $translation['file_too_big'] = 'فایل بسیار بزرگ است.'; + $translation['no_mime'] = 'نوع MIME تشخیص داده نشد.'; + $translation['incorrect_file'] = 'نوع فایل اشتباه است.'; + $translation['image_too_wide'] = 'عرض تصویر بسیار زیاد است.'; + $translation['image_too_narrow'] = 'عرض تصویر بسیار کم است.'; + $translation['image_too_high'] = 'ارتفاع تصویر بسیار زیاد است.'; + $translation['image_too_short'] = 'ارتفاع تصویر بسیار کم است.'; + $translation['ratio_too_high'] = 'نسبت تصویر بیش از حد بالاست (تصویر بسیار عریض است).'; + $translation['ratio_too_low'] = 'نسبت تصویر بسیار پایین است (تصویر بسیار مرتفع(طویل)است).'; + $translation['too_many_pixels'] = 'تعداد نقاط (عنصر تصویر) بسیار زیاد است.'; + $translation['not_enough_pixels'] = 'تعداد نقاط تصویر کافی است.'; + $translation['file_not_uploaded'] = 'فایل بارگذاری نشده است.امکان ادامه پردازش وجود ندارد..'; + $translation['already_exists'] = '%s در حال حاضر وجود دارد. لطفا نام فایل را عوض کنید.'; + $translation['temp_file_missing'] = 'منبع پوشه فایل موقت صحیح نمی باشد. امکان ادامه پردازش وجود ندارد.'; + $translation['source_missing'] = 'منبع فایل بارگذاری شده صحیح نیست. امکان ادامه پردازش وجود ندارد.'; + $translation['destination_dir'] = 'شاخه مقصد ساخته نمیشود.امکان ادامه پردازش وجود ندارد.'; + $translation['destination_dir_missing'] = 'شاخه مقصد وجود ندارد. امکان ادامه پردازش وجود ندارد.'; + $translation['destination_path_not_dir'] = 'مسیر مقصد یک شاخه نیست. امکان ادامه پردازش وجود ندارد.'; + $translation['destination_dir_write'] = 'مقصد شاخه قابل نوشتن نیست. امکان ادامه پردازش وجود ندارد.'; + $translation['destination_path_write'] = 'مسیر مقصد قابل نوشتن نیست. امکان ادامه پردازش وجود ندارد.'; + $translation['temp_file'] = 'فایل موقتی نمیتوان ساخت. امکان ادامه پردازش وجود ندارد.'; + $translation['source_not_readable'] = 'منبع فایل قابل خواندن نیست. امکان ادامه پردازش وجود ندارد'; + $translation['no_create_support'] = 'را ندارد %s پشتیبانی.'; + $translation['create_error'] = ' از منبع%s خطای ساخت عکس.'; + $translation['source_invalid'] = 'منبع عکس قابل خواندن نیست.فایل مور نظر عکس نیست.'; + $translation['gd_missing'] = 'نیست GDدر حال حاضر.'; + $translation['watermark_no_create_support'] = 'پشتیبانی را ندارد . علامت سفید چاپ خوانده نمی شود.'; + $translation['watermark_create_error'] = 'پشتیبانی خواندن را ندارد. علامت سفید چاپ خوانده نمی شود.'; + $translation['watermark_invalid'] = 'اندازه عکس مشخص نیست. علامت سفید چاپ خوانده نمیشود.'; + $translation['file_create'] = ' قابل ساخت نیست %s پشتیبانی.'; + $translation['no_conversion_type'] = 'هیچ نوع تبدیل پیدا نشد.'; + $translation['copy_failed'] = 'خطای کپی فایل روی سرور.فرایند کپی با شکست مواجه شد.'; + $translation['reading_failed'] = 'خطای خواندن فایل.'; + +?> diff --git a/vendor/verot/class.upload.php/src/lang/class.upload.fi_FI.php b/vendor/verot/class.upload.php/src/lang/class.upload.fi_FI.php new file mode 100644 index 0000000..b048a58 --- /dev/null +++ b/vendor/verot/class.upload.php/src/lang/class.upload.fi_FI.php @@ -0,0 +1,87 @@ + \ No newline at end of file diff --git a/vendor/verot/class.upload.php/src/lang/class.upload.fr_FR.php b/vendor/verot/class.upload.php/src/lang/class.upload.fr_FR.php new file mode 100644 index 0000000..a11c84a --- /dev/null +++ b/vendor/verot/class.upload.php/src/lang/class.upload.fr_FR.php @@ -0,0 +1,88 @@ + + * @license http://opensource.org/licenses/gpl-license.php GNU Public License + * @copyright Colin Verot + * @package cmf + * @subpackage external + */ + + $translation = array(); + $translation['file_error'] = 'Erreur de transmission. Essayez encore.'; + $translation['local_file_missing'] = 'Le fichier local n\'existe pas.'; + $translation['local_file_not_readable'] = 'Le fichier local ne peut être ouvert en lecture.'; + $translation['uploaded_too_big_ini'] = 'Le fichier transmis dépasse la taille autorisée dans la configuration php.ini.'; + $translation['uploaded_too_big_html'] = 'Le fichier transmis dépasse la taille autorisée dans le formulaire.'; + $translation['uploaded_partial'] = 'Le fichier n\' été que partiellement transmis.'; + $translation['uploaded_missing'] = 'Le serveur n\'a pas reçu de fichier.'; + $translation['uploaded_no_tmp_dir'] = 'Il n\'y a pas de répertoire temporaire disponible'; + $translation['uploaded_cant_write'] = 'Impossible d\'écrire sur le disque.'; + $translation['uploaded_err_extension'] = 'Upload stoppé par l\'extension.'; + $translation['uploaded_unknown'] = 'Erreur inconnue.'; + $translation['try_again'] = 'Erreur de transmission. Essayez encore.'; + $translation['file_too_big'] = 'Fichier trop gros.'; + $translation['no_mime'] = 'Le MIME type ne peut être détecté.'; + $translation['incorrect_file'] = 'Type de fichier incorrect.'; + $translation['image_too_wide'] = 'L\'image est trop large.'; + $translation['image_too_narrow'] = 'L\'image n\est pas assez large.'; + $translation['image_too_high'] = 'L\image est trop haute.'; + $translation['image_too_short'] = 'L\image n\est pas assez haute.'; + $translation['ratio_too_high'] = 'Le ratio est trop élevé (image trop large).'; + $translation['ratio_too_low'] = 'Le ratio est trop petit (image trop haute).'; + $translation['too_many_pixels'] = 'L\'image a trop de pixels.'; + $translation['not_enough_pixels'] = 'L\'image n\'a pas assez de pixels.'; + $translation['file_not_uploaded'] = 'Fichier non transmis. Impossible de continuer.'; + $translation['already_exists'] = '%s existe déjà. Changez le nom du fichier.'; + $translation['temp_file_missing'] = 'Le fichier source est incorrect. Impossible de continuer.'; + $translation['source_missing'] = 'Le fichier transmis est incorrect. Impossible de continuer.'; + $translation['destination_dir'] = 'Le répertoire de destination ne peut être crée. Impossible de continuer.'; + $translation['destination_dir_missing'] = 'Le répertoire de destination n\'existe pas. Impossible de continuer.'; + $translation['destination_path_not_dir'] = 'Le chemin de destination n\'est pas un répertoire. Impossible de continuer.'; + $translation['destination_dir_write'] = 'Le répertoire de destination ne peut être ouvert en écriture. Impossible de continuer.'; + $translation['destination_path_write'] = 'Le chemin de destination ne peut être ouvert en écriture. Impossible de continuer.'; + $translation['temp_file'] = 'Le fichier temporaire ne peut être crée. Impossible de continuer.'; + $translation['source_not_readable'] = 'Le fichier source ne peut être lu. Impossible de continuer.'; + $translation['no_create_support'] = 'Création depuis un fichier %s impossible.'; + $translation['create_error'] = 'Erreur lors de la création de l\'image %s depuis le fichier source.'; + $translation['source_invalid'] = 'Impossible de lire l\'image source. Est-ce une image?.'; + $translation['gd_missing'] = 'GD ne semble pas être présent.'; + $translation['watermark_no_create_support'] = 'Création depuis un fichier %s impossible, watermark ne peut être lu.'; + $translation['watermark_create_error'] = 'Erreur lors de la création du watermark %s depuis le fichier source.'; + $translation['watermark_invalid'] = 'Impossible de lire le watermark, format de fichier inconnu.'; + $translation['file_create'] = 'Création d\'un fichier %s impossible.'; + $translation['no_conversion_type'] = 'Le type de conversion n\'est pas défini.'; + $translation['copy_failed'] = 'La copie du fichier sur le serveur a échoué.'; + $translation['reading_failed'] = 'Erreur pendant la lecture du fichier.'; + +?> diff --git a/vendor/verot/class.upload.php/src/lang/class.upload.he_IL.php b/vendor/verot/class.upload.php/src/lang/class.upload.he_IL.php new file mode 100644 index 0000000..37d235b --- /dev/null +++ b/vendor/verot/class.upload.php/src/lang/class.upload.he_IL.php @@ -0,0 +1,86 @@ + diff --git a/vendor/verot/class.upload.php/src/lang/class.upload.hr_HR.php b/vendor/verot/class.upload.php/src/lang/class.upload.hr_HR.php new file mode 100644 index 0000000..829ad35 --- /dev/null +++ b/vendor/verot/class.upload.php/src/lang/class.upload.hr_HR.php @@ -0,0 +1,84 @@ + \ No newline at end of file diff --git a/vendor/verot/class.upload.php/src/lang/class.upload.hu_HU.php b/vendor/verot/class.upload.php/src/lang/class.upload.hu_HU.php new file mode 100644 index 0000000..f78204f --- /dev/null +++ b/vendor/verot/class.upload.php/src/lang/class.upload.hu_HU.php @@ -0,0 +1,86 @@ + \ No newline at end of file diff --git a/vendor/verot/class.upload.php/src/lang/class.upload.id_ID.php b/vendor/verot/class.upload.php/src/lang/class.upload.id_ID.php new file mode 100644 index 0000000..ab82b23 --- /dev/null +++ b/vendor/verot/class.upload.php/src/lang/class.upload.id_ID.php @@ -0,0 +1,86 @@ + \ No newline at end of file diff --git a/vendor/verot/class.upload.php/src/lang/class.upload.it_IT.php b/vendor/verot/class.upload.php/src/lang/class.upload.it_IT.php new file mode 100644 index 0000000..449fe5e --- /dev/null +++ b/vendor/verot/class.upload.php/src/lang/class.upload.it_IT.php @@ -0,0 +1,85 @@ + \ No newline at end of file diff --git a/vendor/verot/class.upload.php/src/lang/class.upload.ja_JP.php b/vendor/verot/class.upload.php/src/lang/class.upload.ja_JP.php new file mode 100644 index 0000000..f40122a --- /dev/null +++ b/vendor/verot/class.upload.php/src/lang/class.upload.ja_JP.php @@ -0,0 +1,88 @@ + diff --git a/vendor/verot/class.upload.php/src/lang/class.upload.lt_LT.php b/vendor/verot/class.upload.php/src/lang/class.upload.lt_LT.php new file mode 100644 index 0000000..5f89c37 --- /dev/null +++ b/vendor/verot/class.upload.php/src/lang/class.upload.lt_LT.php @@ -0,0 +1,88 @@ + diff --git a/vendor/verot/class.upload.php/src/lang/class.upload.mk_MK.php b/vendor/verot/class.upload.php/src/lang/class.upload.mk_MK.php new file mode 100644 index 0000000..eec5f73 --- /dev/null +++ b/vendor/verot/class.upload.php/src/lang/class.upload.mk_MK.php @@ -0,0 +1,88 @@ + \ No newline at end of file diff --git a/vendor/verot/class.upload.php/src/lang/class.upload.nl_NL.php b/vendor/verot/class.upload.php/src/lang/class.upload.nl_NL.php new file mode 100644 index 0000000..c5d36bf --- /dev/null +++ b/vendor/verot/class.upload.php/src/lang/class.upload.nl_NL.php @@ -0,0 +1,86 @@ + diff --git a/vendor/verot/class.upload.php/src/lang/class.upload.no_NO.php b/vendor/verot/class.upload.php/src/lang/class.upload.no_NO.php new file mode 100644 index 0000000..d096f14 --- /dev/null +++ b/vendor/verot/class.upload.php/src/lang/class.upload.no_NO.php @@ -0,0 +1,85 @@ + \ No newline at end of file diff --git a/vendor/verot/class.upload.php/src/lang/class.upload.pl_PL.php b/vendor/verot/class.upload.php/src/lang/class.upload.pl_PL.php new file mode 100644 index 0000000..8291017 --- /dev/null +++ b/vendor/verot/class.upload.php/src/lang/class.upload.pl_PL.php @@ -0,0 +1,85 @@ + \ No newline at end of file diff --git a/vendor/verot/class.upload.php/src/lang/class.upload.pt_BR.php b/vendor/verot/class.upload.php/src/lang/class.upload.pt_BR.php new file mode 100644 index 0000000..0b1c53f --- /dev/null +++ b/vendor/verot/class.upload.php/src/lang/class.upload.pt_BR.php @@ -0,0 +1,88 @@ + diff --git a/vendor/verot/class.upload.php/src/lang/class.upload.ro_RO.php b/vendor/verot/class.upload.php/src/lang/class.upload.ro_RO.php new file mode 100644 index 0000000..b0210c7 --- /dev/null +++ b/vendor/verot/class.upload.php/src/lang/class.upload.ro_RO.php @@ -0,0 +1,84 @@ + \ No newline at end of file diff --git a/vendor/verot/class.upload.php/src/lang/class.upload.ru_RU.php b/vendor/verot/class.upload.php/src/lang/class.upload.ru_RU.php new file mode 100644 index 0000000..d39086b --- /dev/null +++ b/vendor/verot/class.upload.php/src/lang/class.upload.ru_RU.php @@ -0,0 +1,85 @@ + diff --git a/vendor/verot/class.upload.php/src/lang/class.upload.ru_RU.windows-1251.php b/vendor/verot/class.upload.php/src/lang/class.upload.ru_RU.windows-1251.php new file mode 100644 index 0000000..9161dc5 --- /dev/null +++ b/vendor/verot/class.upload.php/src/lang/class.upload.ru_RU.windows-1251.php @@ -0,0 +1,85 @@ + diff --git a/vendor/verot/class.upload.php/src/lang/class.upload.sk_SK.php b/vendor/verot/class.upload.php/src/lang/class.upload.sk_SK.php new file mode 100644 index 0000000..8c4c75c --- /dev/null +++ b/vendor/verot/class.upload.php/src/lang/class.upload.sk_SK.php @@ -0,0 +1,84 @@ + \ No newline at end of file diff --git a/vendor/verot/class.upload.php/src/lang/class.upload.sr_YU.php b/vendor/verot/class.upload.php/src/lang/class.upload.sr_YU.php new file mode 100644 index 0000000..4e4f706 --- /dev/null +++ b/vendor/verot/class.upload.php/src/lang/class.upload.sr_YU.php @@ -0,0 +1,84 @@ + \ No newline at end of file diff --git a/vendor/verot/class.upload.php/src/lang/class.upload.sv_SE.php b/vendor/verot/class.upload.php/src/lang/class.upload.sv_SE.php new file mode 100644 index 0000000..8540357 --- /dev/null +++ b/vendor/verot/class.upload.php/src/lang/class.upload.sv_SE.php @@ -0,0 +1,84 @@ + \ No newline at end of file diff --git a/vendor/verot/class.upload.php/src/lang/class.upload.ta_TA.php b/vendor/verot/class.upload.php/src/lang/class.upload.ta_TA.php new file mode 100644 index 0000000..38fb19a --- /dev/null +++ b/vendor/verot/class.upload.php/src/lang/class.upload.ta_TA.php @@ -0,0 +1,88 @@ + diff --git a/vendor/verot/class.upload.php/src/lang/class.upload.tr_TR.php b/vendor/verot/class.upload.php/src/lang/class.upload.tr_TR.php new file mode 100644 index 0000000..8a38fe3 --- /dev/null +++ b/vendor/verot/class.upload.php/src/lang/class.upload.tr_TR.php @@ -0,0 +1,88 @@ + + + diff --git a/vendor/verot/class.upload.php/src/lang/class.upload.uk_UA.php b/vendor/verot/class.upload.php/src/lang/class.upload.uk_UA.php new file mode 100644 index 0000000..83f38dc --- /dev/null +++ b/vendor/verot/class.upload.php/src/lang/class.upload.uk_UA.php @@ -0,0 +1,85 @@ + \ No newline at end of file diff --git a/vendor/verot/class.upload.php/src/lang/class.upload.uk_UA.windows-1251.php b/vendor/verot/class.upload.php/src/lang/class.upload.uk_UA.windows-1251.php new file mode 100644 index 0000000..39afdee --- /dev/null +++ b/vendor/verot/class.upload.php/src/lang/class.upload.uk_UA.windows-1251.php @@ -0,0 +1,85 @@ + \ No newline at end of file diff --git a/vendor/verot/class.upload.php/src/lang/class.upload.vn_VN.php b/vendor/verot/class.upload.php/src/lang/class.upload.vn_VN.php new file mode 100644 index 0000000..dd65d7d --- /dev/null +++ b/vendor/verot/class.upload.php/src/lang/class.upload.vn_VN.php @@ -0,0 +1,85 @@ + \ No newline at end of file diff --git a/vendor/verot/class.upload.php/src/lang/class.upload.xx_XX.php b/vendor/verot/class.upload.php/src/lang/class.upload.xx_XX.php new file mode 100644 index 0000000..cfc33f9 --- /dev/null +++ b/vendor/verot/class.upload.php/src/lang/class.upload.xx_XX.php @@ -0,0 +1,88 @@ + \ No newline at end of file diff --git a/vendor/verot/class.upload.php/src/lang/class.upload.zh_CN.gb-2312.php b/vendor/verot/class.upload.php/src/lang/class.upload.zh_CN.gb-2312.php new file mode 100644 index 0000000..4cb4b11 --- /dev/null +++ b/vendor/verot/class.upload.php/src/lang/class.upload.zh_CN.gb-2312.php @@ -0,0 +1,86 @@ + \ No newline at end of file diff --git a/vendor/verot/class.upload.php/src/lang/class.upload.zh_CN.php b/vendor/verot/class.upload.php/src/lang/class.upload.zh_CN.php new file mode 100644 index 0000000..d7d70f7 --- /dev/null +++ b/vendor/verot/class.upload.php/src/lang/class.upload.zh_CN.php @@ -0,0 +1,85 @@ + \ No newline at end of file diff --git a/vendor/verot/class.upload.php/src/lang/class.upload.zh_TW.php b/vendor/verot/class.upload.php/src/lang/class.upload.zh_TW.php new file mode 100644 index 0000000..36078ff --- /dev/null +++ b/vendor/verot/class.upload.php/src/lang/class.upload.zh_TW.php @@ -0,0 +1,87 @@ + \ No newline at end of file diff --git a/vendor/verot/class.upload.php/test/bg.gif b/vendor/verot/class.upload.php/test/bg.gif new file mode 100644 index 0000000..4a2bd05 Binary files /dev/null and b/vendor/verot/class.upload.php/test/bg.gif differ diff --git a/vendor/verot/class.upload.php/test/foo.gdf b/vendor/verot/class.upload.php/test/foo.gdf new file mode 100644 index 0000000..f5f7e36 Binary files /dev/null and b/vendor/verot/class.upload.php/test/foo.gdf differ diff --git a/vendor/verot/class.upload.php/test/foo.ttf b/vendor/verot/class.upload.php/test/foo.ttf new file mode 100644 index 0000000..de8a9e1 Binary files /dev/null and b/vendor/verot/class.upload.php/test/foo.ttf differ diff --git a/vendor/verot/class.upload.php/test/index.html b/vendor/verot/class.upload.php/test/index.html new file mode 100644 index 0000000..e64083f --- /dev/null +++ b/vendor/verot/class.upload.php/test/index.html @@ -0,0 +1,250 @@ + + + + + class.upload.php test forms + + + + + +

class.upload.php test forms

+ +
+
+ Simple upload +

Pick up a file to upload, and press "upload"

+ +

+

+

+ +
+ +
+ Image upload +

Pick up an image to upload, and press "upload"

+
+

+

+

+ +
+ +
+ XMLHttpRequest upload +

Pick up one file to upload, and press "upload"

+
+

+
+

+

+
+ +
+
+ +
+ HTML5 File Drag & Drop API +

Drag and drop one file to upload, and press "upload"

+
+

+
... drag and drop here ...
+
+

+

+
+ +
+
+ +
+ Multiple upload +

Pick up some files to upload, and press "upload"

+
+

+

+

+

+

+ +
+ +
+ Multiple upload flexible +

Pick up some files to upload, and press "upload"

+
+

+

+

+ +

Note: Number of processed files per request on the server is also limited by PHP ini setting max_file_uploads.

+
+ +
+ Image local manipulation +

Enter a local file name (absolute or relative) for a small image, and press "process"

+
+

+

+

+ +
+ +
+ Base64-encoded image data +

Copy here base64-encoded file data, and press "process"

+
+

+

+

+ +
+
+ + + + + diff --git a/vendor/verot/class.upload.php/test/test.bmp b/vendor/verot/class.upload.php/test/test.bmp new file mode 100644 index 0000000..fa60d84 Binary files /dev/null and b/vendor/verot/class.upload.php/test/test.bmp differ diff --git a/vendor/verot/class.upload.php/test/test.gif b/vendor/verot/class.upload.php/test/test.gif new file mode 100644 index 0000000..f428023 Binary files /dev/null and b/vendor/verot/class.upload.php/test/test.gif differ diff --git a/vendor/verot/class.upload.php/test/test.jpg b/vendor/verot/class.upload.php/test/test.jpg new file mode 100644 index 0000000..1c44fe4 Binary files /dev/null and b/vendor/verot/class.upload.php/test/test.jpg differ diff --git a/vendor/verot/class.upload.php/test/test.png b/vendor/verot/class.upload.php/test/test.png new file mode 100644 index 0000000..d2ca43c Binary files /dev/null and b/vendor/verot/class.upload.php/test/test.png differ diff --git a/vendor/verot/class.upload.php/test/test.webp b/vendor/verot/class.upload.php/test/test.webp new file mode 100644 index 0000000..fd33a5e Binary files /dev/null and b/vendor/verot/class.upload.php/test/test.webp differ diff --git a/vendor/verot/class.upload.php/test/upload.php b/vendor/verot/class.upload.php/test/upload.php new file mode 100644 index 0000000..1b29080 --- /dev/null +++ b/vendor/verot/class.upload.php/test/upload.php @@ -0,0 +1,988 @@ + + + + + + + + class.php.upload test forms + + + + + + +

class.upload.php test forms

+ +uploaded) { + + // yes, the file is on the server + // now, we start the upload 'process'. That is, to copy the uploaded file + // from its temporary location to the wanted location + // It could be something like $handle->process('/home/www/my_uploads/'); + $handle->process($dir_dest); + + // we check if everything went OK + if ($handle->processed) { + // everything was fine ! + echo '

'; + echo ' File uploaded with success
'; + echo ' File:
' . $handle->file_dst_name . ''; + echo ' (' . round(filesize($handle->file_dst_pathname)/256)/4 . 'KB)'; + echo '

'; + } else { + // one error occured + echo '

'; + echo ' File not uploaded to the wanted location
'; + echo ' Error: ' . $handle->error . ''; + echo '

'; + } + + // we delete the temporary files + $handle-> clean(); + + } else { + // if we're here, the upload file failed for some reasons + // i.e. the server didn't receive the file + echo '

'; + echo ' File not uploaded on the server
'; + echo ' Error: ' . $handle->error . ''; + echo '

'; + } + + $log .= $handle->log . '
'; + + +} else if ($action == 'base64') { + + // ---------- BASE64 FILE ---------- + + // we create an instance of the class, giving as argument the data string + $handle = new Upload((isset($_POST['my_field']) ? $_POST['my_field'] : (isset($_GET['file']) ? $_GET['file'] : ''))); + + // check if a temporary file has been created with the file data + if ($handle->uploaded) { + + // yes, the file is on the server + $handle->process($dir_dest); + + // we check if everything went OK + if ($handle->processed) { + // everything was fine ! + echo '

'; + echo ' File uploaded with success
'; + echo ' File: ' . $handle->file_dst_name . ''; + echo ' (' . round(filesize($handle->file_dst_pathname)/256)/4 . 'KB)'; + echo '

'; + } else { + // one error occured + echo '

'; + echo ' File not uploaded to the wanted location
'; + echo ' Error: ' . $handle->error . ''; + echo '

'; + } + + // we delete the temporary files + $handle-> clean(); + + } else { + // if we're here, the file failed for some reasons + echo '

'; + echo ' File not uploaded on the server
'; + echo ' Error: ' . $handle->error . ''; + echo '

'; + } + + $log .= $handle->log . '
'; + +} else if ($action == 'image') { + + // ---------- IMAGE UPLOAD ---------- + + // we create an instance of the class, giving as argument the PHP object + // corresponding to the file field from the form + // All the uploads are accessible from the PHP object $_FILES + $handle = new Upload($_FILES['my_field']); + + // then we check if the file has been uploaded properly + // in its *temporary* location in the server (often, it is /tmp) + if ($handle->uploaded) { + + // yes, the file is on the server + // below are some example settings which can be used if the uploaded file is an image. + $handle->image_resize = true; + $handle->image_ratio_y = true; + $handle->image_x = 300; + + // now, we start the upload 'process'. That is, to copy the uploaded file + // from its temporary location to the wanted location + // It could be something like $handle->process('/home/www/my_uploads/'); + $handle->process($dir_dest); + + // we check if everything went OK + if ($handle->processed) { + // everything was fine ! + echo '

'; + echo ' File uploaded with success
'; + echo ' '; + $info = getimagesize($handle->file_dst_pathname); + echo ' File: ' . $handle->file_dst_name . '
'; + echo ' (' . $info['mime'] . ' - ' . $info[0] . ' x ' . $info[1] .' - ' . round(filesize($handle->file_dst_pathname)/256)/4 . 'KB)'; + echo '

'; + } else { + // one error occured + echo '

'; + echo ' File not uploaded to the wanted location
'; + echo ' Error: ' . $handle->error . ''; + echo '

'; + } + + // we now process the image a second time, with some other settings + $handle->image_resize = true; + $handle->image_ratio_y = true; + $handle->image_x = 300; + $handle->image_reflection_height = '25%'; + $handle->image_contrast = 50; + + $handle->process($dir_dest); + + // we check if everything went OK + if ($handle->processed) { + // everything was fine ! + echo '

'; + echo ' File uploaded with success
'; + echo ' '; + $info = getimagesize($handle->file_dst_pathname); + echo ' File: ' . $handle->file_dst_name . '
'; + echo ' (' . $info['mime'] . ' - ' . $info[0] . ' x ' . $info[1] .' - ' . round(filesize($handle->file_dst_pathname)/256)/4 . 'KB)'; + echo '

'; + } else { + // one error occured + echo '

'; + echo ' File not uploaded to the wanted location
'; + echo ' Error: ' . $handle->error . ''; + echo '

'; + } + + // we delete the temporary files + $handle-> clean(); + + } else { + // if we're here, the upload file failed for some reasons + // i.e. the server didn't receive the file + echo '

'; + echo ' File not uploaded on the server
'; + echo ' Error: ' . $handle->error . ''; + echo '

'; + } + + $log .= $handle->log . '
'; + +} else if ($action == 'xhr') { + + // ---------- XMLHttpRequest UPLOAD ---------- + + // we first check if it is a XMLHttpRequest call + if (isset($_SERVER['HTTP_X_FILE_NAME']) && isset($_SERVER['CONTENT_LENGTH'])) { + + // we create an instance of the class, feeding in the name of the file + // sent via a XMLHttpRequest request, prefixed with 'php:' + $handle = new Upload('php:'.$_SERVER['HTTP_X_FILE_NAME']); + + } else { + // we create an instance of the class, giving as argument the PHP object + // corresponding to the file field from the form + // This is the fallback, using the standard way + $handle = new Upload($_FILES['my_field']); + } + + // then we check if the file has been uploaded properly + // in its *temporary* location in the server (often, it is /tmp) + if ($handle->uploaded) { + + // yes, the file is on the server + // now, we start the upload 'process'. That is, to copy the uploaded file + // from its temporary location to the wanted location + // It could be something like $handle->process('/home/www/my_uploads/'); + $handle->process($dir_dest); + + // we check if everything went OK + if ($handle->processed) { + // everything was fine ! + echo '

'; + echo ' File uploaded with success
'; + echo ' File: ' . $handle->file_dst_name . ''; + echo ' (' . round(filesize($handle->file_dst_pathname)/256)/4 . 'KB)'; + echo '

'; + } else { + // one error occured + echo '

'; + echo ' File not uploaded to the wanted location
'; + echo ' Error: ' . $handle->error . ''; + echo '

'; + } + + // we delete the temporary files + $handle-> clean(); + + } else { + // if we're here, the upload file failed for some reasons + // i.e. the server didn't receive the file + echo '

'; + echo ' File not uploaded on the server
'; + echo ' Error: ' . $handle->error . ''; + echo '

'; + } + + $log .= $handle->log . '
'; + +} else if ($action == 'multiple') { + + // ---------- MULTIPLE UPLOADS ---------- + + // as it is multiple uploads, we will parse the $_FILES array to reorganize it into $files + $files = array(); + foreach ($_FILES['my_field'] as $k => $l) { + foreach ($l as $i => $v) { + if (!array_key_exists($i, $files)) + $files[$i] = array(); + $files[$i][$k] = $v; + } + } + + // now we can loop through $files, and feed each element to the class + foreach ($files as $file) { + + // we instanciate the class for each element of $file + $handle = new Upload($file); + + // then we check if the file has been uploaded properly + // in its *temporary* location in the server (often, it is /tmp) + if ($handle->uploaded) { + + // now, we start the upload 'process'. That is, to copy the uploaded file + // from its temporary location to the wanted location + // It could be something like $handle->process('/home/www/my_uploads/'); + $handle->process($dir_dest); + + // we check if everything went OK + if ($handle->processed) { + // everything was fine ! + echo '

'; + echo ' File uploaded with success
'; + echo ' File: ' . $handle->file_dst_name . ''; + echo ' (' . round(filesize($handle->file_dst_pathname)/256)/4 . 'KB)'; + echo '

'; + } else { + // one error occured + echo '

'; + echo ' File not uploaded to the wanted location
'; + echo ' Error: ' . $handle->error . ''; + echo '

'; + } + + } else { + // if we're here, the upload file failed for some reasons + // i.e. the server didn't receive the file + echo '

'; + echo ' File not uploaded on the server
'; + echo ' Error: ' . $handle->error . ''; + echo '

'; + } + + $log .= $handle->log . '
'; + } + +} else if ($action == 'local' || isset($_GET['file'])) { + + // ---------- LOCAL PROCESSING ---------- + + + //error_reporting(E_ALL ^ (E_NOTICE | E_USER_NOTICE | E_WARNING | E_USER_WARNING)); + ini_set("max_execution_time",0); + + // we don't upload, we just send a local filename (image) + $handle = new Upload((isset($_POST['my_field']) ? $_POST['my_field'] : (isset($_GET['file']) ? $_GET['file'] : ''))); + + // then we check if the file has been "uploaded" properly + // in our case, it means if the file is present on the local file system + if ($handle->uploaded) { + + // now, we start a serie of processes, with different parameters + // we use a little function TestProcess() to avoid repeting the same code too many times + function TestProcess(&$handle, $title = 'test', $details='') { + global $dir_pics, $dir_dest; + + $handle->process($dir_dest); + + if ($handle->processed) { + echo '
'; + echo ' ' . $title . ''; + echo '
'; + $info = getimagesize($handle->file_dst_pathname); + echo '

' . $info['mime'] . '  -  ' . $info[0] . ' x ' . $info[1] .'  -  ' . round(filesize($handle->file_dst_pathname)/256)/4 . 'KB

'; + if ($details) echo '
' . htmlentities($details) . '
'; + echo '
'; + } else { + echo '
'; + echo ' ' . $title . ''; + echo ' Error: ' . $handle->error . ''; + if ($details) echo '
' . htmlentities($details) . '
'; + echo '
'; + } + } + if (!file_exists($dir_dest)) mkdir($dir_dest); + + // ----------- + TestProcess($handle, 'original file', ''); + + // ----------- + $handle->image_resize = true; + $handle->image_ratio_y = true; + $handle->image_x = 50; + TestProcess($handle, 'width 50, height auto', "\$foo->image_resize = true;\n\$foo->image_ratio_y = true;\n\$foo->image_x = 50;"); + + // ----------- + $handle->image_resize = true; + $handle->image_ratio_x = true; + $handle->image_y = 50; + TestProcess($handle, 'height 50, width auto', "\$foo->image_resize = true;\n\$foo->image_ratio_x = true;\n\$foo->image_y = 50;"); + + // ----------- + $handle->image_resize = true; + $handle->image_y = 50; + $handle->image_x = 50; + TestProcess($handle, 'height 50, width 50', "\$foo->image_resize = true;\n\$foo->image_y = 50;\n\$foo->image_x = 50;"); + + // ----------- + $handle->image_resize = true; + $handle->image_ratio = true; + $handle->image_y = 50; + $handle->image_x = 50; + TestProcess($handle, 'height 50, width 50, keeping ratio', "\$foo->image_resize = true;\n\$foo->image_ratio = true;\n\$foo->image_y = 50;\n\$foo->image_x = 50;"); + + // ----------- + $handle->image_resize = true; + $handle->image_ratio_crop = true; + $handle->image_y = 50; + $handle->image_x = 50; + TestProcess($handle, '50x50, keeping ratio, cropping excedent', "\$foo->image_resize = true;\n\$foo->image_ratio_crop = true;\n\$foo->image_y = 50;\n\$foo->image_x = 50;"); + + // ----------- + $handle->image_resize = true; + $handle->image_ratio_crop = 'L'; + $handle->image_y = 50; + $handle->image_x = 50; + TestProcess($handle, '50x50, keeping ratio, cropping right excedent', "\$foo->image_resize = true;\n\$foo->image_ratio_crop = 'L';\n\$foo->image_y = 50;\n\$foo->image_x = 50;"); + + // ----------- + $handle->image_resize = true; + $handle->image_ratio_crop = 'R'; + $handle->image_y = 50; + $handle->image_x = 50; + TestProcess($handle, '50x50, keeping ratio, cropping left excedent', "\$foo->image_resize = true;\n\$foo->image_ratio_crop = 'R';\n\$foo->image_y = 50;\n\$foo->image_x = 50;"); + + // ----------- + $handle->image_resize = true; + $handle->image_ratio_fill = true; + $handle->image_y = 50; + $handle->image_x = 150; + TestProcess($handle, '150x50, keeping ratio, filling in', "\$foo->image_resize = true;\n\$foo->image_ratio_fill = true;\n\$foo->image_y = 50;\n\$foo->image_x = 150;"); + + // ----------- + $handle->image_resize = true; + $handle->image_ratio_fill = 'L'; + $handle->image_y = 50; + $handle->image_x = 150; + TestProcess($handle, '150x50, keeping ratio, filling left side', "\$foo->image_resize = true;\n\$foo->image_ratio_fill = 'L';\n\$foo->image_y = 50;\n\$foo->image_x = 150;"); + + // ----------- + $handle->image_resize = true; + $handle->image_ratio_fill = 'R'; + $handle->image_y = 150; + $handle->image_x = 100; + $handle->image_background_color = '#FF00FF'; + TestProcess($handle, '100x150, keeping ratio, filling top and bottom', "\$foo->image_resize = true;\n\$foo->image_ratio_fill = 'R';\n\$foo->image_y = 150;\n\$foo->image_x = 100;\n\$foo->image_background_color = '#FF00FF';"); + + // ----------- + $handle->image_resize = true; + $handle->image_ratio_crop = true; + $handle->image_y = 50; + $handle->image_x = 50; + $handle->image_crop = '0 10'; + TestProcess($handle, 'height 50, width 50, cropped, using ratio_crop', "\$foo->image_resize = true;\n\$foo->image_ratio_crop = true;\n\$foo->image_crop = '0 10';\n\$foo->image_y = 50;\n\$foo->image_x = 50;"); + + // ----------- + $handle->image_resize = true; + $handle->image_ratio_pixels = 25000; + TestProcess($handle, 'calculates x and y, targeting 25000 pixels', "\$foo->image_resize = true;\n\$foo->image_ratio_pixels = 25000;"); + + // ----------- + $handle->image_resize = true; + $handle->image_ratio_pixels = 10000; + TestProcess($handle, 'calculates x and y, targeting 10000 pixels', "\$foo->image_resize = true;\n\$foo->image_ratio_pixels = 10000;"); + + // ----------- + $handle->image_crop = '20%'; + TestProcess($handle, '20% crop', "\$foo->image_crop = '20%';"); + + // ----------- + $handle->image_crop = '5 20%'; + TestProcess($handle, '5px vertical and 20% horizontal crop', "\$foo->image_crop = '5 20%';"); + + // ----------- + $handle->image_crop = '-3px -10%'; + $handle->image_background_color = '#FF00FF'; + TestProcess($handle, 'negative crop with a background color', "\$foo->image_crop = '-3px -10%';\n\$foo->image_background_color = '#FF00FF';"); + + // ----------- + $handle->image_crop = '5 40 10% -20'; + TestProcess($handle, '5px top, 40px right, 10% bot. and -20px left crop', "\$foo->image_crop = '5 40 10% -20';"); + + // ----------- + $handle->image_resize = true; + $handle->image_ratio_y = true; + $handle->image_x = 150; + $handle->image_precrop = 15; + TestProcess($handle, '15px pre-cropping (before resizing 150 wide)', "\$foo->image_resize = true;\n\$foo->image_ratio_y = true;\n\$foo->image_x = 150;\n\$foo->image_precrop = 15;"); + + // ----------- + $handle->image_resize = true; + $handle->image_ratio_y = true; + $handle->image_x = 150; + $handle->image_precrop = '25 70 10% -20'; + TestProcess($handle, 'diverse pre-cropping (before resizing 150 wide)', "\$foo->image_resize = true;\n\$foo->image_ratio_y = true;\n\$foo->image_x = 150;\n\$foo->image_precrop = '25 70 10% -20';"); + + // ----------- + $handle->image_rotate = '90'; + TestProcess($handle, '90 degrees rotation', "\$foo->image_rotate = '90';"); + + // ----------- + $handle->image_rotate = '180'; + TestProcess($handle, '180 degrees rotation', "\$foo->image_rotate = '180';"); + + // ----------- + $handle->image_convert = 'webp'; + $handle->image_flip = 'H'; + TestProcess($handle, 'horizontal flip, into WEBP file', "\$foo->image_convert = 'webp';\n\$foo->image_flip = 'H';"); + + // ----------- + $handle->image_convert = 'gif'; + $handle->image_flip = 'V'; + TestProcess($handle, 'vertical flip, into GIF file', "\$foo->image_convert = 'gif';\n\$foo->image_flip = 'V';"); + + // ----------- + $handle->image_convert = 'bmp'; + $handle->image_default_color = '#00FF00'; + $handle->image_rotate = '180'; + TestProcess($handle, '180 degrees rotation, into BMP, green bg', "\$foo->image_convert = 'bmp';\n\$foo->image_default_color = '#00FF00';\n\$foo->image_rotate = '180';"); + + // ----------- + $handle->image_convert = 'png'; + $handle->image_flip = 'H'; + $handle->image_rotate = '90'; + TestProcess($handle, '90 degrees rotation and horizontal flip, into PNG', "\$foo->image_convert = 'png';\n\$foo->image_flip = 'H';\n\$foo->image_rotate = '90';"); + + // ----------- + $handle->image_bevel = 20; + $handle->image_bevel_color1 = '#FFFFFF'; + $handle->image_bevel_color2 = '#000000'; + TestProcess($handle, '20px black and white bevel', "\$foo->image_bevel = 20;\n\$foo->image_bevel_color1 = '#FFFFFF';\n\$foo->image_bevel_color2 = '#000000';"); + + // ----------- + $handle->image_bevel = 5; + $handle->image_bevel_color1 = '#FFFFFF'; + $handle->image_bevel_color2 = '#FFFFFF'; + TestProcess($handle, '5px white bevel (smooth border)', "\$foo->image_bevel = 5;\n\$foo->image_bevel_color1 = '#FFFFFF';\n\$foo->image_bevel_color2 = '#FFFFFF';"); + + // ----------- + $handle->image_border = 5; + $handle->image_border_color = '#FF0000'; + TestProcess($handle, '5px red border', "\$foo->image_border = 5;\n\$foo->image_border_color = '#FF0000';"); + + // ----------- + $handle->image_border = 5; + $handle->image_border_color = '#00FF00'; + $handle->image_border_opacity = 50; + TestProcess($handle, '5px green semi-transparent border', "\$foo->image_border = 5;\n\$foo->image_border_color = '#00FF00';\n\$foo->image_border_opacity = 50;"); + + // ----------- + $handle->image_border = '5 20 1 25%'; + $handle->image_border_color = '#0000FF'; + TestProcess($handle, '5px top, 20px right, 1px bot. and 25% left blue border', "\$foo->image_border = '5 20 1 25%';\n\$foo->image_border_color = '#0000FF';"); + + // ----------- + $handle->image_frame = 1; + $handle->image_frame_colors = '#FF0000 #FFFFFF #FFFFFF #0000FF'; + TestProcess($handle, 'flat colored frame, 4 px wide', "\$foo->image_frame = 1;\n\$foo->image_frame_colors = '#FF0000 #FFFFFF\n #FFFFFF #0000FF';"); + + // ----------- + $handle->image_frame = 2; + $handle->image_frame_colors = '#FFFFFF #BBBBBB #999999 #FF0000 #666666 #333333 #000000'; + TestProcess($handle, 'crossed colored frame, 7 px wide', "\$foo->image_frame = 2;\n\$foo->image_frame_colors = '#FFFFFF #BBBBBB\n #999999 #FF0000\n #666666 #333333\n #000000';"); + + // ----------- + $handle->image_frame = 1; + $handle->image_frame_colors = '#FF0000 #FF00FF #0000FF #000000'; + $handle->image_frame_opacity = 25; + TestProcess($handle, 'flat colored frame, 4 px wide, 25% opacity', "\$foo->image_frame = 1;\n\$foo->image_frame_colors = '#FF0000 #FF00FF\n #0000FF #000000';\n\$foo->image_frame_opacity = 25;"); + + // ----------- + $handle->image_border_transparent = 10; + TestProcess($handle, '10px fade-to-transparent border', "\$foo->image_border_transparent = 10;"); + + // ----------- + $handle->image_border_transparent = '10 50 20 60'; + TestProcess($handle, 'various fade-to-transparent borders', "\$foo->image_border_transparent = '10 50 20 60';"); + + // ----------- + $handle->image_border_transparent = array(0, 150, 0, 0); + TestProcess($handle, 'right fading-out to transparency mask', "\$foo->image_border_transparent = array(0, 150, 0, 0);"); + + // ----------- + $handle->image_overlay_color = '#FFFFFF'; + $handle->image_overlay_opacity = 50; + $handle->image_rotate = '180'; + $handle->image_tint_color = '#FF0000'; + TestProcess($handle, 'tint and 50% overlay and 180\' rotation', "\$foo->image_overlay_color = '#FFFFFF';\n\$foo->image_overlay_opacity = 50;\n\$foo->image_rotate = '180';\n\$foo->image_tint_color = '#FF0000';"); + + // ----------- + $handle->image_tint_color = '#FF0000'; + TestProcess($handle, '#FF0000 tint', "\$foo->image_tint_color = '#FF0000';"); + + // ----------- + $handle->image_overlay_color = '#FF0000'; + $handle->image_overlay_opacity = 50; + TestProcess($handle, '50% overlay #FF0000', "\$foo->image_overlay_color = '#FF0000';\n\$foo->image_overlay_opacity = 50;"); + + // ----------- + $handle->image_overlay_color = '#0000FF'; + $handle->image_overlay_opacity = 5; + TestProcess($handle, '5% overlay #0000FF', "\$foo->image_overlay_color = '#0000FF';\n\$foo->image_overlay_opacity = 5;"); + + // ----------- + $handle->image_overlay_color = '#FFFFFF'; + $handle->image_overlay_opacity = 90; + TestProcess($handle, '90% overlay #FFFFFF', "\$foo->image_overlay_color = '#FFFFFF';\n\$foo->image_overlay_opacity = 90;"); + + // ----------- + $handle->image_brightness = 25; + TestProcess($handle, 'brightness 25', "\$foo->image_brightness = 25;"); + + // ----------- + $handle->image_brightness = -25; + TestProcess($handle, 'brightness -25', "\$foo->image_brightness = -25;"); + + // ----------- + $handle->image_contrast = 75; + TestProcess($handle, 'contrast 75', "\$foo->image_contrast = 75;"); + + // ----------- + $handle->image_opacity = 75; + TestProcess($handle, 'opacity 75', "\$foo->image_opacity = 75;"); + + // ----------- + $handle->image_opacity = 25; + TestProcess($handle, 'opacity 25', "\$foo->image_opacity = 25;"); + + // ----------- + $handle->image_threshold = 20; + TestProcess($handle, 'threshold filter', "\$foo->image_threshold = 20;"); + + // ----------- + $handle->image_greyscale = true; + TestProcess($handle, 'greyscale', "\$foo->image_greyscale = true;"); + + // ----------- + $handle->image_negative = true; + TestProcess($handle, 'negative', "\$foo->image_negative = true;"); + + // ----------- + TestProcess($handle, 'original file, again', ''); + + // ----------- + $handle->image_pixelate = 3; + TestProcess($handle, 'pixelate, 3px block size', "\$foo->image_pixelate = 3;"); + + // ----------- + $handle->image_pixelate = 10; + TestProcess($handle, 'pixelate, 10px block size', "\$foo->image_pixelate = 10;"); + + // ----------- + $handle->image_unsharp = true; + TestProcess($handle, 'unsharp mask, default values', "\$foo->image_unsharp = true;"); + + // ----------- + $handle->image_unsharp = true; + $handle->image_unsharp_amount = 200; + $handle->image_unsharp_radius = 1; + $handle->image_unsharp_threshold = 5; + TestProcess($handle, 'unsharp mask, different values', "\$foo->image_unsharp = true;\n\$foo->image_unsharp_amount = 200;\n\$foo->image_unsharp_radius = 1;\n\$foo->image_unsharp_threshold = 5;"); + + // ----------- + $handle->image_brightness = 75; + $handle->image_resize = true; + $handle->image_y = 200; + $handle->image_x = 100; + $handle->image_rotate = '90'; + $handle->image_overlay_color = '#FF0000'; + $handle->image_overlay_opacity = 50; + $handle->image_text = 'verot.net'; + $handle->image_text_color = '#0000FF'; + $handle->image_text_background = '#FFFFFF'; + $handle->image_text_position = 'BL'; + $handle->image_text_padding_x = 10; + $handle->image_text_padding_y = 2; + TestProcess($handle, 'brightness, resize, rotation, overlay & label', "\$foo->image_brightness = 75;\n\$foo->image_resize = true;\n\$foo->image_y = 200;\n\$foo->image_x = 100;\n\$foo->image_rotate = '90';\n\$foo->image_overlay_color = '#FF0000';\n\$foo->image_overlay_opacity = 50;\n\$foo->image_text = 'verot.net';\n\$foo->image_text_color = '#0000FF';\n\$foo->image_text_background = '#FFFFFF';\n\$foo->image_text_position = 'BL';\n\$foo->image_text_padding_x = 10;\n\$foo->image_text_padding_y = 2;"); + + // ----------- + $handle->image_text = 'verot.net'; + $handle->image_text_color = '#000000'; + $handle->image_text_opacity = 80; + $handle->image_text_background = '#FFFFFF'; + $handle->image_text_background_opacity = 70; + $handle->image_text_font = 5; + $handle->image_text_padding = 20; + TestProcess($handle, 'overlayed transparent label', "\$foo->image_text = 'verot.net';\n\$foo->image_text_color = '#000000';\n\$foo->image_text_opacity = 80;\n\$foo->image_text_background = '#FFFFFF';\n\$foo->image_text_background_opacity = 70;\n\$foo->image_text_font = 5;\n\$foo->image_text_padding = 20;"); + + // ----------- + $handle->image_text = 'verot.net'; + $handle->image_text_direction = 'v'; + $handle->image_text_background = '#000000'; + $handle->image_text_font = 2; + $handle->image_text_position = 'BL'; + $handle->image_text_padding_x = 2; + $handle->image_text_padding_y = 8; + TestProcess($handle, 'overlayed vertical plain label bottom left', "\$foo->image_text = 'verot.net';\n\$foo->image_text_direction = 'v';\n\$foo->image_text_background = '#000000';\n\$foo->image_text_font = 2;\n\$foo->image_text_position = 'BL';\n\$foo->image_text_padding_x = 2;\n\$foo->image_text_padding_y = 8;"); + + // ----------- + $handle->image_convert = 'bmp'; + $handle->image_text = 'verot.net'; + $handle->image_text_direction = 'v'; + $handle->image_text_color = '#FFFFFF'; + $handle->image_text_background = '#000000'; + $handle->image_text_background_opacity = 50; + $handle->image_text_padding = 5; + TestProcess($handle, 'overlayed vertical label, into BMP', "\$foo->image_convert = 'bmp';\n\$foo->image_text = 'verot.net';\n\$foo->image_text_direction = 'v';\n\$foo->image_text_color = '#FFFFFF';\n\$foo->image_text_background = '#000000';\n\$foo->image_text_background_opacity = 50;\n\$foo->image_text_padding = 5;"); + + // ----------- + $handle->image_text = 'verot.net'; + $handle->image_text_opacity = 50; + $handle->image_text_background = '#0000FF'; + $handle->image_text_x = -5; + $handle->image_text_y = -5; + $handle->image_text_padding = 5; + TestProcess($handle, 'overlayed label with absolute negative position', "\$foo->image_text = 'verot.net';\n\$foo->image_text_opacity = 50;\n\$foo->image_text_background = '#0000FF';\n\$foo->image_text_x = -5;\n\$foo->image_text_y = -5;\n\$foo->image_text_padding = 5;"); + + // ----------- + $handle->image_text = 'verot.net'; + $handle->image_text_background = '#0000FF'; + $handle->image_text_background_opacity = 25; + $handle->image_text_x = 5; + $handle->image_text_y = 5; + $handle->image_text_padding = 20; + TestProcess($handle, 'overlayed transparent label with absolute position', "\$foo->image_text = 'verot.net';\n\$foo->image_text_background = '#0000FF';\n\$foo->image_text_background_opacity = 25;\n\$foo->image_text_x = 5;\n\$foo->image_text_y = 5;\n\$foo->image_text_padding = 20;"); + + // ----------- + $handle->image_text = "verot.net\nclass\nupload"; + $handle->image_text_background = '#000000'; + $handle->image_text_background_opacity = 75; + $handle->image_text_font = 1; + $handle->image_text_padding = 10; + TestProcess($handle, 'text label with multiple lines and small font', "\$foo->image_text = \"verot.net\\nclass\\nupload\";\n\$foo->image_text_background = '#000000';\n\$foo->image_text_background_opacity = 75;\n\$foo->image_text_font = 1;\n\$foo->image_text_padding = 10;"); + + // ----------- + $handle->image_text = "verot.net\nclass\nupload"; + $handle->image_text_color = '#000000'; + $handle->image_text_background = '#FFFFFF'; + $handle->image_text_background_opacity = 60; + $handle->image_text_padding = 3; + $handle->image_text_font = 3; + $handle->image_text_alignment = 'R'; + $handle->image_text_direction = 'V'; + TestProcess($handle, 'vertical multi-lines text, right aligned', "\$foo->image_text = \"verot.net\\nclass\\nupload\";\n\$foo->image_text_color = '#000000';\n\$foo->image_text_background = '#FFFFFF';\n\$foo->image_text_background_opacity = 60;\n\$foo->image_text_padding = 3;\n\$foo->image_text_font = 3;\n\$foo->image_text_alignment = 'R';\n\$foo->image_text_direction = 'V';"); + + // ----------- + $handle->image_text = "verot.net\nclass\nupload"; + $handle->image_text_background = '#000000'; + $handle->image_text_background_opacity = 50; + $handle->image_text_padding = 10; + $handle->image_text_x = -5; + $handle->image_text_y = -5; + $handle->image_text_line_spacing = 10; + TestProcess($handle, 'text label with 10 pixels of line spacing', "\$foo->image_text = \"verot.net\\nclass\\nupload\";\n\$foo->image_text_background = '#000000';\n\$foo->image_text_background_opacity = 50;\n\$foo->image_text_padding = 10;\n\$foo->image_text_x = -5;\n\$foo->image_text_y = -5;\n\$foo->image_text_line_spacing = 10;"); + + // ----------- + $handle->image_unsharp = true; + $handle->image_border = '0 0 16 0'; + $handle->image_border_color = '#000000'; + $handle->image_text = 'verot.net'; + $handle->image_text_font = 2; + $handle->image_text_position = 'B'; + $handle->image_text_padding_y = 2; + TestProcess($handle, 'text label in a black line, plus unsharp mask', "\$foo->image_unsharp = true;\n\$foo->image_border = '0 0 16 0';\n\$foo->image_border_color = '#000000';\n\$foo->image_text = \"verot.net\";\n\$foo->image_text_font = 2;\n\$foo->image_text_position = 'B';\n\$foo->image_text_padding_y = 2;"); + + // ----------- + $handle->image_crop = '-3 -3 -30 -3'; + $handle->image_text = '[dst_name] [dst_x]x[dst_y]'; + $handle->image_text_background = '#6666ff'; + $handle->image_text_color = '#ffffff'; + $handle->image_background_color = '#000099'; + $handle->image_text_font = 2; + $handle->image_text_y = -7; + $handle->image_text_padding_x = 3; + $handle->image_text_padding_y = 2; + TestProcess($handle, 'using tokens in text labels', "\$foo->image_crop = '-3 -3 -30 -3';\n\$foo->image_text = \"[dst_name] [dst_x]x[dst_y]\";\n\$foo->image_text_background = '#6666ff';\n\$foo->image_text_color = '#ffffff';\n\$foo->image_background_color= '#000099';\n\$foo->image_text_font = 2;\n\$foo->image_text_y = -7;\n\$foo->image_text_padding_x = 3;\n\$foo->image_text_padding_y = 2;"); + + // ----------- + $handle->image_crop = '-15 -15 -240 -15'; + $handle->image_text = "token value\n------------- ------------------\nsrc_name [src_name]\nsrc_name_body [src_name_body]\nsrc_name_ext [src_name_ext]\nsrc_pathname [src_pathname]\nsrc_mime [src_mime]\nsrc_type [src_type]\nsrc_bits [src_bits]\nsrc_pixels [src_pixels]\nsrc_size [src_size]\nsrc_size_kb [src_size_kb]\nsrc_size_mb [src_size_mb]\nsrc_size_human [src_size_human]\nsrc_x [src_x]\nsrc_y [src_y]\ndst_path [dst_path]\ndst_name_body [dst_name_body]\ndst_name_ext [dst_name_ext]\ndst_name [dst_name]\ndst_pathname [dst_pathname]\ndst_x [dst_x]\ndst_y [dst_y]\ndate [date]\ntime [time]\nhost [host]\nserver [server]\nip [ip]\ngd_version [gd_version]"; + $handle->image_text_alignment = 'L'; + $handle->image_text_font = 1; + $handle->image_text_position = 'B'; + $handle->image_text_padding_y = 5; + $handle->image_text_color = '#000000'; + TestProcess($handle, 'all the tokens available', "\$foo->image_crop = '-15 -15 -240 -15';\n\$foo->image_text = \n \"token value\\n\n ------------- ------------------\\n\n src_name [src_name]\\n\n src_name_body [src_name_body]\\n\n src_name_ext [src_name_ext]\\n\n src_pathname [src_pathname]\\n\n src_mime [src_mime]\\n\n src_type [src_type]\\n\n src_bits [src_bits]\\n\n src_pixels [src_pixels]\\n\n src_size [src_size]\\n\n src_size_kb [src_size_kb]\\n\n src_size_mb [src_size_mb]\\n\n src_size_human [src_size_human]\\n\n src_x [src_x]\\n\n src_y [src_y]\\n\n dst_path [dst_path]\\n\n dst_name_body [dst_name_body]\\n\n dst_name_ext [dst_name_ext]\\n\n dst_name [dst_name]\\n\n dst_pathname [dst_pathname]\\n\n dst_x [dst_x]\\n\n dst_y [dst_y]\\n\n date [date]\\n\n time [time]\\n\n host [host]\\n\n server [server]\\n\n ip [ip]\\n\n gd_version [gd_version]\";\n\$foo->image_text_alignment = 'L';\n\$foo->image_text_font = 1;\n\$foo->image_text_position = 'B';\n\$foo->image_text_padding_y = 5;\n\$foo->image_text_color = '#000000';"); + + // ----------- + $handle->image_text = "verot.net\nclass\nupload"; + $handle->image_text_background = '#000000'; + $handle->image_text_padding = 10; + $handle->image_text_font = "./foo.gdf"; + $handle->image_text_line_spacing = 2; + TestProcess($handle, 'text label with external GDF font', "\$foo->image_text = \"verot.net\\nclass\\nupload\";\n\$foo->image_text_background = '#000000';\n\$foo->image_text_padding = 10;\n\$foo->image_text_font = \"./foo.gdf\";\n\$foo->image_text_line_spacing = 2;"); + + // ----------- + $handle->image_text = "PHP"; + $handle->image_text_color = '#FFFF00'; + $handle->image_text_background = '#FF0000'; + $handle->image_text_padding = 10; + $handle->image_text_font = "./foo.gdf"; + TestProcess($handle, 'text label with external GDF font', "\$foo->image_text = 'PHP';\n\$foo->image_text_color = '#FFFF00';\n\$foo->image_text_background = '#FF0000';\n\$foo->image_text_padding = 10;\n\$foo->image_text_font = \"./foo.gdf\";"); + + // ----------- + $handle->image_text = "àzértyuïôp"; + $handle->image_text_background = '#000000'; + $handle->image_text_padding = 10; + $handle->image_text_font = "./foo.ttf"; + TestProcess($handle, 'UTF-8 text label with external TTF font', "\$foo->image_text = \"àzértyuïôp\";\n\$foo->image_text_background = '#000000';\n\$foo->image_text_padding = 10;\n\$foo->image_text_font = \"./foo.ttf\";"); + + // ----------- + $handle->image_text = "άλφα\nβήτα"; + $handle->image_text_color = '#0033CC'; + $handle->image_text_size = 28; + $handle->image_text_font = "./foo.ttf"; + $handle->image_overlay_color = '#FFFFFF'; + $handle->image_overlay_opacity = 75; + TestProcess($handle, 'UTF-8 text label with external TTF font', "\$foo->image_text = \"άλφα\\nβήτα\";\n\$foo->image_text_color = '#0033CC';\n\$foo->image_text_size = 28;\n\$foo->image_text_font = \"./foo.ttf\";\n\$foo->image_overlay_color = '#FFFFFF';\n\$foo->image_overlay_opacity = 75;"); + + // ----------- + $handle->image_text = "люблю"; + $handle->image_text_background = '#000000'; + $handle->image_text_padding = 10; + $handle->image_text_size = 20; + $handle->image_text_angle = 20; + $handle->image_text_font = "./foo.ttf"; + TestProcess($handle, 'UTF-8 text label with external TTF font', "\$foo->image_text = \"люблю\";\n\$foo->image_text_background = '#000000';\n\$foo->image_text_size = 20;\n\$foo->image_text_angle = 20;\n\$foo->image_text_padding = 10;\n\$foo->image_text_font = \"./foo.ttf\";"); + + // ----------- + $handle->image_reflection_height = '40px'; + TestProcess($handle, '40px reflection', "\$foo->image_reflection_height = '40px';"); + + // ----------- + $handle->image_reflection_height = '50%'; + $handle->image_text = "verot.net\nclass\nupload"; + $handle->image_text_background = '#000000'; + $handle->image_text_padding = 10; + $handle->image_text_line_spacing = 10; + TestProcess($handle, 'text label and 50% reflection', "\$foo->image_text = \"verot.net\\nclass\\nupload\";\n\$foo->image_text_background = '#000000';\n\$foo->image_text_padding = 10;\n\$foo->image_text_line_spacing = 10;\n\$foo->image_reflection_height = '50%';"); + + // ----------- + $handle->image_convert = 'jpg'; + $handle->image_reflection_height = '40px'; + $handle->image_reflection_space = 10; + TestProcess($handle, '40px reflection and 10 pixels space, into JPEG', "\$foo->image_convert = 'jpg';\n\$foo->image_reflection_height = '40px';\n\$foo->image_reflection_space = 10;"); + + // ----------- + $handle->image_reflection_height = 60; + $handle->image_reflection_space = -40; + TestProcess($handle, '60px reflection and -40 pixels space', "\$foo->image_reflection_height = 60;\n\$foo->image_reflection_space = -40;"); + + // ----------- + $handle->image_reflection_height = 50; + $handle->image_reflection_opacity = 100; + TestProcess($handle, '50px reflection and 100% opacity', "\$foo->image_reflection_height = 50;\n\$foo->image_reflection_opacity = 100;"); + + // ----------- + $handle->image_reflection_height = 50; + $handle->image_reflection_opacity = 20; + TestProcess($handle, '50px reflection and 20% opacity', "\$foo->image_reflection_height = 50;\n\$foo->image_reflection_opacity = 20;"); + + // ----------- + $handle->image_reflection_height = '50%'; + $handle->image_default_color = '#000000'; + TestProcess($handle, '50% reflection, black background', "\$foo->image_reflection_height = '50%';\n\$foo->image_default_color = '#000000';"); + + // ----------- + $handle->image_convert = 'gif'; + $handle->image_reflection_height = '50%'; + $handle->image_default_color = '#FF00FF'; + TestProcess($handle, '50% reflection, pink background, into GIF', "\$foo->image_convert = 'gif';\n\$foo->image_reflection_height = '50%';\n\$foo->image_default_color = '#000000';"); + + // ----------- + $handle->image_watermark = "watermark.png"; + TestProcess($handle, 'overlayed watermark (alpha transparent PNG)', "\$foo->image_watermark = 'watermark.png';"); + + // ----------- + $handle->image_watermark = "watermark.png"; + $handle->image_watermark_position = 'R'; + TestProcess($handle, 'overlayed watermark, right position', "\$foo->image_watermark = 'watermark.png';\n\$foo->image_watermark_position = 'R;"); + + // ----------- + $handle->image_watermark = "watermark.png"; + $handle->image_watermark_x = 10; + $handle->image_watermark_y = 10; + $handle->image_greyscale = true; + TestProcess($handle, 'watermark on greyscale pic, absolute position', "\$foo->image_watermark = 'watermark.png';\n\$foo->image_watermark_x = 10;\n\$foo->image_watermark_y = 10;\n\$foo->image_greyscale = true;"); + + // ----------- + $handle->image_watermark = "watermark.png"; + $handle->image_watermark_no_zoom_in = false; + TestProcess($handle, 'watermark, automatic up-resizing activated', "\$foo->image_watermark = 'watermark.png';\n\$foo->image_watermark_no_zoom_in = false;"); + + // ----------- + $handle->image_watermark = "watermark_large.png"; + TestProcess($handle, 'large watermark automatically reduced (default)', "\$foo->image_watermark = 'watermark_large.png';"); + + // ----------- + $handle->image_watermark = "watermark_large.png"; + $handle->image_watermark_no_zoom_out = true; + TestProcess($handle, 'large watermark, automatic down-resizing deactivated', "\$foo->image_watermark = 'watermark_large.png';\n\$foo->image_watermark_no_zoom_out = true;"); + + // ----------- + $handle->image_watermark = "watermark_large.png"; + $handle->image_watermark_no_zoom_out = true; + $handle->image_watermark_position = 'TL'; + TestProcess($handle, 'large watermark, down-resizing deactivated, position top-left', "\$foo->image_watermark = 'watermark_large.png';\n\$foo->image_watermark_no_zoom_out = true;\n\$foo->image_watermark_position = 'TL'"); + + // ----------- + $handle->image_watermark = "watermark_large.png"; + $handle->image_watermark_x = 20; + $handle->image_watermark_y = -20; + TestProcess($handle, 'large watermark automatically reduced, position 20 -20', "\$foo->image_watermark = 'watermark_large.png';\n\$foo->image_watermark_x = 20;\n\$foo->image_watermark_y = -20;"); + + // ----------- + $handle->image_convert = 'jpg'; + $handle->jpeg_size = 3072; + TestProcess($handle, 'desired JPEG size set to 3KB', "\$foo->image_convert = 'jpg';\n\$foo->jpeg_size = 3072;"); + + // ----------- + $handle->image_convert = 'jpg'; + $handle->jpeg_quality = 10; + TestProcess($handle, 'JPG quality set to 10%', "\$foo->image_convert = 'jpg';\n\$foo->jpeg_quality = 10;"); + + // ----------- + $handle->image_convert = 'jpg'; + $handle->jpeg_quality = 80; + TestProcess($handle, 'JPG quality set to 80%', "\$foo->image_convert = 'jpg';\n\$foo->jpeg_quality = 80;"); + + // ----------- + $handle->image_convert = 'png'; + $handle->png_compression = 0; + TestProcess($handle, 'PNG compression set to 0 (fast, large files)', "\$foo->image_convert = 'png';\n\$foo->png_compression = 0;"); + + // ----------- + $handle->image_convert = 'png'; + $handle->png_compression = 9; + TestProcess($handle, 'PNG compression set to 9 (slow, smaller files)', "\$foo->image_convert = 'png';\n\$foo->png_compression = 9;"); + + // ----------- + $handle->image_convert = 'webp'; + $handle->webp_quality = 10; + TestProcess($handle, 'WEBP quality set to 10%', "\$foo->image_convert = 'webp';\n\$foo->webp_quality = 10;"); + + // ----------- + $handle->image_convert = 'webp'; + $handle->webp_quality = 80; + TestProcess($handle, 'WEBP quality set to 80%', "\$foo->image_convert = 'webp';\n\$foo->webp_quality = 80;"); + + + } else { + // if we are here, the local file failed for some reasons + echo 'local file error
'; + echo 'Error: ' . $handle->error . ''; + } + + $log .= $handle->log . '
'; +} + +echo '

do another test

'; + +if ($log) echo '
' . $log . '
'; + +?> + + + diff --git a/vendor/verot/class.upload.php/test/watermark.png b/vendor/verot/class.upload.php/test/watermark.png new file mode 100644 index 0000000..984a995 Binary files /dev/null and b/vendor/verot/class.upload.php/test/watermark.png differ diff --git a/vendor/verot/class.upload.php/test/watermark_large.png b/vendor/verot/class.upload.php/test/watermark_large.png new file mode 100644 index 0000000..a7e9c90 Binary files /dev/null and b/vendor/verot/class.upload.php/test/watermark_large.png differ diff --git a/vendor/vlucas/phpdotenv/LICENSE b/vendor/vlucas/phpdotenv/LICENSE new file mode 100644 index 0000000..922c552 --- /dev/null +++ b/vendor/vlucas/phpdotenv/LICENSE @@ -0,0 +1,30 @@ +BSD 3-Clause License + +Copyright (c) 2014, Graham Campbell. +Copyright (c) 2013, Vance Lucas. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/vlucas/phpdotenv/composer.json b/vendor/vlucas/phpdotenv/composer.json new file mode 100644 index 0000000..d7a1e8c --- /dev/null +++ b/vendor/vlucas/phpdotenv/composer.json @@ -0,0 +1,53 @@ +{ + "name": "vlucas/phpdotenv", + "description": "Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.", + "keywords": ["env", "dotenv", "environment"], + "license": "BSD-3-Clause", + "authors": [ + { + "name": "Graham Campbell", + "email": "graham@alt-three.com", + "homepage": "https://gjcampbell.co.uk/" + }, + { + "name": "Vance Lucas", + "email": "vance@vancelucas.com", + "homepage": "https://vancelucas.com/" + } + ], + "require": { + "php": "^7.1.3 || ^8.0", + "ext-pcre": "*", + "graham-campbell/result-type": "^1.0.1", + "phpoption/phpoption": "^1.7.4", + "symfony/polyfill-ctype": "^1.17", + "symfony/polyfill-mbstring": "^1.17", + "symfony/polyfill-php80": "^1.17" + }, + "require-dev": { + "ext-filter": "*", + "bamarni/composer-bin-plugin": "^1.4.1", + "phpunit/phpunit": "^7.5.20 || ^8.5.14 || ^9.5.1" + }, + "autoload": { + "psr-4": { + "Dotenv\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "Dotenv\\Tests\\": "tests/Dotenv/" + } + }, + "suggest": { + "ext-filter": "Required to use the boolean validator." + }, + "config": { + "preferred-install": "dist" + }, + "extra": { + "branch-alias": { + "dev-master": "5.3-dev" + } + } +} diff --git a/vendor/vlucas/phpdotenv/src/Dotenv.php b/vendor/vlucas/phpdotenv/src/Dotenv.php new file mode 100644 index 0000000..0460ced --- /dev/null +++ b/vendor/vlucas/phpdotenv/src/Dotenv.php @@ -0,0 +1,267 @@ +store = $store; + $this->parser = $parser; + $this->loader = $loader; + $this->repository = $repository; + } + + /** + * Create a new dotenv instance. + * + * @param \Dotenv\Repository\RepositoryInterface $repository + * @param string|string[] $paths + * @param string|string[]|null $names + * @param bool $shortCircuit + * @param string|null $fileEncoding + * + * @return \Dotenv\Dotenv + */ + public static function create(RepositoryInterface $repository, $paths, $names = null, bool $shortCircuit = true, string $fileEncoding = null) + { + $builder = $names === null ? StoreBuilder::createWithDefaultName() : StoreBuilder::createWithNoNames(); + + foreach ((array) $paths as $path) { + $builder = $builder->addPath($path); + } + + foreach ((array) $names as $name) { + $builder = $builder->addName($name); + } + + if ($shortCircuit) { + $builder = $builder->shortCircuit(); + } + + return new self($builder->fileEncoding($fileEncoding)->make(), new Parser(), new Loader(), $repository); + } + + /** + * Create a new mutable dotenv instance with default repository. + * + * @param string|string[] $paths + * @param string|string[]|null $names + * @param bool $shortCircuit + * @param string|null $fileEncoding + * + * @return \Dotenv\Dotenv + */ + public static function createMutable($paths, $names = null, bool $shortCircuit = true, string $fileEncoding = null) + { + $repository = RepositoryBuilder::createWithDefaultAdapters()->make(); + + return self::create($repository, $paths, $names, $shortCircuit, $fileEncoding); + } + + /** + * Create a new mutable dotenv instance with default repository with the putenv adapter. + * + * @param string|string[] $paths + * @param string|string[]|null $names + * @param bool $shortCircuit + * @param string|null $fileEncoding + * + * @return \Dotenv\Dotenv + */ + public static function createUnsafeMutable($paths, $names = null, bool $shortCircuit = true, string $fileEncoding = null) + { + $repository = RepositoryBuilder::createWithDefaultAdapters() + ->addAdapter(PutenvAdapter::class) + ->make(); + + return self::create($repository, $paths, $names, $shortCircuit, $fileEncoding); + } + + /** + * Create a new immutable dotenv instance with default repository. + * + * @param string|string[] $paths + * @param string|string[]|null $names + * @param bool $shortCircuit + * @param string|null $fileEncoding + * + * @return \Dotenv\Dotenv + */ + public static function createImmutable($paths, $names = null, bool $shortCircuit = true, string $fileEncoding = null) + { + $repository = RepositoryBuilder::createWithDefaultAdapters()->immutable()->make(); + + return self::create($repository, $paths, $names, $shortCircuit, $fileEncoding); + } + + /** + * Create a new immutable dotenv instance with default repository with the putenv adapter. + * + * @param string|string[] $paths + * @param string|string[]|null $names + * @param bool $shortCircuit + * @param string|null $fileEncoding + * + * @return \Dotenv\Dotenv + */ + public static function createUnsafeImmutable($paths, $names = null, bool $shortCircuit = true, string $fileEncoding = null) + { + $repository = RepositoryBuilder::createWithDefaultAdapters() + ->addAdapter(PutenvAdapter::class) + ->immutable() + ->make(); + + return self::create($repository, $paths, $names, $shortCircuit, $fileEncoding); + } + + /** + * Create a new dotenv instance with an array backed repository. + * + * @param string|string[] $paths + * @param string|string[]|null $names + * @param bool $shortCircuit + * @param string|null $fileEncoding + * + * @return \Dotenv\Dotenv + */ + public static function createArrayBacked($paths, $names = null, bool $shortCircuit = true, string $fileEncoding = null) + { + $repository = RepositoryBuilder::createWithNoAdapters()->addAdapter(ArrayAdapter::class)->make(); + + return self::create($repository, $paths, $names, $shortCircuit, $fileEncoding); + } + + /** + * Parse the given content and resolve nested variables. + * + * This method behaves just like load(), only without mutating your actual + * environment. We do this by using an array backed repository. + * + * @param string $content + * + * @throws \Dotenv\Exception\InvalidFileException + * + * @return array + */ + public static function parse(string $content) + { + $repository = RepositoryBuilder::createWithNoAdapters()->addAdapter(ArrayAdapter::class)->make(); + + $phpdotenv = new self(new StringStore($content), new Parser(), new Loader(), $repository); + + return $phpdotenv->load(); + } + + /** + * Read and load environment file(s). + * + * @throws \Dotenv\Exception\InvalidPathException|\Dotenv\Exception\InvalidEncodingException|\Dotenv\Exception\InvalidFileException + * + * @return array + */ + public function load() + { + $entries = $this->parser->parse($this->store->read()); + + return $this->loader->load($this->repository, $entries); + } + + /** + * Read and load environment file(s), silently failing if no files can be read. + * + * @throws \Dotenv\Exception\InvalidEncodingException|\Dotenv\Exception\InvalidFileException + * + * @return array + */ + public function safeLoad() + { + try { + return $this->load(); + } catch (InvalidPathException $e) { + // suppressing exception + return []; + } + } + + /** + * Required ensures that the specified variables exist, and returns a new validator object. + * + * @param string|string[] $variables + * + * @return \Dotenv\Validator + */ + public function required($variables) + { + return (new Validator($this->repository, (array) $variables))->required(); + } + + /** + * Returns a new validator object that won't check if the specified variables exist. + * + * @param string|string[] $variables + * + * @return \Dotenv\Validator + */ + public function ifPresent($variables) + { + return new Validator($this->repository, (array) $variables); + } +} diff --git a/vendor/vlucas/phpdotenv/src/Exception/ExceptionInterface.php b/vendor/vlucas/phpdotenv/src/Exception/ExceptionInterface.php new file mode 100644 index 0000000..1e80f53 --- /dev/null +++ b/vendor/vlucas/phpdotenv/src/Exception/ExceptionInterface.php @@ -0,0 +1,12 @@ + + */ + public function load(RepositoryInterface $repository, array $entries) + { + return \array_reduce($entries, static function (array $vars, Entry $entry) use ($repository) { + $name = $entry->getName(); + + $value = $entry->getValue()->map(static function (Value $value) use ($repository) { + return Resolver::resolve($repository, $value); + }); + + if ($value->isDefined()) { + $inner = $value->get(); + if ($repository->set($name, $inner)) { + return \array_merge($vars, [$name => $inner]); + } + } else { + if ($repository->clear($name)) { + return \array_merge($vars, [$name => null]); + } + } + + return $vars; + }, []); + } +} diff --git a/vendor/vlucas/phpdotenv/src/Loader/LoaderInterface.php b/vendor/vlucas/phpdotenv/src/Loader/LoaderInterface.php new file mode 100644 index 0000000..275d98e --- /dev/null +++ b/vendor/vlucas/phpdotenv/src/Loader/LoaderInterface.php @@ -0,0 +1,20 @@ + + */ + public function load(RepositoryInterface $repository, array $entries); +} diff --git a/vendor/vlucas/phpdotenv/src/Loader/Resolver.php b/vendor/vlucas/phpdotenv/src/Loader/Resolver.php new file mode 100644 index 0000000..36d7a4b --- /dev/null +++ b/vendor/vlucas/phpdotenv/src/Loader/Resolver.php @@ -0,0 +1,65 @@ +getVars(), static function (string $s, int $i) use ($repository) { + return Str::substr($s, 0, $i).self::resolveVariable($repository, Str::substr($s, $i)); + }, $value->getChars()); + } + + /** + * Resolve a single nested variable. + * + * @param \Dotenv\Repository\RepositoryInterface $repository + * @param string $str + * + * @return string + */ + private static function resolveVariable(RepositoryInterface $repository, string $str) + { + return Regex::replaceCallback( + '/\A\${([a-zA-Z0-9_.]+)}/', + static function (array $matches) use ($repository) { + return Option::fromValue($repository->get($matches[1])) + ->getOrElse($matches[0]); + }, + $str, + 1 + )->success()->getOrElse($str); + } +} diff --git a/vendor/vlucas/phpdotenv/src/Parser/Entry.php b/vendor/vlucas/phpdotenv/src/Parser/Entry.php new file mode 100644 index 0000000..7570f58 --- /dev/null +++ b/vendor/vlucas/phpdotenv/src/Parser/Entry.php @@ -0,0 +1,59 @@ +name = $name; + $this->value = $value; + } + + /** + * Get the entry name. + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Get the entry value. + * + * @return \PhpOption\Option<\Dotenv\Parser\Value> + */ + public function getValue() + { + /** @var \PhpOption\Option<\Dotenv\Parser\Value> */ + return Option::fromValue($this->value); + } +} diff --git a/vendor/vlucas/phpdotenv/src/Parser/EntryParser.php b/vendor/vlucas/phpdotenv/src/Parser/EntryParser.php new file mode 100644 index 0000000..5cfa3ee --- /dev/null +++ b/vendor/vlucas/phpdotenv/src/Parser/EntryParser.php @@ -0,0 +1,293 @@ + + */ + public static function parse(string $entry) + { + return self::splitStringIntoParts($entry)->flatMap(static function (array $parts) { + [$name, $value] = $parts; + + return self::parseName($name)->flatMap(static function (string $name) use ($value) { + /** @var Result */ + $parsedValue = $value === null ? Success::create(null) : self::parseValue($value); + + return $parsedValue->map(static function (?Value $value) use ($name) { + return new Entry($name, $value); + }); + }); + }); + } + + /** + * Split the compound string into parts. + * + * @param string $line + * + * @return \GrahamCampbell\ResultType\Result + */ + private static function splitStringIntoParts(string $line) + { + /** @var array{string,string|null} */ + $result = Str::pos($line, '=')->map(static function () use ($line) { + return \array_map('trim', \explode('=', $line, 2)); + })->getOrElse([$line, null]); + + if ($result[0] === '') { + return Error::create(self::getErrorMessage('an unexpected equals', $line)); + } + + /** @var \GrahamCampbell\ResultType\Result */ + return Success::create($result); + } + + /** + * Parse the given variable name. + * + * That is, strip the optional quotes and leading "export" from the + * variable name. We wrap the answer in a result type. + * + * @param string $name + * + * @return \GrahamCampbell\ResultType\Result + */ + private static function parseName(string $name) + { + if (Str::len($name) > 8 && Str::substr($name, 0, 6) === 'export' && \ctype_space(Str::substr($name, 6, 1))) { + $name = \ltrim(Str::substr($name, 6)); + } + + if (self::isQuotedName($name)) { + $name = Str::substr($name, 1, -1); + } + + if (!self::isValidName($name)) { + return Error::create(self::getErrorMessage('an invalid name', $name)); + } + + return Success::create($name); + } + + /** + * Is the given variable name quoted? + * + * @param string $name + * + * @return bool + */ + private static function isQuotedName(string $name) + { + if (Str::len($name) < 3) { + return false; + } + + $first = Str::substr($name, 0, 1); + $last = Str::substr($name, -1, 1); + + return ($first === '"' && $last === '"') || ($first === '\'' && $last === '\''); + } + + /** + * Is the given variable name valid? + * + * @param string $name + * + * @return bool + */ + private static function isValidName(string $name) + { + return Regex::matches('~\A[a-zA-Z0-9_.]+\z~', $name)->success()->getOrElse(false); + } + + /** + * Parse the given variable value. + * + * This has the effect of stripping quotes and comments, dealing with + * special characters, and locating nested variables, but not resolving + * them. Formally, we run a finite state automaton with an output tape: a + * transducer. We wrap the answer in a result type. + * + * @param string $value + * + * @return \GrahamCampbell\ResultType\Result<\Dotenv\Parser\Value,string> + */ + private static function parseValue(string $value) + { + if (\trim($value) === '') { + return Success::create(Value::blank()); + } + + return \array_reduce(\iterator_to_array(Lexer::lex($value)), static function (Result $data, string $token) { + return $data->flatMap(static function (array $data) use ($token) { + return self::processToken($data[1], $token)->map(static function (array $val) use ($data) { + return [$data[0]->append($val[0], $val[1]), $val[2]]; + }); + }); + }, Success::create([Value::blank(), self::INITIAL_STATE]))->flatMap(static function (array $result) { + if (in_array($result[1], self::REJECT_STATES, true)) { + return Error::create('a missing closing quote'); + } + + return Success::create($result[0]); + })->mapError(static function (string $err) use ($value) { + return self::getErrorMessage($err, $value); + }); + } + + /** + * Process the given token. + * + * @param int $state + * @param string $token + * + * @return \GrahamCampbell\ResultType\Result + */ + private static function processToken(int $state, string $token) + { + switch ($state) { + case self::INITIAL_STATE: + if ($token === '\'') { + /** @var \GrahamCampbell\ResultType\Result */ + return Success::create(['', false, self::SINGLE_QUOTED_STATE]); + } elseif ($token === '"') { + /** @var \GrahamCampbell\ResultType\Result */ + return Success::create(['', false, self::DOUBLE_QUOTED_STATE]); + } elseif ($token === '#') { + /** @var \GrahamCampbell\ResultType\Result */ + return Success::create(['', false, self::COMMENT_STATE]); + } elseif ($token === '$') { + /** @var \GrahamCampbell\ResultType\Result */ + return Success::create([$token, true, self::UNQUOTED_STATE]); + } else { + /** @var \GrahamCampbell\ResultType\Result */ + return Success::create([$token, false, self::UNQUOTED_STATE]); + } + case self::UNQUOTED_STATE: + if ($token === '#') { + /** @var \GrahamCampbell\ResultType\Result */ + return Success::create(['', false, self::COMMENT_STATE]); + } elseif (\ctype_space($token)) { + /** @var \GrahamCampbell\ResultType\Result */ + return Success::create(['', false, self::WHITESPACE_STATE]); + } elseif ($token === '$') { + /** @var \GrahamCampbell\ResultType\Result */ + return Success::create([$token, true, self::UNQUOTED_STATE]); + } else { + /** @var \GrahamCampbell\ResultType\Result */ + return Success::create([$token, false, self::UNQUOTED_STATE]); + } + case self::SINGLE_QUOTED_STATE: + if ($token === '\'') { + /** @var \GrahamCampbell\ResultType\Result */ + return Success::create(['', false, self::WHITESPACE_STATE]); + } else { + /** @var \GrahamCampbell\ResultType\Result */ + return Success::create([$token, false, self::SINGLE_QUOTED_STATE]); + } + case self::DOUBLE_QUOTED_STATE: + if ($token === '"') { + /** @var \GrahamCampbell\ResultType\Result */ + return Success::create(['', false, self::WHITESPACE_STATE]); + } elseif ($token === '\\') { + /** @var \GrahamCampbell\ResultType\Result */ + return Success::create(['', false, self::ESCAPE_SEQUENCE_STATE]); + } elseif ($token === '$') { + /** @var \GrahamCampbell\ResultType\Result */ + return Success::create([$token, true, self::DOUBLE_QUOTED_STATE]); + } else { + /** @var \GrahamCampbell\ResultType\Result */ + return Success::create([$token, false, self::DOUBLE_QUOTED_STATE]); + } + case self::ESCAPE_SEQUENCE_STATE: + if ($token === '"' || $token === '\\') { + /** @var \GrahamCampbell\ResultType\Result */ + return Success::create([$token, false, self::DOUBLE_QUOTED_STATE]); + } elseif ($token === '$') { + /** @var \GrahamCampbell\ResultType\Result */ + return Success::create([$token, false, self::DOUBLE_QUOTED_STATE]); + } else { + $first = Str::substr($token, 0, 1); + if (\in_array($first, ['f', 'n', 'r', 't', 'v'], true)) { + /** @var \GrahamCampbell\ResultType\Result */ + return Success::create([\stripcslashes('\\'.$first).Str::substr($token, 1), false, self::DOUBLE_QUOTED_STATE]); + } else { + /** @var \GrahamCampbell\ResultType\Result */ + return Error::create('an unexpected escape sequence'); + } + } + case self::WHITESPACE_STATE: + if ($token === '#') { + /** @var \GrahamCampbell\ResultType\Result */ + return Success::create(['', false, self::COMMENT_STATE]); + } elseif (!\ctype_space($token)) { + /** @var \GrahamCampbell\ResultType\Result */ + return Error::create('unexpected whitespace'); + } else { + /** @var \GrahamCampbell\ResultType\Result */ + return Success::create(['', false, self::WHITESPACE_STATE]); + } + case self::COMMENT_STATE: + /** @var \GrahamCampbell\ResultType\Result */ + return Success::create(['', false, self::COMMENT_STATE]); + default: + throw new \Error('Parser entered invalid state.'); + } + } + + /** + * Generate a friendly error message. + * + * @param string $cause + * @param string $subject + * + * @return string + */ + private static function getErrorMessage(string $cause, string $subject) + { + return \sprintf( + 'Encountered %s at [%s].', + $cause, + \strtok($subject, "\n") + ); + } +} diff --git a/vendor/vlucas/phpdotenv/src/Parser/Lexer.php b/vendor/vlucas/phpdotenv/src/Parser/Lexer.php new file mode 100644 index 0000000..c5eb64d --- /dev/null +++ b/vendor/vlucas/phpdotenv/src/Parser/Lexer.php @@ -0,0 +1,62 @@ + + */ + public static function lex(string $content) + { + static $regex; + + if ($regex === null) { + $regex = '(('.\implode(')|(', self::PATTERNS).'))A'; + } + + $tokens = []; + + $offset = 0; + + while (isset($content[$offset])) { + if (!\preg_match($regex, $content, $matches, 0, $offset)) { + throw new \Error(\sprintf('Lexer encountered unexpected character [%s].', $content[$offset])); + } + + $offset += \strlen($matches[0]); + + yield $matches[0]; + } + } +} diff --git a/vendor/vlucas/phpdotenv/src/Parser/Lines.php b/vendor/vlucas/phpdotenv/src/Parser/Lines.php new file mode 100644 index 0000000..3839794 --- /dev/null +++ b/vendor/vlucas/phpdotenv/src/Parser/Lines.php @@ -0,0 +1,125 @@ +map(static function () use ($line) { + return self::looksLikeMultilineStop($line, true) === false; + })->getOrElse(false); + } + + /** + * Determine if the given line can be the start of a multiline variable. + * + * @param string $line + * @param bool $started + * + * @return bool + */ + private static function looksLikeMultilineStop(string $line, bool $started) + { + if ($line === '"') { + return true; + } + + return Regex::occurences('/(?=([^\\\\]"))/', \str_replace('\\\\', '', $line))->map(static function (int $count) use ($started) { + return $started ? $count > 1 : $count >= 1; + })->success()->getOrElse(false); + } + + /** + * Determine if the line in the file is a comment or whitespace. + * + * @param string $line + * + * @return bool + */ + private static function isCommentOrWhitespace(string $line) + { + $line = \trim($line); + + return $line === '' || (isset($line[0]) && $line[0] === '#'); + } +} diff --git a/vendor/vlucas/phpdotenv/src/Parser/Parser.php b/vendor/vlucas/phpdotenv/src/Parser/Parser.php new file mode 100644 index 0000000..3c115e5 --- /dev/null +++ b/vendor/vlucas/phpdotenv/src/Parser/Parser.php @@ -0,0 +1,52 @@ +mapError(static function () { + return 'Could not split into separate lines.'; + })->flatMap(static function (array $lines) { + return self::process(Lines::process($lines)); + })->mapError(static function (string $error) { + throw new InvalidFileException(\sprintf('Failed to parse dotenv file. %s', $error)); + })->success()->get(); + } + + /** + * Convert the raw entries into proper entries. + * + * @param string[] $entries + * + * @return \GrahamCampbell\ResultType\Result<\Dotenv\Parser\Entry[],string> + */ + private static function process(array $entries) + { + /** @var \GrahamCampbell\ResultType\Result<\Dotenv\Parser\Entry[],string> */ + return \array_reduce($entries, static function (Result $result, string $raw) { + return $result->flatMap(static function (array $entries) use ($raw) { + return EntryParser::parse($raw)->map(static function (Entry $entry) use ($entries) { + return \array_merge($entries, [$entry]); + }); + }); + }, Success::create([])); + } +} diff --git a/vendor/vlucas/phpdotenv/src/Parser/ParserInterface.php b/vendor/vlucas/phpdotenv/src/Parser/ParserInterface.php new file mode 100644 index 0000000..17cc42a --- /dev/null +++ b/vendor/vlucas/phpdotenv/src/Parser/ParserInterface.php @@ -0,0 +1,19 @@ +chars = $chars; + $this->vars = $vars; + } + + /** + * Create an empty value instance. + * + * @return \Dotenv\Parser\Value + */ + public static function blank() + { + return new self('', []); + } + + /** + * Create a new value instance, appending the characters. + * + * @param string $chars + * @param bool $var + * + * @return \Dotenv\Parser\Value + */ + public function append(string $chars, bool $var) + { + return new self( + $this->chars.$chars, + $var ? \array_merge($this->vars, [Str::len($this->chars)]) : $this->vars + ); + } + + /** + * Get the string representation of the parsed value. + * + * @return string + */ + public function getChars() + { + return $this->chars; + } + + /** + * Get the locations of the variables in the value. + * + * @return int[] + */ + public function getVars() + { + $vars = $this->vars; + + \rsort($vars); + + return $vars; + } +} diff --git a/vendor/vlucas/phpdotenv/src/Repository/Adapter/AdapterInterface.php b/vendor/vlucas/phpdotenv/src/Repository/Adapter/AdapterInterface.php new file mode 100644 index 0000000..5604398 --- /dev/null +++ b/vendor/vlucas/phpdotenv/src/Repository/Adapter/AdapterInterface.php @@ -0,0 +1,15 @@ + + */ + public static function create(); +} diff --git a/vendor/vlucas/phpdotenv/src/Repository/Adapter/ApacheAdapter.php b/vendor/vlucas/phpdotenv/src/Repository/Adapter/ApacheAdapter.php new file mode 100644 index 0000000..868033a --- /dev/null +++ b/vendor/vlucas/phpdotenv/src/Repository/Adapter/ApacheAdapter.php @@ -0,0 +1,89 @@ + + */ + public static function create() + { + if (self::isSupported()) { + /** @var \PhpOption\Option */ + return Some::create(new self()); + } + + return None::create(); + } + + /** + * Determines if the adapter is supported. + * + * This happens if PHP is running as an Apache module. + * + * @return bool + */ + private static function isSupported() + { + return \function_exists('apache_getenv') && \function_exists('apache_setenv'); + } + + /** + * Read an environment variable, if it exists. + * + * @param string $name + * + * @return \PhpOption\Option + */ + public function read(string $name) + { + /** @var \PhpOption\Option */ + return Option::fromValue(apache_getenv($name))->filter(static function ($value) { + return \is_string($value) && $value !== ''; + }); + } + + /** + * Write to an environment variable, if possible. + * + * @param string $name + * @param string $value + * + * @return bool + */ + public function write(string $name, string $value) + { + return apache_setenv($name, $value); + } + + /** + * Delete an environment variable, if possible. + * + * @param string $name + * + * @return bool + */ + public function delete(string $name) + { + return apache_setenv($name, ''); + } +} diff --git a/vendor/vlucas/phpdotenv/src/Repository/Adapter/ArrayAdapter.php b/vendor/vlucas/phpdotenv/src/Repository/Adapter/ArrayAdapter.php new file mode 100644 index 0000000..2881a7e --- /dev/null +++ b/vendor/vlucas/phpdotenv/src/Repository/Adapter/ArrayAdapter.php @@ -0,0 +1,80 @@ + + */ + private $variables; + + /** + * Create a new array adapter instance. + * + * @return void + */ + private function __construct() + { + $this->variables = []; + } + + /** + * Create a new instance of the adapter, if it is available. + * + * @return \PhpOption\Option<\Dotenv\Repository\Adapter\AdapterInterface> + */ + public static function create() + { + /** @var \PhpOption\Option */ + return Some::create(new self()); + } + + /** + * Read an environment variable, if it exists. + * + * @param string $name + * + * @return \PhpOption\Option + */ + public function read(string $name) + { + return Option::fromArraysValue($this->variables, $name); + } + + /** + * Write to an environment variable, if possible. + * + * @param string $name + * @param string $value + * + * @return bool + */ + public function write(string $name, string $value) + { + $this->variables[$name] = $value; + + return true; + } + + /** + * Delete an environment variable, if possible. + * + * @param string $name + * + * @return bool + */ + public function delete(string $name) + { + unset($this->variables[$name]); + + return true; + } +} diff --git a/vendor/vlucas/phpdotenv/src/Repository/Adapter/EnvConstAdapter.php b/vendor/vlucas/phpdotenv/src/Repository/Adapter/EnvConstAdapter.php new file mode 100644 index 0000000..9ef7fb4 --- /dev/null +++ b/vendor/vlucas/phpdotenv/src/Repository/Adapter/EnvConstAdapter.php @@ -0,0 +1,87 @@ + + */ + public static function create() + { + /** @var \PhpOption\Option */ + return Some::create(new self()); + } + + /** + * Read an environment variable, if it exists. + * + * @param string $name + * + * @return \PhpOption\Option + */ + public function read(string $name) + { + /** @var \PhpOption\Option */ + return Option::fromArraysValue($_ENV, $name) + ->map(static function ($value) { + if ($value === false) { + return 'false'; + } + + if ($value === true) { + return 'true'; + } + + return $value; + })->filter(static function ($value) { + return \is_string($value); + }); + } + + /** + * Write to an environment variable, if possible. + * + * @param string $name + * @param string $value + * + * @return bool + */ + public function write(string $name, string $value) + { + $_ENV[$name] = $value; + + return true; + } + + /** + * Delete an environment variable, if possible. + * + * @param string $name + * + * @return bool + */ + public function delete(string $name) + { + unset($_ENV[$name]); + + return true; + } +} diff --git a/vendor/vlucas/phpdotenv/src/Repository/Adapter/GuardedWriter.php b/vendor/vlucas/phpdotenv/src/Repository/Adapter/GuardedWriter.php new file mode 100644 index 0000000..7bb69e8 --- /dev/null +++ b/vendor/vlucas/phpdotenv/src/Repository/Adapter/GuardedWriter.php @@ -0,0 +1,85 @@ +writer = $writer; + $this->allowList = $allowList; + } + + /** + * Write to an environment variable, if possible. + * + * @param string $name + * @param string $value + * + * @return bool + */ + public function write(string $name, string $value) + { + // Don't set non-allowed variables + if (!$this->isAllowed($name)) { + return false; + } + + // Set the value on the inner writer + return $this->writer->write($name, $value); + } + + /** + * Delete an environment variable, if possible. + * + * @param string $name + * + * @return bool + */ + public function delete(string $name) + { + // Don't clear non-allowed variables + if (!$this->isAllowed($name)) { + return false; + } + + // Set the value on the inner writer + return $this->writer->delete($name); + } + + /** + * Determine if the given variable is allowed. + * + * @param string $name + * + * @return bool + */ + private function isAllowed(string $name) + { + return \in_array($name, $this->allowList, true); + } +} diff --git a/vendor/vlucas/phpdotenv/src/Repository/Adapter/ImmutableWriter.php b/vendor/vlucas/phpdotenv/src/Repository/Adapter/ImmutableWriter.php new file mode 100644 index 0000000..574fcd6 --- /dev/null +++ b/vendor/vlucas/phpdotenv/src/Repository/Adapter/ImmutableWriter.php @@ -0,0 +1,110 @@ + + */ + private $loaded; + + /** + * Create a new immutable writer instance. + * + * @param \Dotenv\Repository\Adapter\WriterInterface $writer + * @param \Dotenv\Repository\Adapter\ReaderInterface $reader + * + * @return void + */ + public function __construct(WriterInterface $writer, ReaderInterface $reader) + { + $this->writer = $writer; + $this->reader = $reader; + $this->loaded = []; + } + + /** + * Write to an environment variable, if possible. + * + * @param string $name + * @param string $value + * + * @return bool + */ + public function write(string $name, string $value) + { + // Don't overwrite existing environment variables + // Ruby's dotenv does this with `ENV[key] ||= value` + if ($this->isExternallyDefined($name)) { + return false; + } + + // Set the value on the inner writer + if (!$this->writer->write($name, $value)) { + return false; + } + + // Record that we have loaded the variable + $this->loaded[$name] = ''; + + return true; + } + + /** + * Delete an environment variable, if possible. + * + * @param string $name + * + * @return bool + */ + public function delete(string $name) + { + // Don't clear existing environment variables + if ($this->isExternallyDefined($name)) { + return false; + } + + // Clear the value on the inner writer + if (!$this->writer->delete($name)) { + return false; + } + + // Leave the variable as fair game + unset($this->loaded[$name]); + + return true; + } + + /** + * Determine if the given variable is externally defined. + * + * That is, is it an "existing" variable. + * + * @param string $name + * + * @return bool + */ + private function isExternallyDefined(string $name) + { + return $this->reader->read($name)->isDefined() && !isset($this->loaded[$name]); + } +} diff --git a/vendor/vlucas/phpdotenv/src/Repository/Adapter/MultiReader.php b/vendor/vlucas/phpdotenv/src/Repository/Adapter/MultiReader.php new file mode 100644 index 0000000..12b3bda --- /dev/null +++ b/vendor/vlucas/phpdotenv/src/Repository/Adapter/MultiReader.php @@ -0,0 +1,48 @@ +readers = $readers; + } + + /** + * Read an environment variable, if it exists. + * + * @param string $name + * + * @return \PhpOption\Option + */ + public function read(string $name) + { + foreach ($this->readers as $reader) { + $result = $reader->read($name); + if ($result->isDefined()) { + return $result; + } + } + + return None::create(); + } +} diff --git a/vendor/vlucas/phpdotenv/src/Repository/Adapter/MultiWriter.php b/vendor/vlucas/phpdotenv/src/Repository/Adapter/MultiWriter.php new file mode 100644 index 0000000..e1dcf56 --- /dev/null +++ b/vendor/vlucas/phpdotenv/src/Repository/Adapter/MultiWriter.php @@ -0,0 +1,64 @@ +writers = $writers; + } + + /** + * Write to an environment variable, if possible. + * + * @param string $name + * @param string $value + * + * @return bool + */ + public function write(string $name, string $value) + { + foreach ($this->writers as $writers) { + if (!$writers->write($name, $value)) { + return false; + } + } + + return true; + } + + /** + * Delete an environment variable, if possible. + * + * @param string $name + * + * @return bool + */ + public function delete(string $name) + { + foreach ($this->writers as $writers) { + if (!$writers->delete($name)) { + return false; + } + } + + return true; + } +} diff --git a/vendor/vlucas/phpdotenv/src/Repository/Adapter/PutenvAdapter.php b/vendor/vlucas/phpdotenv/src/Repository/Adapter/PutenvAdapter.php new file mode 100644 index 0000000..126c465 --- /dev/null +++ b/vendor/vlucas/phpdotenv/src/Repository/Adapter/PutenvAdapter.php @@ -0,0 +1,91 @@ + + */ + public static function create() + { + if (self::isSupported()) { + /** @var \PhpOption\Option */ + return Some::create(new self()); + } + + return None::create(); + } + + /** + * Determines if the adapter is supported. + * + * @return bool + */ + private static function isSupported() + { + return \function_exists('getenv') && \function_exists('putenv'); + } + + /** + * Read an environment variable, if it exists. + * + * @param string $name + * + * @return \PhpOption\Option + */ + public function read(string $name) + { + /** @var \PhpOption\Option */ + return Option::fromValue(\getenv($name), false)->filter(static function ($value) { + return \is_string($value); + }); + } + + /** + * Write to an environment variable, if possible. + * + * @param string $name + * @param string $value + * + * @return bool + */ + public function write(string $name, string $value) + { + \putenv("$name=$value"); + + return true; + } + + /** + * Delete an environment variable, if possible. + * + * @param string $name + * + * @return bool + */ + public function delete(string $name) + { + \putenv($name); + + return true; + } +} diff --git a/vendor/vlucas/phpdotenv/src/Repository/Adapter/ReaderInterface.php b/vendor/vlucas/phpdotenv/src/Repository/Adapter/ReaderInterface.php new file mode 100644 index 0000000..5ece5ee --- /dev/null +++ b/vendor/vlucas/phpdotenv/src/Repository/Adapter/ReaderInterface.php @@ -0,0 +1,17 @@ + + */ + public function read(string $name); +} diff --git a/vendor/vlucas/phpdotenv/src/Repository/Adapter/ReplacingWriter.php b/vendor/vlucas/phpdotenv/src/Repository/Adapter/ReplacingWriter.php new file mode 100644 index 0000000..326cd18 --- /dev/null +++ b/vendor/vlucas/phpdotenv/src/Repository/Adapter/ReplacingWriter.php @@ -0,0 +1,104 @@ + + */ + private $seen; + + /** + * Create a new replacement writer instance. + * + * @param \Dotenv\Repository\Adapter\WriterInterface $writer + * @param \Dotenv\Repository\Adapter\ReaderInterface $reader + * + * @return void + */ + public function __construct(WriterInterface $writer, ReaderInterface $reader) + { + $this->writer = $writer; + $this->reader = $reader; + $this->seen = []; + } + + /** + * Write to an environment variable, if possible. + * + * @param string $name + * @param string $value + * + * @return bool + */ + public function write(string $name, string $value) + { + if ($this->exists($name)) { + return $this->writer->write($name, $value); + } + + // succeed if nothing to do + return true; + } + + /** + * Delete an environment variable, if possible. + * + * @param string $name + * + * @return bool + */ + public function delete(string $name) + { + if ($this->exists($name)) { + return $this->writer->delete($name); + } + + // succeed if nothing to do + return true; + } + + /** + * Does the given environment variable exist. + * + * Returns true if it currently exists, or existed at any point in the past + * that we are aware of. + * + * @param string $name + * + * @return bool + */ + private function exists(string $name) + { + if (isset($this->seen[$name])) { + return true; + } + + if ($this->reader->read($name)->isDefined()) { + $this->seen[$name] = ''; + + return true; + } + + return false; + } +} diff --git a/vendor/vlucas/phpdotenv/src/Repository/Adapter/ServerConstAdapter.php b/vendor/vlucas/phpdotenv/src/Repository/Adapter/ServerConstAdapter.php new file mode 100644 index 0000000..8e3dc98 --- /dev/null +++ b/vendor/vlucas/phpdotenv/src/Repository/Adapter/ServerConstAdapter.php @@ -0,0 +1,87 @@ + + */ + public static function create() + { + /** @var \PhpOption\Option */ + return Some::create(new self()); + } + + /** + * Read an environment variable, if it exists. + * + * @param string $name + * + * @return \PhpOption\Option + */ + public function read(string $name) + { + /** @var \PhpOption\Option */ + return Option::fromArraysValue($_SERVER, $name) + ->map(static function ($value) { + if ($value === false) { + return 'false'; + } + + if ($value === true) { + return 'true'; + } + + return $value; + })->filter(static function ($value) { + return \is_string($value); + }); + } + + /** + * Write to an environment variable, if possible. + * + * @param string $name + * @param string $value + * + * @return bool + */ + public function write(string $name, string $value) + { + $_SERVER[$name] = $value; + + return true; + } + + /** + * Delete an environment variable, if possible. + * + * @param string $name + * + * @return bool + */ + public function delete(string $name) + { + unset($_SERVER[$name]); + + return true; + } +} diff --git a/vendor/vlucas/phpdotenv/src/Repository/Adapter/WriterInterface.php b/vendor/vlucas/phpdotenv/src/Repository/Adapter/WriterInterface.php new file mode 100644 index 0000000..8b3fa57 --- /dev/null +++ b/vendor/vlucas/phpdotenv/src/Repository/Adapter/WriterInterface.php @@ -0,0 +1,27 @@ +reader = $reader; + $this->writer = $writer; + } + + /** + * Determine if the given environment variable is defined. + * + * @param string $name + * + * @return bool + */ + public function has(string $name) + { + return $this->reader->read($name)->isDefined(); + } + + /** + * Get an environment variable. + * + * @param string $name + * + * @return string|null + */ + public function get(string $name) + { + return $this->reader->read($name)->getOrElse(null); + } + + /** + * Set an environment variable. + * + * @param string $name + * @param string $value + * + * @return bool + */ + public function set(string $name, string $value) + { + return $this->writer->write($name, $value); + } + + /** + * Clear an environment variable. + * + * @param string $name + * + * @return bool + */ + public function clear(string $name) + { + return $this->writer->delete($name); + } +} diff --git a/vendor/vlucas/phpdotenv/src/Repository/RepositoryBuilder.php b/vendor/vlucas/phpdotenv/src/Repository/RepositoryBuilder.php new file mode 100644 index 0000000..f8a9264 --- /dev/null +++ b/vendor/vlucas/phpdotenv/src/Repository/RepositoryBuilder.php @@ -0,0 +1,274 @@ +readers = $readers; + $this->writers = $writers; + $this->immutable = $immutable; + $this->allowList = $allowList; + } + + /** + * Create a new repository builder instance with no adapters added. + * + * @return \Dotenv\Repository\RepositoryBuilder + */ + public static function createWithNoAdapters() + { + return new self(); + } + + /** + * Create a new repository builder instance with the default adapters added. + * + * @return \Dotenv\Repository\RepositoryBuilder + */ + public static function createWithDefaultAdapters() + { + $adapters = \iterator_to_array(self::defaultAdapters()); + + return new self($adapters, $adapters); + } + + /** + * Return the array of default adapters. + * + * @return \Generator<\Dotenv\Repository\Adapter\AdapterInterface> + */ + private static function defaultAdapters() + { + foreach (self::DEFAULT_ADAPTERS as $adapter) { + $instance = $adapter::create(); + if ($instance->isDefined()) { + yield $instance->get(); + } + } + } + + /** + * Determine if the given name if of an adapaterclass. + * + * @param string $name + * + * @return bool + */ + private static function isAnAdapterClass(string $name) + { + if (!\class_exists($name)) { + return false; + } + + return (new ReflectionClass($name))->implementsInterface(AdapterInterface::class); + } + + /** + * Creates a repository builder with the given reader added. + * + * Accepts either a reader instance, or a class-string for an adapter. If + * the adapter is not supported, then we silently skip adding it. + * + * @param \Dotenv\Repository\Adapter\ReaderInterface|string $reader + * + * @throws \InvalidArgumentException + * + * @return \Dotenv\Repository\RepositoryBuilder + */ + public function addReader($reader) + { + if (!(\is_string($reader) && self::isAnAdapterClass($reader)) && !($reader instanceof ReaderInterface)) { + throw new InvalidArgumentException( + \sprintf( + 'Expected either an instance of %s or a class-string implementing %s', + ReaderInterface::class, + AdapterInterface::class + ) + ); + } + + $optional = Some::create($reader)->flatMap(static function ($reader) { + return \is_string($reader) ? $reader::create() : Some::create($reader); + }); + + $readers = \array_merge($this->readers, \iterator_to_array($optional)); + + return new self($readers, $this->writers, $this->immutable, $this->allowList); + } + + /** + * Creates a repository builder with the given writer added. + * + * Accepts either a writer instance, or a class-string for an adapter. If + * the adapter is not supported, then we silently skip adding it. + * + * @param \Dotenv\Repository\Adapter\WriterInterface|string $writer + * + * @throws \InvalidArgumentException + * + * @return \Dotenv\Repository\RepositoryBuilder + */ + public function addWriter($writer) + { + if (!(\is_string($writer) && self::isAnAdapterClass($writer)) && !($writer instanceof WriterInterface)) { + throw new InvalidArgumentException( + \sprintf( + 'Expected either an instance of %s or a class-string implementing %s', + WriterInterface::class, + AdapterInterface::class + ) + ); + } + + $optional = Some::create($writer)->flatMap(static function ($writer) { + return \is_string($writer) ? $writer::create() : Some::create($writer); + }); + + $writers = \array_merge($this->writers, \iterator_to_array($optional)); + + return new self($this->readers, $writers, $this->immutable, $this->allowList); + } + + /** + * Creates a repository builder with the given adapter added. + * + * Accepts either an adapter instance, or a class-string for an adapter. If + * the adapter is not supported, then we silently skip adding it. We will + * add the adapter as both a reader and a writer. + * + * @param \Dotenv\Repository\Adapter\WriterInterface|string $adapter + * + * @throws \InvalidArgumentException + * + * @return \Dotenv\Repository\RepositoryBuilder + */ + public function addAdapter($adapter) + { + if (!(\is_string($adapter) && self::isAnAdapterClass($adapter)) && !($adapter instanceof AdapterInterface)) { + throw new InvalidArgumentException( + \sprintf( + 'Expected either an instance of %s or a class-string implementing %s', + WriterInterface::class, + AdapterInterface::class + ) + ); + } + + $optional = Some::create($adapter)->flatMap(static function ($adapter) { + return \is_string($adapter) ? $adapter::create() : Some::create($adapter); + }); + + $readers = \array_merge($this->readers, \iterator_to_array($optional)); + $writers = \array_merge($this->writers, \iterator_to_array($optional)); + + return new self($readers, $writers, $this->immutable, $this->allowList); + } + + /** + * Creates a repository builder with mutability enabled. + * + * @return \Dotenv\Repository\RepositoryBuilder + */ + public function immutable() + { + return new self($this->readers, $this->writers, true, $this->allowList); + } + + /** + * Creates a repository builder with the given allow list. + * + * @param string[]|null $allowList + * + * @return \Dotenv\Repository\RepositoryBuilder + */ + public function allowList(array $allowList = null) + { + return new self($this->readers, $this->writers, $this->immutable, $allowList); + } + + /** + * Creates a new repository instance. + * + * @return \Dotenv\Repository\RepositoryInterface + */ + public function make() + { + $reader = new MultiReader($this->readers); + $writer = new MultiWriter($this->writers); + + if ($this->immutable) { + $writer = new ImmutableWriter($writer, $reader); + } + + if ($this->allowList !== null) { + $writer = new GuardedWriter($writer, $this->allowList); + } + + return new AdapterRepository($reader, $writer); + } +} diff --git a/vendor/vlucas/phpdotenv/src/Repository/RepositoryInterface.php b/vendor/vlucas/phpdotenv/src/Repository/RepositoryInterface.php new file mode 100644 index 0000000..a2a7d32 --- /dev/null +++ b/vendor/vlucas/phpdotenv/src/Repository/RepositoryInterface.php @@ -0,0 +1,45 @@ + + */ + public static function read(array $filePaths, bool $shortCircuit = true, string $fileEncoding = null) + { + $output = []; + + foreach ($filePaths as $filePath) { + $content = self::readFromFile($filePath, $fileEncoding); + if ($content->isDefined()) { + $output[$filePath] = $content->get(); + if ($shortCircuit) { + break; + } + } + } + + return $output; + } + + /** + * Read the given file. + * + * @param string $path + * @param string|null $encoding + * + * @throws \Dotenv\Exception\InvalidEncodingException + * + * @return \PhpOption\Option + */ + private static function readFromFile(string $path, string $encoding = null) + { + /** @var Option */ + $content = Option::fromValue(@\file_get_contents($path), false); + + return $content->flatMap(static function (string $content) use ($encoding) { + return Str::utf8($content, $encoding)->mapError(static function (string $error) { + throw new InvalidEncodingException($error); + })->success(); + }); + } +} diff --git a/vendor/vlucas/phpdotenv/src/Store/FileStore.php b/vendor/vlucas/phpdotenv/src/Store/FileStore.php new file mode 100644 index 0000000..43f6135 --- /dev/null +++ b/vendor/vlucas/phpdotenv/src/Store/FileStore.php @@ -0,0 +1,72 @@ +filePaths = $filePaths; + $this->shortCircuit = $shortCircuit; + $this->fileEncoding = $fileEncoding; + } + + /** + * Read the content of the environment file(s). + * + * @throws \Dotenv\Exception\InvalidEncodingException|\Dotenv\Exception\InvalidPathException + * + * @return string + */ + public function read() + { + if ($this->filePaths === []) { + throw new InvalidPathException('At least one environment file path must be provided.'); + } + + $contents = Reader::read($this->filePaths, $this->shortCircuit, $this->fileEncoding); + + if (\count($contents) > 0) { + return \implode("\n", $contents); + } + + throw new InvalidPathException( + \sprintf('Unable to read any of the environment file(s) at [%s].', \implode(', ', $this->filePaths)) + ); + } +} diff --git a/vendor/vlucas/phpdotenv/src/Store/StoreBuilder.php b/vendor/vlucas/phpdotenv/src/Store/StoreBuilder.php new file mode 100644 index 0000000..d1fb26f --- /dev/null +++ b/vendor/vlucas/phpdotenv/src/Store/StoreBuilder.php @@ -0,0 +1,143 @@ +paths = $paths; + $this->names = $names; + $this->shortCircuit = $shortCircuit; + $this->fileEncoding = $fileEncoding; + } + + /** + * Create a new store builder instance with no names. + * + * @return \Dotenv\Store\StoreBuilder + */ + public static function createWithNoNames() + { + return new self(); + } + + /** + * Create a new store builder instance with the default name. + * + * @return \Dotenv\Store\StoreBuilder + */ + public static function createWithDefaultName() + { + return new self([], [self::DEFAULT_NAME]); + } + + /** + * Creates a store builder with the given path added. + * + * @param string $path + * + * @return \Dotenv\Store\StoreBuilder + */ + public function addPath(string $path) + { + return new self(\array_merge($this->paths, [$path]), $this->names, $this->shortCircuit, $this->fileEncoding); + } + + /** + * Creates a store builder with the given name added. + * + * @param string $name + * + * @return \Dotenv\Store\StoreBuilder + */ + public function addName(string $name) + { + return new self($this->paths, \array_merge($this->names, [$name]), $this->shortCircuit, $this->fileEncoding); + } + + /** + * Creates a store builder with short circuit mode enabled. + * + * @return \Dotenv\Store\StoreBuilder + */ + public function shortCircuit() + { + return new self($this->paths, $this->names, true, $this->fileEncoding); + } + + /** + * Creates a store builder with the specified file encoding. + * + * @param string|null $fileEncoding + * + * @return \Dotenv\Store\StoreBuilder + */ + public function fileEncoding(string $fileEncoding = null) + { + return new self($this->paths, $this->names, $this->shortCircuit, $fileEncoding); + } + + /** + * Creates a new store instance. + * + * @return \Dotenv\Store\StoreInterface + */ + public function make() + { + return new FileStore( + Paths::filePaths($this->paths, $this->names), + $this->shortCircuit, + $this->fileEncoding + ); + } +} diff --git a/vendor/vlucas/phpdotenv/src/Store/StoreInterface.php b/vendor/vlucas/phpdotenv/src/Store/StoreInterface.php new file mode 100644 index 0000000..6f5b986 --- /dev/null +++ b/vendor/vlucas/phpdotenv/src/Store/StoreInterface.php @@ -0,0 +1,17 @@ +content = $content; + } + + /** + * Read the content of the environment file(s). + * + * @return string + */ + public function read() + { + return $this->content; + } +} diff --git a/vendor/vlucas/phpdotenv/src/Util/Regex.php b/vendor/vlucas/phpdotenv/src/Util/Regex.php new file mode 100644 index 0000000..e558f40 --- /dev/null +++ b/vendor/vlucas/phpdotenv/src/Util/Regex.php @@ -0,0 +1,110 @@ + + */ + public static function matches(string $pattern, string $subject) + { + return self::pregAndWrap(static function (string $subject) use ($pattern) { + return @\preg_match($pattern, $subject) === 1; + }, $subject); + } + + /** + * Perform a preg match all, wrapping up the result. + * + * @param string $pattern + * @param string $subject + * + * @return \GrahamCampbell\ResultType\Result + */ + public static function occurences(string $pattern, string $subject) + { + return self::pregAndWrap(static function (string $subject) use ($pattern) { + return (int) @\preg_match_all($pattern, $subject); + }, $subject); + } + + /** + * Perform a preg replace callback, wrapping up the result. + * + * @param string $pattern + * @param callable $callback + * @param string $subject + * @param int|null $limit + * + * @return \GrahamCampbell\ResultType\Result + */ + public static function replaceCallback(string $pattern, callable $callback, string $subject, int $limit = null) + { + return self::pregAndWrap(static function (string $subject) use ($pattern, $callback, $limit) { + return (string) @\preg_replace_callback($pattern, $callback, $subject, $limit ?? -1); + }, $subject); + } + + /** + * Perform a preg split, wrapping up the result. + * + * @param string $pattern + * @param string $subject + * + * @return \GrahamCampbell\ResultType\Result + */ + public static function split(string $pattern, string $subject) + { + return self::pregAndWrap(static function (string $subject) use ($pattern) { + /** @var string[] */ + return (array) @\preg_split($pattern, $subject); + }, $subject); + } + + /** + * Perform a preg operation, wrapping up the result. + * + * @template V + * + * @param callable(string):V $operation + * @param string $subject + * + * @return \GrahamCampbell\ResultType\Result + */ + private static function pregAndWrap(callable $operation, string $subject) + { + $result = $operation($subject); + + if (\preg_last_error() !== \PREG_NO_ERROR) { + return Error::create(\preg_last_error_msg()); + } + + return Success::create($result); + } +} diff --git a/vendor/vlucas/phpdotenv/src/Util/Str.php b/vendor/vlucas/phpdotenv/src/Util/Str.php new file mode 100644 index 0000000..582c214 --- /dev/null +++ b/vendor/vlucas/phpdotenv/src/Util/Str.php @@ -0,0 +1,90 @@ + + */ + public static function utf8(string $input, string $encoding = null) + { + if ($encoding !== null && !\in_array($encoding, \mb_list_encodings(), true)) { + /** @var \GrahamCampbell\ResultType\Result */ + return Error::create( + \sprintf('Illegal character encoding [%s] specified.', $encoding) + ); + } + + /** @var \GrahamCampbell\ResultType\Result */ + return Success::create( + $encoding === null ? @\mb_convert_encoding($input, 'UTF-8') : @\mb_convert_encoding($input, 'UTF-8', $encoding) + ); + } + + /** + * Search for a given substring of the input. + * + * @param string $haystack + * @param string $needle + * + * @return \PhpOption\Option + */ + public static function pos(string $haystack, string $needle) + { + /** @var \PhpOption\Option */ + return Option::fromValue(\mb_strpos($haystack, $needle, 0, 'UTF-8'), false); + } + + /** + * Grab the specified substring of the input. + * + * @param string $input + * @param int $start + * @param int|null $length + * + * @return string + */ + public static function substr(string $input, int $start, int $length = null) + { + return \mb_substr($input, $start, $length, 'UTF-8'); + } + + /** + * Compute the length of the given string. + * + * @param string $input + * + * @return int + */ + public static function len(string $input) + { + return \mb_strlen($input, 'UTF-8'); + } +} diff --git a/vendor/vlucas/phpdotenv/src/Validator.php b/vendor/vlucas/phpdotenv/src/Validator.php new file mode 100644 index 0000000..0c04ab6 --- /dev/null +++ b/vendor/vlucas/phpdotenv/src/Validator.php @@ -0,0 +1,209 @@ +repository = $repository; + $this->variables = $variables; + } + + /** + * Assert that each variable is present. + * + * @throws \Dotenv\Exception\ValidationException + * + * @return \Dotenv\Validator + */ + public function required() + { + return $this->assert( + static function (?string $value) { + return $value !== null; + }, + 'is missing' + ); + } + + /** + * Assert that each variable is not empty. + * + * @throws \Dotenv\Exception\ValidationException + * + * @return \Dotenv\Validator + */ + public function notEmpty() + { + return $this->assertNullable( + static function (string $value) { + return Str::len(\trim($value)) > 0; + }, + 'is empty' + ); + } + + /** + * Assert that each specified variable is an integer. + * + * @throws \Dotenv\Exception\ValidationException + * + * @return \Dotenv\Validator + */ + public function isInteger() + { + return $this->assertNullable( + static function (string $value) { + return \ctype_digit($value); + }, + 'is not an integer' + ); + } + + /** + * Assert that each specified variable is a boolean. + * + * @throws \Dotenv\Exception\ValidationException + * + * @return \Dotenv\Validator + */ + public function isBoolean() + { + return $this->assertNullable( + static function (string $value) { + if ($value === '') { + return false; + } + + return \filter_var($value, \FILTER_VALIDATE_BOOLEAN, \FILTER_NULL_ON_FAILURE) !== null; + }, + 'is not a boolean' + ); + } + + /** + * Assert that each variable is amongst the given choices. + * + * @param string[] $choices + * + * @throws \Dotenv\Exception\ValidationException + * + * @return \Dotenv\Validator + */ + public function allowedValues(array $choices) + { + return $this->assertNullable( + static function (string $value) use ($choices) { + return \in_array($value, $choices, true); + }, + \sprintf('is not one of [%s]', \implode(', ', $choices)) + ); + } + + /** + * Assert that each variable matches the given regular expression. + * + * @param string $regex + * + * @throws \Dotenv\Exception\ValidationException + * + * @return \Dotenv\Validator + */ + public function allowedRegexValues(string $regex) + { + return $this->assertNullable( + static function (string $value) use ($regex) { + return Regex::matches($regex, $value)->success()->getOrElse(false); + }, + \sprintf('does not match "%s"', $regex) + ); + } + + /** + * Assert that the callback returns true for each variable. + * + * @param callable(?string):bool $callback + * @param string $message + * + * @throws \Dotenv\Exception\ValidationException + * + * @return \Dotenv\Validator + */ + public function assert(callable $callback, string $message) + { + $failing = []; + + foreach ($this->variables as $variable) { + if ($callback($this->repository->get($variable)) === false) { + $failing[] = \sprintf('%s %s', $variable, $message); + } + } + + if (\count($failing) > 0) { + throw new ValidationException(\sprintf( + 'One or more environment variables failed assertions: %s.', + \implode(', ', $failing) + )); + } + + return $this; + } + + /** + * Assert that the callback returns true for each variable. + * + * Skip checking null variable values. + * + * @param callable(string):bool $callback + * @param string $message + * + * @throws \Dotenv\Exception\ValidationException + * + * @return \Dotenv\Validator + */ + public function assertNullable(callable $callback, string $message) + { + return $this->assert( + static function (?string $value) use ($callback) { + if ($value === null) { + return true; + } + + return $callback($value); + }, + $message + ); + } +}