@@ -49,20 +49,20 @@ discard block |
||
49 | 49 | $this->log->new_message('Enviando factura a: '.$email); |
50 | 50 | $mail->addAddress($email, $customer->nombre); |
51 | 51 | $mail->Subject = $subject; |
52 | - $mail->AltBody = strip_tags(str_replace("<br>", "\n",html_entity_decode($this->emailConfig->emailsubject))); |
|
52 | + $mail->AltBody = strip_tags(str_replace("<br>", "\n", html_entity_decode($this->emailConfig->emailsubject))); |
|
53 | 53 | $this->emailAdditionalInfo($mail, $customer); |
54 | 54 | $mail->msgHTML(html_entity_decode($this->emailConfig->emailsubject)); |
55 | 55 | $mail->isHTML(true); |
56 | - $mail->addAttachment('tmp/' . FS_TMP_NAME . 'enviar/' . $archivo); |
|
56 | + $mail->addAttachment('tmp/'.FS_TMP_NAME.'enviar/'.$archivo); |
|
57 | 57 | $this->emailAdditionalAttachments($mail); |
58 | 58 | if ($companyInformation->mail_connect($mail) && $mail->send()) { |
59 | - $invoice->femail = \date('d-m-Y');; |
|
59 | + $invoice->femail = \date('d-m-Y'); ; |
|
60 | 60 | $invoice->save(); |
61 | 61 | $companyInformation->save_mail($mail); |
62 | - } else { |
|
63 | - $this->log->new_error("Error al enviar el email: " . $mail->ErrorInfo); |
|
62 | + }else { |
|
63 | + $this->log->new_error("Error al enviar el email: ".$mail->ErrorInfo); |
|
64 | 64 | } |
65 | - unlink('tmp/' . FS_TMP_NAME . 'enviar/' . $archivo); |
|
65 | + unlink('tmp/'.FS_TMP_NAME.'enviar/'.$archivo); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | public function sendgridEmailTest() |
@@ -90,9 +90,9 @@ discard block |
||
90 | 90 | $email->setFrom($this->emailConfig->apisenderemail, $this->emailConfig->apisendername); |
91 | 91 | $email->setSubject($subject); |
92 | 92 | $email->addTo($customer->email, $customer->nombre); |
93 | - $email->addContent("text/plain", strip_tags(str_replace("<br>", "\n",html_entity_decode($this->emailConfig->emailsubject))),); |
|
93 | + $email->addContent("text/plain", strip_tags(str_replace("<br>", "\n", html_entity_decode($this->emailConfig->emailsubject))),); |
|
94 | 94 | $email->addContent("text/html", html_entity_decode($this->emailConfig->emailsubject)); |
95 | - $file_encoded = base64_encode(file_get_contents('tmp/' . FS_TMP_NAME . 'enviar/' . $archivo)); |
|
95 | + $file_encoded = base64_encode(file_get_contents('tmp/'.FS_TMP_NAME.'enviar/'.$archivo)); |
|
96 | 96 | $email->addAttachment( |
97 | 97 | $file_encoded, |
98 | 98 | "application/pdf", |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | |
112 | 112 | public function mailjetEmailTest() |
113 | 113 | { |
114 | - $mj = new \Mailjet\Client($this->emailConfig->apikey,$this->emailConfig->apisecret,true,['version' => 'v3.1']); |
|
114 | + $mj = new \Mailjet\Client($this->emailConfig->apikey, $this->emailConfig->apisecret, true, ['version' => 'v3.1']); |
|
115 | 115 | $body = [ |
116 | 116 | 'Messages' => [ |
117 | 117 | [ |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | |
139 | 139 | public function mailjetEmail(&$companyInformation, &$invoice, &$customer, $user, $archivo, $subject) |
140 | 140 | { |
141 | - $mj = new \Mailjet\Client($this->emailConfig->apikey,$this->emailConfig->apisecret,true,['version' => 'v3.1']); |
|
141 | + $mj = new \Mailjet\Client($this->emailConfig->apikey, $this->emailConfig->apisecret, true, ['version' => 'v3.1']); |
|
142 | 142 | $body = [ |
143 | 143 | 'Messages' => [ |
144 | 144 | [ |
@@ -153,14 +153,14 @@ discard block |
||
153 | 153 | ] |
154 | 154 | ], |
155 | 155 | 'Subject' => $subject, |
156 | - 'TextPart' => strip_tags(str_replace("<br>", "\n",html_entity_decode($this->emailConfig->emailsubject))), |
|
156 | + 'TextPart' => strip_tags(str_replace("<br>", "\n", html_entity_decode($this->emailConfig->emailsubject))), |
|
157 | 157 | 'HTMLPart' => html_entity_decode($this->emailConfig->emailsubject), |
158 | 158 | 'Attachments' => [ |
159 | 159 | [ |
160 | 160 | 'ContentType' => 'application/pdf', |
161 | 161 | 'Filename' => $invoice->numero2.'.pdf', |
162 | 162 | 'Base64Content' => base64_encode( |
163 | - file_get_contents('tmp/' . FS_TMP_NAME . 'enviar/' . $archivo) |
|
163 | + file_get_contents('tmp/'.FS_TMP_NAME.'enviar/'.$archivo) |
|
164 | 164 | ) |
165 | 165 | ] |
166 | 166 | ] |
@@ -175,9 +175,9 @@ discard block |
||
175 | 175 | public function invoiceEmail(&$companyInformation, &$invoice, &$customer, $user, $archivo) |
176 | 176 | { |
177 | 177 | if (file_exists('tmp/'.FS_TMP_NAME.'enviar/'.$archivo)) { |
178 | - $subject = fs_fix_html($companyInformation->nombre) . |
|
179 | - ' - Su Factura ' . $invoice->codigo . ' ' . $invoice->numero2; |
|
180 | - switch($this->emailConfig->tiposervicio) { |
|
178 | + $subject = fs_fix_html($companyInformation->nombre). |
|
179 | + ' - Su Factura '.$invoice->codigo.' '.$invoice->numero2; |
|
180 | + switch ($this->emailConfig->tiposervicio) { |
|
181 | 181 | case "sendgrid": |
182 | 182 | $this->sendgridEmail($companyInformation, $invoice, $customer, $user, $archivo, $subject); |
183 | 183 | break; |
@@ -213,8 +213,8 @@ discard block |
||
213 | 213 | // } else { |
214 | 214 | // $this->log->new_error("Error al enviar el email: " . $mail->ErrorInfo); |
215 | 215 | // } |
216 | - unlink('tmp/' . FS_TMP_NAME . 'enviar/' . $archivo); |
|
217 | - } else { |
|
216 | + unlink('tmp/'.FS_TMP_NAME.'enviar/'.$archivo); |
|
217 | + }else { |
|
218 | 218 | $this->log->new_error('Imposible generar el PDF.'); |
219 | 219 | } |
220 | 220 | } |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | trim($this->rc->filter_request('email_copia')), |
228 | 228 | $customer->nombre |
229 | 229 | ); |
230 | - } else { |
|
230 | + }else { |
|
231 | 231 | $mail->addCC( |
232 | 232 | trim($this->rc->filter_request('email_copia')), |
233 | 233 | $customer->nombre |
@@ -252,19 +252,19 @@ discard block |
||
252 | 252 | : $customer->email; |
253 | 253 | $this->log->new_message('Enviando Estado de cuenta a: '.$email); |
254 | 254 | $mail->addAddress($email, $customer->nombre); |
255 | - $elSubject = ': Su Estado de cuenta al '. \date('d-m-Y'); |
|
256 | - $mail->Subject = fs_fix_html($empresa->nombre) . $elSubject; |
|
255 | + $elSubject = ': Su Estado de cuenta al '.\date('d-m-Y'); |
|
256 | + $mail->Subject = fs_fix_html($empresa->nombre).$elSubject; |
|
257 | 257 | $mail->AltBody = strip_tags($_POST['mensaje']); |
258 | 258 | $this->emailAdditionalAttachments($mail); |
259 | 259 | $mail->msgHTML(nl2br($mail->AltBody)); |
260 | 260 | $mail->isHTML(true); |
261 | - $mail->addAttachment('tmp/' . FS_TMP_NAME . 'enviar/' . $archivo); |
|
261 | + $mail->addAttachment('tmp/'.FS_TMP_NAME.'enviar/'.$archivo); |
|
262 | 262 | $this->emailAdditionalAttachments($mail); |
263 | 263 | if ($empresa->mail_connect($mail) && $mail->send()) { |
264 | 264 | $empresa->save_mail($mail); |
265 | - } else { |
|
266 | - $this->log->new_error("Error al enviar el email: " . $mail->ErrorInfo); |
|
265 | + }else { |
|
266 | + $this->log->new_error("Error al enviar el email: ".$mail->ErrorInfo); |
|
267 | 267 | } |
268 | - unlink('tmp/' . FS_TMP_NAME . 'enviar/' . $archivo); |
|
268 | + unlink('tmp/'.FS_TMP_NAME.'enviar/'.$archivo); |
|
269 | 269 | } |
270 | 270 | } |
271 | 271 | \ No newline at end of file |
@@ -9,21 +9,21 @@ discard block |
||
9 | 9 | function assertEqual($a, $b) { |
10 | 10 | if ($a != $b) { |
11 | 11 | global $failure; |
12 | - $failure ++; |
|
13 | - echo "\n FAIL: '" . $a . "' != '" . $b . "'"; |
|
14 | - } else { |
|
12 | + $failure++; |
|
13 | + echo "\n FAIL: '".$a."' != '".$b."'"; |
|
14 | + }else { |
|
15 | 15 | global $success; |
16 | - $success ++; |
|
16 | + $success++; |
|
17 | 17 | echo "\n success"; |
18 | 18 | } |
19 | 19 | } |
20 | 20 | |
21 | 21 | function printHeader($text) { |
22 | - echo "\n " . $text . " test:"; |
|
22 | + echo "\n ".$text." test:"; |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | function printSubHeader($text) { |
26 | - echo "\n " . $text . ":"; |
|
26 | + echo "\n ".$text.":"; |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | |
@@ -133,9 +133,9 @@ discard block |
||
133 | 133 | |
134 | 134 | |
135 | 135 | if ($failure == 0) { |
136 | - echo "\n\nALL " . $success . " TESTS SUCCESSFUL\n\n"; |
|
137 | -} else { |
|
138 | - echo "\n\n" . $failure . "/" . ($failure + $success) . " FAILURES OCCURRED\n\n"; |
|
136 | + echo "\n\nALL ".$success." TESTS SUCCESSFUL\n\n"; |
|
137 | +}else { |
|
138 | + echo "\n\n".$failure."/".($failure + $success)." FAILURES OCCURRED\n\n"; |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | ?> |
@@ -6,13 +6,13 @@ |
||
6 | 6 | |
7 | 7 | class Ecdsa { |
8 | 8 | |
9 | - public static function sign ($message, $privateKey) { |
|
9 | + public static function sign($message, $privateKey) { |
|
10 | 10 | $signature = null; |
11 | 11 | openssl_sign($message, $signature, $privateKey->openSslPrivateKey, OPENSSL_ALGO_SHA256); |
12 | 12 | return new Signature($signature); |
13 | 13 | } |
14 | 14 | |
15 | - public static function verify ($message, $signature, $publicKey) { |
|
15 | + public static function verify($message, $signature, $publicKey) { |
|
16 | 16 | $success = openssl_verify($message, $signature->toDer(), $publicKey->openSslPublicKey, OPENSSL_ALGO_SHA256); |
17 | 17 | if ($success == 1) { |
18 | 18 | return true; |
@@ -3,7 +3,7 @@ |
||
3 | 3 | namespace EllipticCurve\Utils; |
4 | 4 | |
5 | 5 | class File { |
6 | - static function read($path, $mode="r") { |
|
6 | + static function read($path, $mode = "r") { |
|
7 | 7 | $file = fopen($path, $mode); |
8 | 8 | $content = fread($file, filesize($path)); |
9 | 9 | fclose($file); |
@@ -5,23 +5,23 @@ |
||
5 | 5 | |
6 | 6 | class Signature { |
7 | 7 | |
8 | - function __construct ($der) { |
|
8 | + function __construct($der) { |
|
9 | 9 | $this->der = $der; |
10 | 10 | } |
11 | 11 | |
12 | - function toDer () { |
|
12 | + function toDer() { |
|
13 | 13 | return $this->der; |
14 | 14 | } |
15 | 15 | |
16 | - function toBase64 () { |
|
16 | + function toBase64() { |
|
17 | 17 | return base64_encode($this->der); |
18 | 18 | } |
19 | 19 | |
20 | - static function fromDer ($str) { |
|
20 | + static function fromDer($str) { |
|
21 | 21 | return new Signature($str); |
22 | 22 | } |
23 | 23 | |
24 | - static function fromBase64 ($str) { |
|
24 | + static function fromBase64($str) { |
|
25 | 25 | return new Signature(base64_decode($str)); |
26 | 26 | } |
27 | 27 | } |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | |
6 | 6 | |
7 | 7 | class PrivateKey { |
8 | - function __construct($curve="secp256k1", $openSslPrivateKey=null) { |
|
8 | + function __construct($curve = "secp256k1", $openSslPrivateKey = null) { |
|
9 | 9 | if (is_null($openSslPrivateKey)) { |
10 | 10 | $config = array( |
11 | 11 | "digest_alg" => "sha256", |
@@ -30,15 +30,15 @@ discard block |
||
30 | 30 | return new PublicKey($openSslPublicKey); |
31 | 31 | } |
32 | 32 | |
33 | - function toString () { |
|
33 | + function toString() { |
|
34 | 34 | return base64_encode($this->toDer()); |
35 | 35 | } |
36 | 36 | |
37 | - function toDer () { |
|
37 | + function toDer() { |
|
38 | 38 | $pem = $this->toPem(); |
39 | 39 | |
40 | 40 | $lines = array(); |
41 | - foreach(explode("\n", $pem) as $value) { |
|
41 | + foreach (explode("\n", $pem) as $value) { |
|
42 | 42 | if (substr($value, 0, 5) !== "-----") { |
43 | 43 | array_push($lines, $value); |
44 | 44 | } |
@@ -49,30 +49,30 @@ discard block |
||
49 | 49 | return base64_decode($pem_data); |
50 | 50 | } |
51 | 51 | |
52 | - function toPem () { |
|
52 | + function toPem() { |
|
53 | 53 | openssl_pkey_export($this->openSslPrivateKey, $out, null); |
54 | 54 | return $out; |
55 | 55 | } |
56 | 56 | |
57 | - static function fromPem ($str) { |
|
57 | + static function fromPem($str) { |
|
58 | 58 | $rebuilt = array(); |
59 | - foreach(explode("\n", $str) as $line) { |
|
59 | + foreach (explode("\n", $str) as $line) { |
|
60 | 60 | $line = trim($line); |
61 | 61 | if (strlen($line) > 1) { |
62 | 62 | array_push($rebuilt, $line); |
63 | 63 | } |
64 | 64 | }; |
65 | - $rebuilt = join("\n", $rebuilt) . "\n"; |
|
65 | + $rebuilt = join("\n", $rebuilt)."\n"; |
|
66 | 66 | return new PrivateKey(null, openssl_get_privatekey($rebuilt)); |
67 | 67 | } |
68 | 68 | |
69 | - static function fromDer ($str) { |
|
69 | + static function fromDer($str) { |
|
70 | 70 | $pem_data = base64_encode($str); |
71 | - $pem = "-----BEGIN EC PRIVATE KEY-----\n" . substr($pem_data, 0, 64) . "\n" . substr($pem_data, 64, 64) . "\n" . substr($pem_data, 128, 64) . "\n-----END EC PRIVATE KEY-----\n"; |
|
71 | + $pem = "-----BEGIN EC PRIVATE KEY-----\n".substr($pem_data, 0, 64)."\n".substr($pem_data, 64, 64)."\n".substr($pem_data, 128, 64)."\n-----END EC PRIVATE KEY-----\n"; |
|
72 | 72 | return new PrivateKey(null, openssl_get_privatekey($pem)); |
73 | 73 | } |
74 | 74 | |
75 | - static function fromString ($str) { |
|
75 | + static function fromString($str) { |
|
76 | 76 | return PrivateKey::fromDer(base64_decode($str)); |
77 | 77 | } |
78 | 78 |
@@ -5,20 +5,20 @@ discard block |
||
5 | 5 | |
6 | 6 | class PublicKey { |
7 | 7 | |
8 | - function __construct ($pem) { |
|
8 | + function __construct($pem) { |
|
9 | 9 | $this->pem = $pem; |
10 | 10 | $this->openSslPublicKey = openssl_get_publickey($pem); |
11 | 11 | } |
12 | 12 | |
13 | - function toString () { |
|
13 | + function toString() { |
|
14 | 14 | return base64_encode($this->toDer()); |
15 | 15 | } |
16 | 16 | |
17 | - function toDer () { |
|
17 | + function toDer() { |
|
18 | 18 | $pem = $this->toPem(); |
19 | 19 | |
20 | 20 | $lines = array(); |
21 | - foreach(explode("\n", $pem) as $value) { |
|
21 | + foreach (explode("\n", $pem) as $value) { |
|
22 | 22 | if (substr($value, 0, 5) !== "-----") { |
23 | 23 | array_push($lines, $value); |
24 | 24 | } |
@@ -29,29 +29,29 @@ discard block |
||
29 | 29 | return base64_decode($pem_data); |
30 | 30 | } |
31 | 31 | |
32 | - function toPem () { |
|
32 | + function toPem() { |
|
33 | 33 | return $this->pem; |
34 | 34 | } |
35 | 35 | |
36 | - static function fromPem ($str) { |
|
36 | + static function fromPem($str) { |
|
37 | 37 | $rebuilt = array(); |
38 | - foreach(explode("\n", $str) as $line) { |
|
38 | + foreach (explode("\n", $str) as $line) { |
|
39 | 39 | $line = trim($line); |
40 | 40 | if (strlen($line) > 1) { |
41 | 41 | array_push($rebuilt, $line); |
42 | 42 | } |
43 | 43 | }; |
44 | - $rebuilt = join("\n", $rebuilt) . "\n"; |
|
44 | + $rebuilt = join("\n", $rebuilt)."\n"; |
|
45 | 45 | return new PublicKey($rebuilt); |
46 | 46 | } |
47 | 47 | |
48 | - static function fromDer ($str) { |
|
48 | + static function fromDer($str) { |
|
49 | 49 | $pem_data = base64_encode($str); |
50 | - $pem = "-----BEGIN PUBLIC KEY-----\n" . substr($pem_data, 0, 64) . "\n" . substr($pem_data, 64) . "\n-----END PUBLIC KEY-----\n"; |
|
50 | + $pem = "-----BEGIN PUBLIC KEY-----\n".substr($pem_data, 0, 64)."\n".substr($pem_data, 64)."\n-----END PUBLIC KEY-----\n"; |
|
51 | 51 | return new PublicKey($pem); |
52 | 52 | } |
53 | 53 | |
54 | - static function fromString ($str) { |
|
54 | + static function fromString($str) { |
|
55 | 55 | return PublicKey::fromDer(base64_decode($str)); |
56 | 56 | } |
57 | 57 |
@@ -2,5 +2,5 @@ |
||
2 | 2 | |
3 | 3 | // Don't redefine the functions if included multiple times. |
4 | 4 | if (!\function_exists('GuzzleHttp\describe_type')) { |
5 | - require __DIR__ . '/functions.php'; |
|
5 | + require __DIR__.'/functions.php'; |
|
6 | 6 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | $options['allow_redirects'] = self::$defaultSettings; |
60 | 60 | } elseif (!\is_array($options['allow_redirects'])) { |
61 | 61 | throw new \InvalidArgumentException('allow_redirects must be true, false, or array'); |
62 | - } else { |
|
62 | + }else { |
|
63 | 63 | // Merge the default settings with the provided settings |
64 | 64 | $options['allow_redirects'] += self::$defaultSettings; |
65 | 65 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | } |
70 | 70 | |
71 | 71 | return $fn($request, $options) |
72 | - ->then(function (ResponseInterface $response) use ($request, $options) { |
|
72 | + ->then(function(ResponseInterface $response) use ($request, $options) { |
|
73 | 73 | return $this->checkRedirect($request, $options, $response); |
74 | 74 | }); |
75 | 75 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | private function withTracking(PromiseInterface $promise, string $uri, int $statusCode): PromiseInterface |
125 | 125 | { |
126 | 126 | return $promise->then( |
127 | - static function (ResponseInterface $response) use ($uri, $statusCode) { |
|
127 | + static function(ResponseInterface $response) use ($uri, $statusCode) { |
|
128 | 128 | // Note that we are pushing to the front of the list as this |
129 | 129 | // would be an earlier response than what is currently present |
130 | 130 | // in the history header. |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | ) { |
193 | 193 | $uri = $request->getUri()->withUserInfo(''); |
194 | 194 | $modify['set_headers']['Referer'] = (string) $uri; |
195 | - } else { |
|
195 | + }else { |
|
196 | 196 | $modify['remove_headers'][] = 'Referer'; |
197 | 197 | } |
198 | 198 |