Compare commits
9 Commits
a2e103c32f
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
35534549fe | ||
|
|
8b1faf795c | ||
|
|
b2a4cbff01 | ||
|
|
8656362f0d | ||
|
|
fa7de7c6c4 | ||
|
|
d86b69ce61 | ||
|
|
46979352b8 | ||
|
|
9f028ac798 | ||
|
|
7cbbec7f81 |
@@ -16,13 +16,13 @@ use Domframework\Tcpclient;
|
|||||||
*/
|
*/
|
||||||
class TcpclientTest extends \PHPUnit_Framework_TestCase
|
class TcpclientTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function testGoogleIPv4()
|
public function testFournier38IPv4()
|
||||||
{
|
{
|
||||||
$tcpclient = new Tcpclient("www.google.fr", 80);
|
$tcpclient = new Tcpclient("ipv4.fournier38.fr", 80);
|
||||||
$tcpclient->preferIPv4(true);
|
$tcpclient->preferIPv4(true);
|
||||||
$tcpclient->connect();
|
$tcpclient->connect();
|
||||||
$tcpclient->send("GET / HTTP/1.1\r\n" .
|
$tcpclient->send("GET / HTTP/1.1\r\n" .
|
||||||
"Host: www.google.fr\r\n" .
|
"Host: ip.fournier38.fr\r\n" .
|
||||||
"User-Agent: DomFramework\r\n" .
|
"User-Agent: DomFramework\r\n" .
|
||||||
"Accept: *" . "/*\r\n" .
|
"Accept: *" . "/*\r\n" .
|
||||||
"\r\n");
|
"\r\n");
|
||||||
@@ -34,12 +34,12 @@ class TcpclientTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertSame(substr($res, 0, 15), "HTTP/1.1 200 OK");
|
$this->assertSame(substr($res, 0, 15), "HTTP/1.1 200 OK");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGoogleIPv4orIpv6()
|
public function testFournier38IPv4orIpv6()
|
||||||
{
|
{
|
||||||
$tcpclient = new Tcpclient("www.google.fr", 80);
|
$tcpclient = new Tcpclient("ip.fournier38.fr", 80);
|
||||||
$tcpclient->connect();
|
$tcpclient->connect();
|
||||||
$tcpclient->send("GET / HTTP/1.1\r\n" .
|
$tcpclient->send("GET / HTTP/1.1\r\n" .
|
||||||
"Host: www.google.fr\r\n" .
|
"Host: ip.fournier38.fr\r\n" .
|
||||||
"User-Agent: DomFramework\r\n" .
|
"User-Agent: DomFramework\r\n" .
|
||||||
"Accept: *" . "/*\r\n" .
|
"Accept: *" . "/*\r\n" .
|
||||||
"\r\n");
|
"\r\n");
|
||||||
@@ -51,13 +51,13 @@ class TcpclientTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertSame(substr($res, 0, 15), "HTTP/1.1 200 OK");
|
$this->assertSame(substr($res, 0, 15), "HTTP/1.1 200 OK");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGoogleSSL()
|
public function testFournier38SSL()
|
||||||
{
|
{
|
||||||
$tcpclient = new Tcpclient("www.google.fr", 443);
|
$tcpclient = new Tcpclient("ip.fournier38.fr", 443);
|
||||||
$tcpclient->connect();
|
$tcpclient->connect();
|
||||||
$tcpclient->cryptoEnable(true);
|
$tcpclient->cryptoEnable(true);
|
||||||
$tcpclient->send("GET / HTTP/1.1\r\n" .
|
$tcpclient->send("GET / HTTP/1.1\r\n" .
|
||||||
"Host: www.google.fr\r\n" .
|
"Host: ip.fournier38.fr\r\n" .
|
||||||
"User-Agent: DomFramework\r\n" .
|
"User-Agent: DomFramework\r\n" .
|
||||||
"Accept: *" . "/*\r\n" .
|
"Accept: *" . "/*\r\n" .
|
||||||
"\r\n");
|
"\r\n");
|
||||||
@@ -69,13 +69,13 @@ class TcpclientTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertSame(substr($res, 0, 15), "HTTP/1.1 200 OK");
|
$this->assertSame(substr($res, 0, 15), "HTTP/1.1 200 OK");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGoogleSSLIPv6()
|
public function testFournier38SSLIPv6()
|
||||||
{
|
{
|
||||||
$tcpclient = new Tcpclient("ipv6.google.com", 443);
|
$tcpclient = new Tcpclient("ipv6.fournier38.fr", 443);
|
||||||
$tcpclient->connect();
|
$tcpclient->connect();
|
||||||
$tcpclient->cryptoEnable(true);
|
$tcpclient->cryptoEnable(true);
|
||||||
$tcpclient->send("GET / HTTP/1.1\r\n" .
|
$tcpclient->send("GET / HTTP/1.1\r\n" .
|
||||||
"Host: www.google.fr\r\n" .
|
"Host: ipv6.fournier38.f\r\n" .
|
||||||
"User-Agent: DomFramework\r\n" .
|
"User-Agent: DomFramework\r\n" .
|
||||||
"Accept: *" . "/*\r\n" .
|
"Accept: *" . "/*\r\n" .
|
||||||
"\r\n");
|
"\r\n");
|
||||||
|
|||||||
48
src/Form.php
48
src/Form.php
@@ -91,7 +91,7 @@ class Form
|
|||||||
* Set the debug level
|
* Set the debug level
|
||||||
* @param integer $val The debug value
|
* @param integer $val The debug value
|
||||||
*/
|
*/
|
||||||
public function debug($val)
|
public function debug($val): self
|
||||||
{
|
{
|
||||||
$this->debug = $val;
|
$this->debug = $val;
|
||||||
return $this;
|
return $this;
|
||||||
@@ -101,7 +101,7 @@ class Form
|
|||||||
* Set the csrf enable
|
* Set the csrf enable
|
||||||
* @param integer $val The csrf check
|
* @param integer $val The csrf check
|
||||||
*/
|
*/
|
||||||
public function csrf($val)
|
public function csrf($val): self
|
||||||
{
|
{
|
||||||
$this->csrf = !! $val;
|
$this->csrf = !! $val;
|
||||||
return $this;
|
return $this;
|
||||||
@@ -111,7 +111,7 @@ class Form
|
|||||||
* Set the method
|
* Set the method
|
||||||
* @param string $val The method to use
|
* @param string $val The method to use
|
||||||
*/
|
*/
|
||||||
public function method($val)
|
public function method($val): self
|
||||||
{
|
{
|
||||||
$this->method = strtolower($val);
|
$this->method = strtolower($val);
|
||||||
return $this;
|
return $this;
|
||||||
@@ -121,7 +121,7 @@ class Form
|
|||||||
* Set the csrf token name
|
* Set the csrf token name
|
||||||
* @param integer $val The csrf token name
|
* @param integer $val The csrf token name
|
||||||
*/
|
*/
|
||||||
public function csrfField($val)
|
public function csrfField($val): self
|
||||||
{
|
{
|
||||||
$this->csrfField = $val;
|
$this->csrfField = $val;
|
||||||
return $this;
|
return $this;
|
||||||
@@ -131,7 +131,7 @@ class Form
|
|||||||
* Set the titlewidth
|
* Set the titlewidth
|
||||||
* @param integer $val The titlewidth
|
* @param integer $val The titlewidth
|
||||||
*/
|
*/
|
||||||
public function titlewidth($val)
|
public function titlewidth($val): self
|
||||||
{
|
{
|
||||||
$this->titlewidth = $val;
|
$this->titlewidth = $val;
|
||||||
return $this;
|
return $this;
|
||||||
@@ -141,7 +141,7 @@ class Form
|
|||||||
* Set the fieldwidth
|
* Set the fieldwidth
|
||||||
* @param integer $val The fieldwidth
|
* @param integer $val The fieldwidth
|
||||||
*/
|
*/
|
||||||
public function fieldwidth($val)
|
public function fieldwidth($val): self
|
||||||
{
|
{
|
||||||
$this->fieldwidth = $val;
|
$this->fieldwidth = $val;
|
||||||
return $this;
|
return $this;
|
||||||
@@ -151,7 +151,7 @@ class Form
|
|||||||
* Set the formClass
|
* Set the formClass
|
||||||
* @param integer $val The formClass
|
* @param integer $val The formClass
|
||||||
*/
|
*/
|
||||||
public function formClass($val)
|
public function formClass($val): self
|
||||||
{
|
{
|
||||||
$this->formClass = $val;
|
$this->formClass = $val;
|
||||||
return $this;
|
return $this;
|
||||||
@@ -164,7 +164,7 @@ class Form
|
|||||||
* @param string|null $loggingBasemsg The basemsg added at the beginning of
|
* @param string|null $loggingBasemsg The basemsg added at the beginning of
|
||||||
* the log
|
* the log
|
||||||
*/
|
*/
|
||||||
public function logging($loggingCallable, $loggingBasemsg = "")
|
public function logging($loggingCallable, $loggingBasemsg = ""): void
|
||||||
{
|
{
|
||||||
$this->loggingCallable = $loggingCallable;
|
$this->loggingCallable = $loggingCallable;
|
||||||
$this->loggingBasemsg = $loggingBasemsg;
|
$this->loggingBasemsg = $loggingBasemsg;
|
||||||
@@ -175,7 +175,7 @@ class Form
|
|||||||
* Can be : Bootstrap3, Bootstrap4 (later Bulma)
|
* Can be : Bootstrap3, Bootstrap4 (later Bulma)
|
||||||
* @param string $formTemplate The template to use
|
* @param string $formTemplate The template to use
|
||||||
*/
|
*/
|
||||||
public function formTemplate($formTemplate)
|
public function formTemplate($formTemplate): self
|
||||||
{
|
{
|
||||||
if (
|
if (
|
||||||
! in_array(
|
! in_array(
|
||||||
@@ -195,7 +195,7 @@ class Form
|
|||||||
* @param integer $prio The priority of the message
|
* @param integer $prio The priority of the message
|
||||||
* @param string $msg The message to store
|
* @param string $msg The message to store
|
||||||
*/
|
*/
|
||||||
private function loggingCallable($prio, $msg)
|
private function loggingCallable($prio, $msg): void
|
||||||
{
|
{
|
||||||
if (! is_callable($this->loggingCallable)) {
|
if (! is_callable($this->loggingCallable)) {
|
||||||
return;
|
return;
|
||||||
@@ -236,7 +236,7 @@ class Form
|
|||||||
*
|
*
|
||||||
* @param array $fields The fields to be displayed
|
* @param array $fields The fields to be displayed
|
||||||
*/
|
*/
|
||||||
public function fields($fields)
|
public function fields($fields): void
|
||||||
{
|
{
|
||||||
$this->fields = $fields;
|
$this->fields = $fields;
|
||||||
}
|
}
|
||||||
@@ -246,7 +246,7 @@ class Form
|
|||||||
* in fields method
|
* in fields method
|
||||||
* @param object $field The field to add
|
* @param object $field The field to add
|
||||||
*/
|
*/
|
||||||
public function addfield($field)
|
public function addfield($field): void
|
||||||
{
|
{
|
||||||
$this->fields[] = $field;
|
$this->fields[] = $field;
|
||||||
}
|
}
|
||||||
@@ -256,7 +256,7 @@ class Form
|
|||||||
* NEVER read the values from $_POST in your codes or CSRF will not be
|
* NEVER read the values from $_POST in your codes or CSRF will not be
|
||||||
* checked
|
* checked
|
||||||
*/
|
*/
|
||||||
public function values()
|
public function values(): array
|
||||||
{
|
{
|
||||||
$values = [];
|
$values = [];
|
||||||
if ($this->method === "post") {
|
if ($this->method === "post") {
|
||||||
@@ -328,7 +328,7 @@ class Form
|
|||||||
$method = 'post',
|
$method = 'post',
|
||||||
$values = null,
|
$values = null,
|
||||||
$errors = []
|
$errors = []
|
||||||
) {
|
): string {
|
||||||
if (count($this->fields) === 0) {
|
if (count($this->fields) === 0) {
|
||||||
$this->loggingCallable(
|
$this->loggingCallable(
|
||||||
LOG_ERR,
|
LOG_ERR,
|
||||||
@@ -456,7 +456,7 @@ class Form
|
|||||||
* Check the token from the user
|
* Check the token from the user
|
||||||
* @param string $tokenFromUser The value form the user's token
|
* @param string $tokenFromUser The value form the user's token
|
||||||
*/
|
*/
|
||||||
public function checkToken($tokenFromUser)
|
public function checkToken($tokenFromUser): void
|
||||||
{
|
{
|
||||||
$csrf = new Csrf();
|
$csrf = new Csrf();
|
||||||
$csrf->field = $this->csrfField;
|
$csrf->field = $this->csrfField;
|
||||||
@@ -468,7 +468,7 @@ class Form
|
|||||||
/**
|
/**
|
||||||
* Return the token generated in form
|
* Return the token generated in form
|
||||||
*/
|
*/
|
||||||
public function getToken()
|
public function getToken(): string
|
||||||
{
|
{
|
||||||
if ($this->csrfToken === "") {
|
if ($this->csrfToken === "") {
|
||||||
$csrf = new Csrf();
|
$csrf = new Csrf();
|
||||||
@@ -485,7 +485,7 @@ class Form
|
|||||||
* stored one if the value is null)
|
* stored one if the value is null)
|
||||||
* @return array containing the errors
|
* @return array containing the errors
|
||||||
*/
|
*/
|
||||||
public function verify($values, $fields = [])
|
public function verify($values, $fields = []): array
|
||||||
{
|
{
|
||||||
if (count($fields) === 0) {
|
if (count($fields) === 0) {
|
||||||
if (! isset($_SESSION["domframework"]["form"]["fields"])) {
|
if (! isset($_SESSION["domframework"]["form"]["fields"])) {
|
||||||
@@ -529,7 +529,7 @@ class Form
|
|||||||
* $spaceuuid = $spaceObj->spaceCreateConceal ($values["spacename"]);
|
* $spaceuuid = $spaceObj->spaceCreateConceal ($values["spacename"]);
|
||||||
* $route->redirect ("/admin/space/");
|
* $route->redirect ("/admin/space/");
|
||||||
*/
|
*/
|
||||||
public function redirectIfError($values, $errors, $route, $url = "")
|
public function redirectIfError($values, $errors, $route, $url = ""): void
|
||||||
{
|
{
|
||||||
$this->saveValuesErrors($values, $errors);
|
$this->saveValuesErrors($values, $errors);
|
||||||
if ($url === "") {
|
if ($url === "") {
|
||||||
@@ -548,7 +548,7 @@ class Form
|
|||||||
* @param array $values The values of the fields filled by the user
|
* @param array $values The values of the fields filled by the user
|
||||||
* @param array|null $errors The errors detected by a verify
|
* @param array|null $errors The errors detected by a verify
|
||||||
*/
|
*/
|
||||||
public function saveValuesErrors($values, $errors = [])
|
public function saveValuesErrors($values, $errors = []): void
|
||||||
{
|
{
|
||||||
if (isset($_SESSION)) {
|
if (isset($_SESSION)) {
|
||||||
$_SESSION["domframework"]["form"][$this->formName]["values"] = $values;
|
$_SESSION["domframework"]["form"][$this->formName]["values"] = $values;
|
||||||
@@ -560,7 +560,7 @@ class Form
|
|||||||
* Reset the saved values to provide a clean form next page
|
* Reset the saved values to provide a clean form next page
|
||||||
* Need the session to work
|
* Need the session to work
|
||||||
*/
|
*/
|
||||||
public function saveValuesErrorsReset()
|
public function saveValuesErrorsReset(): void
|
||||||
{
|
{
|
||||||
unset($_SESSION["domframework"]["form"][$this->formName]["values"]);
|
unset($_SESSION["domframework"]["form"][$this->formName]["values"]);
|
||||||
unset($_SESSION["domframework"]["form"][$this->formName]["errors"]);
|
unset($_SESSION["domframework"]["form"][$this->formName]["errors"]);
|
||||||
@@ -572,7 +572,7 @@ class Form
|
|||||||
* @param array $values The values returned if there is no stored values
|
* @param array $values The values returned if there is no stored values
|
||||||
* @return array The values to use
|
* @return array The values to use
|
||||||
*/
|
*/
|
||||||
public function getOldValues($values)
|
public function getOldValues($values): array
|
||||||
{
|
{
|
||||||
if (isset($_SESSION["domframework"]["form"][$this->formName]["values"])) {
|
if (isset($_SESSION["domframework"]["form"][$this->formName]["values"])) {
|
||||||
$values = $_SESSION["domframework"]["form"][$this->formName]["values"];
|
$values = $_SESSION["domframework"]["form"][$this->formName]["values"];
|
||||||
@@ -587,7 +587,7 @@ class Form
|
|||||||
* @param array $errors The values returned if there is no stored values
|
* @param array $errors The values returned if there is no stored values
|
||||||
* @return array The errors to use
|
* @return array The errors to use
|
||||||
*/
|
*/
|
||||||
public function getOldErrors($errors)
|
public function getOldErrors($errors): array
|
||||||
{
|
{
|
||||||
if (isset($_SESSION["domframework"]["form"][$this->formName]["errors"])) {
|
if (isset($_SESSION["domframework"]["form"][$this->formName]["errors"])) {
|
||||||
$errors = $_SESSION["domframework"]["form"][$this->formName]["errors"];
|
$errors = $_SESSION["domframework"]["form"][$this->formName]["errors"];
|
||||||
@@ -606,14 +606,14 @@ class Form
|
|||||||
* @param string $outputFormat The output format of the date
|
* @param string $outputFormat The output format of the date
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function convertDate($inputDate, $inputFormat, $outputFormat)
|
public function convertDate($inputDate, $inputFormat, $outputFormat): string
|
||||||
{
|
{
|
||||||
$date = \DateTime::CreateFromFormat($inputFormat, $inputDate);
|
$date = \DateTime::CreateFromFormat($inputFormat, $inputDate);
|
||||||
if ($date === false) {
|
if ($date === false) {
|
||||||
return $inputDate;
|
return $inputDate;
|
||||||
}
|
}
|
||||||
$errors = $date->getLastErrors();
|
$errors = $date->getLastErrors();
|
||||||
if ($errors["warning_count"] > 0 || $errors["error_count"] > 0) {
|
if (is_array($errors) && ($errors["warning_count"] > 0 || $errors["error_count"] > 0)) {
|
||||||
return $inputDate;
|
return $inputDate;
|
||||||
}
|
}
|
||||||
return $date->format($outputFormat);
|
return $date->format($outputFormat);
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ class Formfield
|
|||||||
/**
|
/**
|
||||||
* Form template (Bootstrap3 by default)
|
* Form template (Bootstrap3 by default)
|
||||||
*/
|
*/
|
||||||
private $formTemplate = "Bootstrap3";
|
public $formTemplate = "Bootstrap3";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When adding a field, the name and the label are the minimum mandatory
|
* When adding a field, the name and the label are the minimum mandatory
|
||||||
@@ -106,7 +106,7 @@ class Formfield
|
|||||||
/**
|
/**
|
||||||
* Display really the form
|
* Display really the form
|
||||||
*/
|
*/
|
||||||
public function display()
|
public function display(): string
|
||||||
{
|
{
|
||||||
$func = "field" . $this->formTemplate . $this->type;
|
$func = "field" . $this->formTemplate . $this->type;
|
||||||
return $this->$func();
|
return $this->$func();
|
||||||
@@ -117,7 +117,7 @@ class Formfield
|
|||||||
* Set the type of the field
|
* Set the type of the field
|
||||||
* @param string $val The value of the type of the field
|
* @param string $val The value of the type of the field
|
||||||
*/
|
*/
|
||||||
public function type($val)
|
public function type($val): self
|
||||||
{
|
{
|
||||||
$this->type = $val;
|
$this->type = $val;
|
||||||
return $this;
|
return $this;
|
||||||
@@ -127,7 +127,7 @@ class Formfield
|
|||||||
* Set the hidden of the field
|
* Set the hidden of the field
|
||||||
* @param string $val The value of the hidden of the field
|
* @param string $val The value of the hidden of the field
|
||||||
*/
|
*/
|
||||||
public function hidden($val)
|
public function hidden($val): self
|
||||||
{
|
{
|
||||||
$this->hidden = !! $val;
|
$this->hidden = !! $val;
|
||||||
return $this;
|
return $this;
|
||||||
@@ -137,7 +137,7 @@ class Formfield
|
|||||||
* Set the help of the field
|
* Set the help of the field
|
||||||
* @param string $val The value of the help of the field
|
* @param string $val The value of the help of the field
|
||||||
*/
|
*/
|
||||||
public function help($val)
|
public function help($val): self
|
||||||
{
|
{
|
||||||
$this->help = $val;
|
$this->help = $val;
|
||||||
return $this;
|
return $this;
|
||||||
@@ -147,7 +147,7 @@ class Formfield
|
|||||||
* Set the placeholder
|
* Set the placeholder
|
||||||
* @param string $val The value of the placeholder
|
* @param string $val The value of the placeholder
|
||||||
*/
|
*/
|
||||||
public function placeholder($val)
|
public function placeholder($val): self
|
||||||
{
|
{
|
||||||
$this->placeholder = $val;
|
$this->placeholder = $val;
|
||||||
return $this;
|
return $this;
|
||||||
@@ -157,7 +157,7 @@ class Formfield
|
|||||||
* Set the multiple
|
* Set the multiple
|
||||||
* @param string $val The value of the multiple
|
* @param string $val The value of the multiple
|
||||||
*/
|
*/
|
||||||
public function multiple($val)
|
public function multiple($val): self
|
||||||
{
|
{
|
||||||
$this->multiple = $val;
|
$this->multiple = $val;
|
||||||
return $this;
|
return $this;
|
||||||
@@ -167,7 +167,7 @@ class Formfield
|
|||||||
* Set the group
|
* Set the group
|
||||||
* @param string $val The value of the group
|
* @param string $val The value of the group
|
||||||
*/
|
*/
|
||||||
public function group($val)
|
public function group($val): self
|
||||||
{
|
{
|
||||||
$this->group = $val;
|
$this->group = $val;
|
||||||
return $this;
|
return $this;
|
||||||
@@ -177,7 +177,7 @@ class Formfield
|
|||||||
* Set the readonly
|
* Set the readonly
|
||||||
* @param string $val The value of the readonly
|
* @param string $val The value of the readonly
|
||||||
*/
|
*/
|
||||||
public function readonly($val)
|
public function readonly($val): self
|
||||||
{
|
{
|
||||||
$this->readonly = !! $val;
|
$this->readonly = !! $val;
|
||||||
return $this;
|
return $this;
|
||||||
@@ -187,7 +187,7 @@ class Formfield
|
|||||||
* Set the mandatory
|
* Set the mandatory
|
||||||
* @param string $val The value of the mandatory
|
* @param string $val The value of the mandatory
|
||||||
*/
|
*/
|
||||||
public function mandatory($val)
|
public function mandatory($val): self
|
||||||
{
|
{
|
||||||
$this->mandatory = !! $val;
|
$this->mandatory = !! $val;
|
||||||
return $this;
|
return $this;
|
||||||
@@ -197,7 +197,7 @@ class Formfield
|
|||||||
* Set the rows
|
* Set the rows
|
||||||
* @param string $val The value of the rows
|
* @param string $val The value of the rows
|
||||||
*/
|
*/
|
||||||
public function rows($val)
|
public function rows($val): self
|
||||||
{
|
{
|
||||||
$this->rows = $val;
|
$this->rows = $val;
|
||||||
return $this;
|
return $this;
|
||||||
@@ -207,7 +207,7 @@ class Formfield
|
|||||||
* Set the cols
|
* Set the cols
|
||||||
* @param string $val The value of the cols
|
* @param string $val The value of the cols
|
||||||
*/
|
*/
|
||||||
public function cols($val)
|
public function cols($val): self
|
||||||
{
|
{
|
||||||
$this->cols = $val;
|
$this->cols = $val;
|
||||||
return $this;
|
return $this;
|
||||||
@@ -219,7 +219,7 @@ class Formfield
|
|||||||
/**
|
/**
|
||||||
* Return the checkbox defined
|
* Return the checkbox defined
|
||||||
*/
|
*/
|
||||||
private function fieldBootstrap3checkbox()
|
private function fieldBootstrap3checkbox(): string
|
||||||
{
|
{
|
||||||
// No $this->multiple, $this->rows $this->cols $this->placeholder,
|
// No $this->multiple, $this->rows $this->cols $this->placeholder,
|
||||||
// $this->maxlength
|
// $this->maxlength
|
||||||
@@ -366,7 +366,7 @@ class Formfield
|
|||||||
/**
|
/**
|
||||||
* Return the hidden field defined
|
* Return the hidden field defined
|
||||||
*/
|
*/
|
||||||
private function fieldBootstrap3hidden()
|
private function fieldBootstrap3hidden(): string
|
||||||
{
|
{
|
||||||
$res = "";
|
$res = "";
|
||||||
// No $this->label, $this->multiple, $this->readonly, $this->hidden,
|
// No $this->label, $this->multiple, $this->readonly, $this->hidden,
|
||||||
@@ -388,7 +388,7 @@ class Formfield
|
|||||||
/**
|
/**
|
||||||
* Return the password field defined
|
* Return the password field defined
|
||||||
*/
|
*/
|
||||||
private function fieldBootstrap3password()
|
private function fieldBootstrap3password(): string
|
||||||
{
|
{
|
||||||
$res = "";
|
$res = "";
|
||||||
// No $this->multiple, $this->rows $this->cols
|
// No $this->multiple, $this->rows $this->cols
|
||||||
@@ -472,7 +472,7 @@ class Formfield
|
|||||||
/**
|
/**
|
||||||
* Return the radio field defined
|
* Return the radio field defined
|
||||||
*/
|
*/
|
||||||
private function fieldBootstrap3radio()
|
private function fieldBootstrap3radio(): string
|
||||||
{
|
{
|
||||||
$res = "";
|
$res = "";
|
||||||
// No $this->multiple, $this->rows $this->cols $this->placeholder
|
// No $this->multiple, $this->rows $this->cols $this->placeholder
|
||||||
@@ -574,7 +574,7 @@ class Formfield
|
|||||||
/**
|
/**
|
||||||
* Return the checkbox defined
|
* Return the checkbox defined
|
||||||
*/
|
*/
|
||||||
private function fieldBootstrap3select()
|
private function fieldBootstrap3select(): string
|
||||||
{
|
{
|
||||||
// No $this->placeholder $this->maxlength
|
// No $this->placeholder $this->maxlength
|
||||||
$res = "";
|
$res = "";
|
||||||
@@ -704,7 +704,7 @@ class Formfield
|
|||||||
/**
|
/**
|
||||||
* Return the submit defined
|
* Return the submit defined
|
||||||
*/
|
*/
|
||||||
private function fieldBootstrap3submit()
|
private function fieldBootstrap3submit(): string
|
||||||
{
|
{
|
||||||
$res = "";
|
$res = "";
|
||||||
// No $this->label, $this->multiple, $this->error, $this->rows,
|
// No $this->label, $this->multiple, $this->error, $this->rows,
|
||||||
@@ -749,7 +749,7 @@ class Formfield
|
|||||||
/**
|
/**
|
||||||
* Return the textarea defined
|
* Return the textarea defined
|
||||||
*/
|
*/
|
||||||
private function fieldBootstrap3textarea()
|
private function fieldBootstrap3textarea(): string
|
||||||
{
|
{
|
||||||
$res = "";
|
$res = "";
|
||||||
// No $this->multiple, $this->titles
|
// No $this->multiple, $this->titles
|
||||||
@@ -835,7 +835,7 @@ class Formfield
|
|||||||
/**
|
/**
|
||||||
* Return the text defined
|
* Return the text defined
|
||||||
*/
|
*/
|
||||||
private function fieldBootstrap3text()
|
private function fieldBootstrap3text(): string
|
||||||
{
|
{
|
||||||
$res = "";
|
$res = "";
|
||||||
// No $this->multiple, $this->titles, $this->rows, $this->cols
|
// No $this->multiple, $this->titles, $this->rows, $this->cols
|
||||||
@@ -919,7 +919,7 @@ class Formfield
|
|||||||
/**
|
/**
|
||||||
* Return the file defined
|
* Return the file defined
|
||||||
*/
|
*/
|
||||||
private function fieldBootstrap3file()
|
private function fieldBootstrap3file(): string
|
||||||
{
|
{
|
||||||
$res = "";
|
$res = "";
|
||||||
// No $this->multiple, $this->titles, $this->rows, $this->cols
|
// No $this->multiple, $this->titles, $this->rows, $this->cols
|
||||||
@@ -1021,7 +1021,7 @@ class Formfield
|
|||||||
/**
|
/**
|
||||||
* Return the checkbox defined
|
* Return the checkbox defined
|
||||||
*/
|
*/
|
||||||
private function fieldBootstrap4checkbox()
|
private function fieldBootstrap4checkbox(): string
|
||||||
{
|
{
|
||||||
// No $this->multiple, $this->rows $this->cols $this->placeholder,
|
// No $this->multiple, $this->rows $this->cols $this->placeholder,
|
||||||
// $this->maxlength
|
// $this->maxlength
|
||||||
@@ -1176,7 +1176,7 @@ class Formfield
|
|||||||
/**
|
/**
|
||||||
* Return the hidden field defined
|
* Return the hidden field defined
|
||||||
*/
|
*/
|
||||||
private function fieldBootstrap4hidden()
|
private function fieldBootstrap4hidden(): string
|
||||||
{
|
{
|
||||||
$res = "";
|
$res = "";
|
||||||
// No $this->label, $this->multiple, $this->readonly, $this->hidden,
|
// No $this->label, $this->multiple, $this->readonly, $this->hidden,
|
||||||
@@ -1198,7 +1198,7 @@ class Formfield
|
|||||||
/**
|
/**
|
||||||
* Return the password field defined
|
* Return the password field defined
|
||||||
*/
|
*/
|
||||||
private function fieldBootstrap4password()
|
private function fieldBootstrap4password(): string
|
||||||
{
|
{
|
||||||
$res = "";
|
$res = "";
|
||||||
// No $this->multiple, $this->rows $this->cols
|
// No $this->multiple, $this->rows $this->cols
|
||||||
@@ -1290,7 +1290,7 @@ class Formfield
|
|||||||
/**
|
/**
|
||||||
* Return the radio field defined
|
* Return the radio field defined
|
||||||
*/
|
*/
|
||||||
private function fieldBootstrap4radio()
|
private function fieldBootstrap4radio(): string
|
||||||
{
|
{
|
||||||
$res = "";
|
$res = "";
|
||||||
// No $this->multiple, $this->rows $this->cols $this->placeholder
|
// No $this->multiple, $this->rows $this->cols $this->placeholder
|
||||||
@@ -1400,7 +1400,7 @@ class Formfield
|
|||||||
/**
|
/**
|
||||||
* Return the checkbox defined
|
* Return the checkbox defined
|
||||||
*/
|
*/
|
||||||
private function fieldBootstrap4select()
|
private function fieldBootstrap4select(): string
|
||||||
{
|
{
|
||||||
// No $this->placeholder $this->maxlength
|
// No $this->placeholder $this->maxlength
|
||||||
$res = "";
|
$res = "";
|
||||||
@@ -1538,7 +1538,7 @@ class Formfield
|
|||||||
/**
|
/**
|
||||||
* Return the submit defined
|
* Return the submit defined
|
||||||
*/
|
*/
|
||||||
private function fieldBootstrap4submit()
|
private function fieldBootstrap4submit(): string
|
||||||
{
|
{
|
||||||
$res = "";
|
$res = "";
|
||||||
// No $this->label, $this->multiple, $this->error, $this->rows,
|
// No $this->label, $this->multiple, $this->error, $this->rows,
|
||||||
@@ -1583,7 +1583,7 @@ class Formfield
|
|||||||
/**
|
/**
|
||||||
* Return the textarea defined
|
* Return the textarea defined
|
||||||
*/
|
*/
|
||||||
private function fieldBootstrap4textarea()
|
private function fieldBootstrap4textarea(): string
|
||||||
{
|
{
|
||||||
$res = "";
|
$res = "";
|
||||||
// No $this->multiple, $this->titles
|
// No $this->multiple, $this->titles
|
||||||
@@ -1677,7 +1677,7 @@ class Formfield
|
|||||||
/**
|
/**
|
||||||
* Return the text defined
|
* Return the text defined
|
||||||
*/
|
*/
|
||||||
private function fieldBootstrap4text()
|
private function fieldBootstrap4text(): string
|
||||||
{
|
{
|
||||||
$res = "";
|
$res = "";
|
||||||
// No $this->multiple, $this->titles, $this->rows, $this->cols
|
// No $this->multiple, $this->titles, $this->rows, $this->cols
|
||||||
@@ -1769,7 +1769,7 @@ class Formfield
|
|||||||
/**
|
/**
|
||||||
* Return the file defined
|
* Return the file defined
|
||||||
*/
|
*/
|
||||||
private function fieldBootstrap4file()
|
private function fieldBootstrap4file(): string
|
||||||
{
|
{
|
||||||
$res = "";
|
$res = "";
|
||||||
// No $this->multiple, $this->titles, $this->rows, $this->cols
|
// No $this->multiple, $this->titles, $this->rows, $this->cols
|
||||||
|
|||||||
@@ -364,7 +364,7 @@ class Language
|
|||||||
$languageCode,
|
$languageCode,
|
||||||
"domframework",
|
"domframework",
|
||||||
LC_MESSAGES,
|
LC_MESSAGES,
|
||||||
dirname(__FILE__) . "/locale"
|
__DIR__ . "/../locale"
|
||||||
);
|
);
|
||||||
$dfDir = dirname(dirname(dirname($dfFile)));
|
$dfDir = dirname(dirname(dirname($dfFile)));
|
||||||
$this->languageActivation($dfFile, $languageCode, LC_MESSAGES, $dfDir);
|
$this->languageActivation($dfFile, $languageCode, LC_MESSAGES, $dfDir);
|
||||||
|
|||||||
@@ -437,7 +437,7 @@ class Logger
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
openlog($this->syslogPrefix, null, $this->syslogFacility);
|
openlog($this->syslogPrefix, LOG_PID, $this->syslogFacility);
|
||||||
// Syslog display a #012 when there is a \n : remove it
|
// Syslog display a #012 when there is a \n : remove it
|
||||||
$message = str_replace("\n", "", $message);
|
$message = str_replace("\n", "", $message);
|
||||||
syslog($priority, $message);
|
syslog($priority, $message);
|
||||||
|
|||||||
17
src/Mail.php
17
src/Mail.php
@@ -302,7 +302,7 @@ class Mail
|
|||||||
PREG_SPLIT_DELIM_CAPTURE
|
PREG_SPLIT_DELIM_CAPTURE
|
||||||
);
|
);
|
||||||
// Remove the first 2 dashes : the boundary is stored like in the headers
|
// Remove the first 2 dashes : the boundary is stored like in the headers
|
||||||
$boundary = "";
|
$boundary = $boundaryCR = "";
|
||||||
while (count($boundaryArray) > 0 && substr($boundary, 0, 2) !== "--") {
|
while (count($boundaryArray) > 0 && substr($boundary, 0, 2) !== "--") {
|
||||||
// Skip the lines until the coundary is found. The boundary start by --
|
// Skip the lines until the coundary is found. The boundary start by --
|
||||||
$boundary = array_shift($boundaryArray);
|
$boundary = array_shift($boundaryArray);
|
||||||
@@ -379,9 +379,9 @@ class Mail
|
|||||||
$headersEML = ltrim(substr($content, 0, $pos +
|
$headersEML = ltrim(substr($content, 0, $pos +
|
||||||
strlen($headerBodySeparator)));
|
strlen($headerBodySeparator)));
|
||||||
$headersArray = [];
|
$headersArray = [];
|
||||||
|
$prevCR = "";
|
||||||
if ($headersEML !== "" && $headersEML !== "--") {
|
if ($headersEML !== "" && $headersEML !== "--") {
|
||||||
$prev = "";
|
$prev = "";
|
||||||
$prevCR = "";
|
|
||||||
$headersSplit = preg_split(
|
$headersSplit = preg_split(
|
||||||
"#([\r\n]+)#",
|
"#([\r\n]+)#",
|
||||||
$headersEML,
|
$headersEML,
|
||||||
@@ -527,6 +527,7 @@ class Mail
|
|||||||
// multipart/alternative)
|
// multipart/alternative)
|
||||||
$sectionList = $this->sectionList();
|
$sectionList = $this->sectionList();
|
||||||
$sectionIDtoChange = "";
|
$sectionIDtoChange = "";
|
||||||
|
$boundary = $boundaryCR = "";
|
||||||
foreach ($sectionList as $sectionID) {
|
foreach ($sectionList as $sectionID) {
|
||||||
$section = $this->sectionGet($sectionID);
|
$section = $this->sectionGet($sectionID);
|
||||||
if (
|
if (
|
||||||
@@ -628,10 +629,10 @@ class Mail
|
|||||||
"text/html; charset=$charset",
|
"text/html; charset=$charset",
|
||||||
$sectionIDtoChange
|
$sectionIDtoChange
|
||||||
);
|
);
|
||||||
if (isset($boundary)) {
|
if ($boundary !== "") {
|
||||||
$part["_boundary"] = $boundary;
|
$part["_boundary"] = $boundary;
|
||||||
}
|
}
|
||||||
if (isset($boundaryCR)) {
|
if ($boundaryCR != "") {
|
||||||
$part["_boundaryCR"] = $boundaryCR;
|
$part["_boundaryCR"] = $boundaryCR;
|
||||||
}
|
}
|
||||||
$this->sectionUpdate($sectionIDtoChange, $part);
|
$this->sectionUpdate($sectionIDtoChange, $part);
|
||||||
@@ -654,6 +655,7 @@ class Mail
|
|||||||
// multipart/alternative)
|
// multipart/alternative)
|
||||||
$sectionList = $this->sectionList();
|
$sectionList = $this->sectionList();
|
||||||
$sectionIDtoChange = "";
|
$sectionIDtoChange = "";
|
||||||
|
$boundary = "";
|
||||||
foreach ($sectionList as $sectionID) {
|
foreach ($sectionList as $sectionID) {
|
||||||
$section = $this->sectionGet($sectionID);
|
$section = $this->sectionGet($sectionID);
|
||||||
if (
|
if (
|
||||||
@@ -736,12 +738,9 @@ class Mail
|
|||||||
"text/plain; charset=$charset",
|
"text/plain; charset=$charset",
|
||||||
$sectionIDtoChange
|
$sectionIDtoChange
|
||||||
);
|
);
|
||||||
if (isset($boundary)) {
|
if ($boundary !== "") {
|
||||||
$part["_boundary"] = $boundary;
|
$part["_boundary"] = $boundary;
|
||||||
}
|
}
|
||||||
if (isset($boundaryCR)) {
|
|
||||||
$part["_boundaryCR"] = $boundaryCR;
|
|
||||||
}
|
|
||||||
$this->sectionUpdate($sectionIDtoChange, $part);
|
$this->sectionUpdate($sectionIDtoChange, $part);
|
||||||
$this->createMailEML();
|
$this->createMailEML();
|
||||||
}
|
}
|
||||||
@@ -939,6 +938,7 @@ class Mail
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
// Add the new section to the mixed section
|
// Add the new section to the mixed section
|
||||||
|
$contentID = "";
|
||||||
$sectionID = $this->sectionAddDefault();
|
$sectionID = $this->sectionAddDefault();
|
||||||
$this->sectionAddChild($sectionIDMixed, $sectionID);
|
$this->sectionAddChild($sectionIDMixed, $sectionID);
|
||||||
$finfo = new \finfo(FILEINFO_MIME);
|
$finfo = new \finfo(FILEINFO_MIME);
|
||||||
@@ -1059,6 +1059,7 @@ class Mail
|
|||||||
), $number), 404);
|
), $number), 404);
|
||||||
}
|
}
|
||||||
$part = $this->sectionGet($attachmentIDs[$number]);
|
$part = $this->sectionGet($attachmentIDs[$number]);
|
||||||
|
$res = [];
|
||||||
foreach ($part as $key => $val) {
|
foreach ($part as $key => $val) {
|
||||||
if ($key[0] === "_") {
|
if ($key[0] === "_") {
|
||||||
if (
|
if (
|
||||||
|
|||||||
10
src/Smtp.php
10
src/Smtp.php
@@ -106,6 +106,7 @@ class Smtp
|
|||||||
if ($errstr === "" && $php_errormsg !== "") {
|
if ($errstr === "" && $php_errormsg !== "") {
|
||||||
$errstr = $php_errormsg;
|
$errstr = $php_errormsg;
|
||||||
}
|
}
|
||||||
|
$this->smtpStream = null;
|
||||||
throw new \Exception(sprintf(dgettext(
|
throw new \Exception(sprintf(dgettext(
|
||||||
"domframework",
|
"domframework",
|
||||||
"Can't connect to SMTP server : %s"
|
"Can't connect to SMTP server : %s"
|
||||||
@@ -123,7 +124,11 @@ class Smtp
|
|||||||
$this->putLine("STARTTLS\r\n");
|
$this->putLine("STARTTLS\r\n");
|
||||||
$context["ssl"]["verify_peer_name"] = $this->starttlsCheck;
|
$context["ssl"]["verify_peer_name"] = $this->starttlsCheck;
|
||||||
$context["ssl"]["verify_peer"] = $this->starttlsCheck;
|
$context["ssl"]["verify_peer"] = $this->starttlsCheck;
|
||||||
stream_context_set_option($this->smtpStream, $context);
|
if (version_compare(PHP_VERSION, '8.3.0') <= 0) {
|
||||||
|
stream_context_set_option($this->smtpStream, $context);
|
||||||
|
} else {
|
||||||
|
stream_context_set_options($this->smtpStream, $context);
|
||||||
|
}
|
||||||
// The track_errors permit to create the $php_errormsg in case of
|
// The track_errors permit to create the $php_errormsg in case of
|
||||||
// warning
|
// warning
|
||||||
ini_set('track_errors', 1);
|
ini_set('track_errors', 1);
|
||||||
@@ -135,6 +140,7 @@ class Smtp
|
|||||||
) ===
|
) ===
|
||||||
false
|
false
|
||||||
) {
|
) {
|
||||||
|
$this->smtpStream = null;
|
||||||
throw new \Exception(sprintf(dgettext(
|
throw new \Exception(sprintf(dgettext(
|
||||||
"domframework",
|
"domframework",
|
||||||
"Can't activate STARTTLS %s"
|
"Can't activate STARTTLS %s"
|
||||||
@@ -144,6 +150,7 @@ class Smtp
|
|||||||
$this->debug("STARTTLS ACTIVATED\n");
|
$this->debug("STARTTLS ACTIVATED\n");
|
||||||
}
|
}
|
||||||
} elseif ($this->starttls === "encrypt") {
|
} elseif ($this->starttls === "encrypt") {
|
||||||
|
$this->smtpStream = null;
|
||||||
throw new \Exception(dgettext(
|
throw new \Exception(dgettext(
|
||||||
"domframework",
|
"domframework",
|
||||||
"Server doesn't supports STARTTLS"
|
"Server doesn't supports STARTTLS"
|
||||||
@@ -166,6 +173,7 @@ class Smtp
|
|||||||
$this->putLine("AUTH LOGIN " . base64_encode($this->user) . "\r\n");
|
$this->putLine("AUTH LOGIN " . base64_encode($this->user) . "\r\n");
|
||||||
$this->putLine(base64_encode($this->password) . "\r\n");
|
$this->putLine(base64_encode($this->password) . "\r\n");
|
||||||
} else {
|
} else {
|
||||||
|
$this->smtpStream = null;
|
||||||
throw new \Exception(
|
throw new \Exception(
|
||||||
dgettext(
|
dgettext(
|
||||||
"domframework",
|
"domframework",
|
||||||
|
|||||||
@@ -246,9 +246,14 @@ class Tcpclient
|
|||||||
"capture_peer_cert_chain" => true,
|
"capture_peer_cert_chain" => true,
|
||||||
"SNI_enabled" => true,
|
"SNI_enabled" => true,
|
||||||
]];
|
]];
|
||||||
|
$optionsMerged = [];
|
||||||
$optionsMerged["ssl"] = array_merge($optionsBase["ssl"], $options);
|
$optionsMerged["ssl"] = array_merge($optionsBase["ssl"], $options);
|
||||||
stream_set_blocking($this->socket, true);
|
stream_set_blocking($this->socket, true);
|
||||||
stream_context_set_option($this->socket, $optionsMerged);
|
if (version_compare(PHP_VERSION, '8.3.0') <= 0) {
|
||||||
|
stream_context_set_option($this->socket, $optionsMerged);
|
||||||
|
} else {
|
||||||
|
stream_context_set_options($this->socket, $optionsMerged);
|
||||||
|
}
|
||||||
$php_errormsg = "";
|
$php_errormsg = "";
|
||||||
ini_set("track_errors", 1);
|
ini_set("track_errors", 1);
|
||||||
$rc = @stream_socket_enable_crypto($this->socket, !!$val, $cryptoMethod);
|
$rc = @stream_socket_enable_crypto($this->socket, !!$val, $cryptoMethod);
|
||||||
|
|||||||
@@ -228,6 +228,7 @@ class Tcpserver
|
|||||||
pcntl_signal(SIGTERM, [$this, "sigTERMINT"]);
|
pcntl_signal(SIGTERM, [$this, "sigTERMINT"]);
|
||||||
pcntl_signal(SIGINT, [$this, "sigTERMINT"]);
|
pcntl_signal(SIGINT, [$this, "sigTERMINT"]);
|
||||||
cli_set_process_title($this->processName . " main");
|
cli_set_process_title($this->processName . " main");
|
||||||
|
$sockServer = [];
|
||||||
foreach ($this->addresses as $key => $address) {
|
foreach ($this->addresses as $key => $address) {
|
||||||
$port = $this->ports[$key];
|
$port = $this->ports[$key];
|
||||||
if (filter_var($address, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
|
if (filter_var($address, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
|
||||||
@@ -495,7 +496,11 @@ class Tcpserver
|
|||||||
"verify_peer_name" => false,
|
"verify_peer_name" => false,
|
||||||
]];
|
]];
|
||||||
stream_set_blocking($this->socket, true);
|
stream_set_blocking($this->socket, true);
|
||||||
stream_context_set_option($this->socket, $options);
|
if (version_compare(PHP_VERSION, '8.3.0') <= 0) {
|
||||||
|
stream_context_set_option($this->socket, $options);
|
||||||
|
} else {
|
||||||
|
stream_context_set_options($this->socket, $options);
|
||||||
|
}
|
||||||
return @stream_socket_enable_crypto($this->socket, !!$val, $cryptoMethod);
|
return @stream_socket_enable_crypto($this->socket, !!$val, $cryptoMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user