Skip to content
This repository was archived by the owner on Jan 10, 2023. It is now read-only.

Commit 70f7d67

Browse files
author
Guillermo Cespedes
committed
general updates
1 parent 6f32f02 commit 70f7d67

29 files changed

+582
-222
lines changed

Particle/Apps/.yarnclean

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# jQuery
2+
jquery/src
3+
jquery/external
4+
jquery/dist/core.js
5+
jquery/dist/*.slim*.js
6+
jquery/dist/*.slim*.map
7+
8+
# code coverage directories
9+
coverage
10+
.nyc_output
11+
12+
# build scripts
13+
Makefile
14+
Gulpfile.js
15+
Gruntfile.js
16+
bower.json
17+
# package.json requerido por cypress
18+
19+
# configs
20+
appveyor.yml
21+
circle.yml
22+
codeship-services.yml
23+
codeship-steps.yml
24+
wercker.yml
25+
.tern-project
26+
.gitattributes
27+
.editorconfig
28+
.*ignore
29+
.eslintrc
30+
.jshintrc
31+
.flowconfig
32+
.documentup.json
33+
.yarn-metadata.json
34+
.travis.yml
35+
36+
# misc
37+
*.md
38+
AUTHORS.txt
39+
LICENSE.txt
40+
LICENSE

Particle/Apps/.yarnrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--modules-folder ./yarn-vendor/

Particle/Apps/Addons/appexec/init.php

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
namespace Particle\Apps\Addons;
4+
5+
use Particle\Core;
6+
7+
class appexecAddons extends Core\Controller
8+
{
9+
// private $viewAddons;
10+
11+
public function __construct()
12+
{
13+
/*setting addons*/
14+
$nameAddons = 'appexec';
15+
Core\App::getInstance()->setAppCurrentAddons($nameAddons);
16+
/* end setting addons*/
17+
}
18+
19+
public function appExec($dir, $returnString = false)
20+
{
21+
$ch = curl_init();
22+
23+
curl_setopt($ch, CURLOPT_URL, HOME_URL.$dir);
24+
curl_setopt($ch, CURLOPT_HEADER, 0);
25+
if ($returnString) {
26+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return string
27+
} else {
28+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0); // print buffer
29+
}
30+
31+
$dataString = curl_exec($ch);
32+
33+
curl_close($ch);
34+
35+
if ($returnString) {
36+
return $dataString; // return string
37+
} else {
38+
@ob_clean(); // clear buffer
39+
}
40+
}
41+
}

Particle/Apps/Entities/Person.php

-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
use Spot\EntityInterface as Entity;
66
use Spot\MapperInterface as Mapper;
77

8-
// use Particle\Apps\Entities\Mapper;
9-
108
class Person extends \Spot\Entity
119
{
1210
protected static $table = 'person';

Particle/Apps/Settings/global.inc.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<?php
2+
// phpcs:disable PSR1.Files.SideEffects
23

34
namespace Particle\Apps;
45

56
define('TYPEMODE', 'DEBUG');
67
define('NAMEHOST', 'host');
78
define('SITENAME', 'Site.com');
9+
define('DEFAULT_TITLE', 'PHP FRAMEWORK');
810

911
/* PATHS */
1012
define('ADDONS_FOLDER', 'Addons');
@@ -15,10 +17,9 @@
1517
define('DEFAULT_METHOD', 'index');
1618
define('DEFAULT_LAYOUT', 'default');
1719
define('PUBLIC_IMG_PATH', PUBLIC_PATH.'images'.DS);
18-
define('SMARTY_CACHE_DIR', PARTICLE_PATH_CORE.'tmp'.DS.'cache-smarty'.DS);
19-
define('SMARTY_COMPILE_DIR', PARTICLE_PATH_CORE.'tmp'.DS.'template-compiler-smarty'.DS);
2020
define('SMARTY_CONFIG_DIR', PARTICLE_PATH_APPS.VIEWS_FOLDER.DS.'layout'.DS.DEFAULT_LAYOUT.DS.'configs-smarty'.DS.NAMEHOST.DS);
2121

22+
2223
/* URLs */
2324
define('HOME_URL', 'https://www.site.com/');
2425
define('HOME_URL_STATIC', 'https://www.site.com/');
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"fixturesFolder": "Testing/cypress/fixtures",
3+
"integrationFolder": "Testing/cypress/integration",
4+
"pluginsFile": "Testing/cypress/plugins",
5+
"screenshotsFolder": "Testing/cypress/screenshots",
6+
"supportFile": "Testing/cypress/support",
7+
"videosFolder": "Testing/cypress/videos"
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
// Bootstrap for PHPUnit
4+
5+
// Constants configuration
6+
require_once '../../../../config.php';
7+
configFramework();
8+
9+
// Autoload
10+
require_once PARTICLE_PATH_CORE.'autoload'.DS.'autoload.php';
11+
12+
// init Session
13+
$session = Particle\Core\Session::singleton();
14+
$_SERVER['HTTP_HOST'] = HTTP_HOST;
15+
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
16+
$_SERVER['HTTP_USER_AGENT'] = 'phpunit';
17+
$_SERVER['HTTPS'] = 1;
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<phpunit bootstrap="bootstrap.php"
2+
colors="true"
3+
convertErrorsToExceptions="true"
4+
convertNoticesToExceptions="true"
5+
convertWarningsToExceptions="true"
6+
processIsolation="false"
7+
verbose="true"
8+
printerClass="Sempro\PHPUnitPrettyPrinter\PrettyPrinter">
9+
10+
<testsuites>
11+
<testsuite name="AllTests">
12+
<directory>./tests</directory>
13+
</testsuite>
14+
<!--
15+
<testsuite name="Addons">
16+
<directory>./tests/addons</directory>
17+
</testsuite>
18+
<testsuite name="Controllers">
19+
<directory>./tests/controllers</directory>
20+
</testsuite>
21+
<testsuite name="Addons">
22+
<directory>./tests/error</directory>
23+
</testsuite>
24+
-->
25+
</testsuites>
26+
<php>
27+
<env name="ENV_PHPUNIT" value="false" force="true" />
28+
<ini name="display_errors" value="On" />
29+
<ini name="display_startup_errors" value="On" />
30+
</php>
31+
</phpunit>

Particle/Apps/appExec.php

-28
This file was deleted.

Particle/Apps/composer.json

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
{
22
"require": {
3-
"phpmailer/phpmailer": "dev-master"
3+
"phpmailer/phpmailer": "~6.1",
4+
"google/apiclient": "~2.4",
5+
"facebook/graph-sdk": "~5.7",
6+
"stevenmaguire/oauth2-microsoft": "~2.2"
7+
},
8+
"config": {
9+
"optimize-autoloader": true,
10+
"classmap-authoritative": true
411
}
512
}

Particle/Apps/package.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "php-framework",
3+
"version": "1.0.0",
4+
"scripts": {
5+
"autoclean": "yarn autoclean --force"
6+
},
7+
"private": true,
8+
"flat": false,
9+
"dependencies": {
10+
"bootstrap": "^3.4.1"
11+
},
12+
"devDependencies": {
13+
"cypress": "^3.6.0"
14+
}
15+
}

Particle/Apps/yarn-error.log

Whitespace-only changes.

Particle/Cli/crontab.php

+23-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,30 @@
11
<?php
22
namespace Particle;
33

4+
use Particle\Core;
5+
use Particle\Apps\Controllers;
6+
use Particle\Apps\Addons;
7+
48
// Init Framework
59
require_once dirname(__FILE__).'/../../config.php';
6-
configFramework();
10+
11+
$blnConfigFramework = configFramework();
12+
if (!$blnConfigFramework) {
13+
echo "err.config";
14+
return false;
15+
}
16+
717
require_once PARTICLE_PATH_CORE.'autoload'.DS.'autoload.php';
18+
try {
19+
// Clear SESSION_GC
20+
Core\Crontab::run();
821

9-
Core\Crontab::run();
22+
// Only PROD
23+
if (TYPEMODE == 'PROD') {
24+
if (date("Hi") == "0015" || date("Hi") == "0016") {
25+
return true;
26+
}
27+
}
28+
} catch (\Exception $e) {
29+
echo 'Exception: '.$e->getMessage();
30+
}

Particle/Core/Controller.php

+13-13
Original file line numberDiff line numberDiff line change
@@ -109,20 +109,20 @@ final protected static function getInt($key, $array = null, $default = 0)
109109
$array = $_POST;
110110
}
111111

112-
113112
if (isset($array[$key]) && !empty($array[$key])) {
114-
if (!isset($_SESSION) || (isset($_SESSION) && $array != $_SESSION)) {
115-
if ($array == $_GET) {
116-
$input = INPUT_GET;
117-
} elseif ($array == $_POST) {
118-
$input = INPUT_POST;
119-
} elseif ($array == $_COOKIE) {
120-
$input = INPUT_COOKIE;
121-
} else {
122-
return false;
123-
}
124-
$array[$key] = filter_input($input, $key, FILTER_VALIDATE_INT);
125-
}
113+
// TODO: check this
114+
// if (!isset($_SESSION) || (isset($_SESSION) && $array != $_SESSION)) {
115+
// if ($array == $_GET) {
116+
// $input = INPUT_GET;
117+
// } elseif ($array == $_POST) {
118+
// $input = INPUT_POST;
119+
// } elseif ($array == $_COOKIE) {
120+
// $input = INPUT_COOKIE;
121+
// } else {
122+
// return false;
123+
// }
124+
// $array[$key] = filter_input($input, $key, FILTER_VALIDATE_INT); // FILTER_SANITIZE_NUMBER_INT
125+
// }
126126
$filterInt = Core\Security::filterInt($array[$key], $default);
127127
return $filterInt;
128128
}

Particle/Core/Cookies.php

+16-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ public static function write($name, $value = null, $duration = 0, $httponly = tr
5252
} else {
5353
$expire = time()+((int) $duration);
5454
}
55-
55+
// TODO: Migrate PHP > 7.3 https://wiki.php.net/rfc/same-site-cookie
56+
if ($secure) {
57+
$path .= '; SameSite=Strict';
58+
}
5659
$valueEncrypt = Core\Security::encrypt((string)$value, COOKIE_KEY, SALT_CODE);
5760

5861
// Writes the cookie
@@ -89,4 +92,16 @@ public static function delete($name)
8992

9093
return false;
9194
}
95+
public static function writeBrowserCookie($strName, $value, $expire = 0)
96+
{
97+
$domain = ini_get('session.cookie_domain');
98+
$path = ini_get('session.cookie_path');
99+
$secure = isset($_SERVER['HTTPS']);
100+
$bWriteCookie = setcookie($strName, $value, $expire, $path, $domain, $secure, false);
101+
if ($bWriteCookie === true) {
102+
$_COOKIE[$strName] = $value;
103+
return true;
104+
}
105+
return false;
106+
}
92107
}

Particle/Core/Crontab.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ public static function run()
1717
if (SESSION_GC == 'crontab') {
1818
$session = Core\Session::singleton();
1919
$session->purge();
20+
echo "run.purge";
2021
}
2122
}
2223
}
23-
// crontab -l | { cat; echo "* 1 * * * /usr/local/php7/bin/php /var/www/tufiesta.grupolfmedia.com/htdocs/Particle/Cli/crontab.php >/dev/null 2>&1"; } | crontab -
24+
// crontab -l | { cat; echo "15 * * * * /usr/local/php7/bin/php /var/www/webdisk/site.com/htdocs/Particle/Cli/crontab.php >/dev/null 2>&1"; } | crontab -

Particle/Core/Debug.php

+7-3
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,19 @@ final public static function savelogfile($id, $location, $message, $filename = '
2020
//
2121
// Usage: Core\Debug::savelogfile(1, 'index.php:33', 'Mensaje de Error');
2222
//
23-
$filename = $_SERVER['DOCUMENT_ROOT'].DS.$filename.'.log';
23+
$filename = ROOT.$filename.'.log';
2424

2525
$file = fopen($filename, 'a');
2626

2727
if (!is_string($location) || !is_string($message)) {
2828
throw new \Exception('Incorrect datatype for save log');
2929
}
30-
$ip = Security::getIp();
31-
fwrite($file, '['.date('Y-m-d H:i:s')."][$ip][ERROR $id][$location][$message]".PHP_EOL);
30+
$ip = Security::getIPNoFORWARDED();
31+
$type = 'INFO';
32+
if ($id > 0) {
33+
$type = 'ERROR '. $id;
34+
}
35+
fwrite($file, '['.date('Y-m-d H:i:s')."][$ip][$type][$location][$message]".PHP_EOL);
3236

3337
fclose($file);
3438
}

0 commit comments

Comments
 (0)