Commit f0e4f3d4 by Juan Montilla

Merge branch 'developJC'

parents 083b65a5 6e6ebfe1
Showing with 4643 additions and 15 deletions
......@@ -14,15 +14,17 @@
# ENVIRONMENT
#--------------------------------------------------------------------
CI_ENVIRONMENT = development
CI_ENVIRONMENT = production
#--------------------------------------------------------------------
# APP
#--------------------------------------------------------------------
# app.baseURL = ''
app.baseURL = 'https://tbw2223-12-mrtjcmh.oa.r.appspot.com'
# If you have trouble with `.`, you could also use `_`.
# app_baseURL = ''
# app_baseURL = 'http://localhost'
# app.forceGlobalSecureRequests = false
# app.CSPEnabled = false
......@@ -30,6 +32,19 @@ CI_ENVIRONMENT = development
# DATABASE
#--------------------------------------------------------------------
#database.default.hostname = localhost
#database.default.database = webapp
#database.default.username = webapp_user
#database.default.password = FOE6f35AUtbL015D
#database.default.DBDriver = MySQLi
database.default.hostname = 34.65.71.245
database.default.database = webapp
database.default.username = mrtjcmh
database.default.password = d7c+}rB+Ezouc<ak
database.default.DBDriver = MySQLi
# database.default.hostname = localhost
# database.default.database = ci4
# database.default.username = root
......
# This file specifies files that are *not* uploaded to Google Cloud
# using gcloud. It follows the same syntax as .gitignore, with the addition of
# "#!include" directives (which insert the entries of the given .gitignore-style
# file at that point).
#
# For more information, run:
# $ gcloud topic gcloudignore
#
.gcloudignore
# If you would like to upload your .git directory, .gitignore file or files
# from your .gitignore file, remove the corresponding line
# below:
.git
.gitignore
# PHP Composer dependencies:
/vendor/
\ No newline at end of file
# Ignorar la carpeta writable/debugbar
/writable/debugbar/
\ No newline at end of file
# Wa2Eat
# Wa2Eat
## Requisitos iniciales (Primera reunión con el cliente)
- **Registro de usuarios:** La página debe permitir a los usuarios registrarse y crear una cuenta para poder utilizar las funciones de la página. Los usuarios deben poder crear un perfil con información personal básica como su nombre y dirección de correo electrónico.
- **Función de ingreso de ingredientes:** La página debe permitir a los usuarios ingresar una lista de ingredientes que tienen en su hogar, junto con su fecha de caducidad. Esto ayudará a la página a ofrecer recomendaciones personalizadas de recetas para cada usuario.
- **Recomendaciones de recetas:** La página debe contar con una función que permita a los usuarios recibir recomendaciones de recetas basadas en los ingredientes que tienen en su hogar. Estas recomendaciones deberán estar ordenadas por orden de relevancia y podrán incluir también sugerencias para ingredientes que falten en la lista.
- **Función de ingreso de recetas:** La página debe permitir a los usuarios ingresar recetas con los ingredientes de cada una. Además, se tendrá la opción de añadir características adicionales para la receta, como la elaboración o el origen de la misma.
- **Filtros de búsqueda:** La página debe contar con diferentes filtros de búsqueda para que los usuarios puedan buscar recetas por temporada, país de origen, tipo de comida, etc. Esto ayudará a los usuarios a encontrar recetas específicas que se ajusten a sus necesidades.
- **Función de búsqueda de recetas:** La página debe contar con una función que permita a los usuarios buscar recetas en función de una serie de ingredientes introducidos, incluso si estos ingredientes no se encuentran en su lista de ingredientes en su cuenta.
- **Función de búsqueda de recetas:** La página debe contar con una función que permita a los usuarios buscar recetas que se encuentren disponibles.
- **Recetas detalladas:** Cada receta debe contar con una lista detallada de ingredientes, pasos a seguir y recomendaciones para la presentación de la comida. Además, es importante que se incluyan fotografías de las recetas para que los usuarios puedan ver cómo debe quedar la comida final.
- **Diseño y navegación:** Es importante que la página tenga un diseño atractivo y una navegación sencilla e intuitiva. Esto facilitará la búsqueda y el uso de las diferentes funciones de la página para los usuarios.
......
runtime: php74
handlers:
# Serve images as static resources.
- url: /(.+\.(gif|png|jpg|jpeg|ico|css|js|woff|woff2))$
static_files: public/\1
upload: .+\.(gif|png|jpg|ico|jpeg|css|js|woff|woff2)$
# Serve php scripts.
- url: .*
script: auto
runtime_config:
document_root: public
\ No newline at end of file
<?php
namespace Config;
use CodeIgniter\Config\AutoloadConfig;
/**
* -------------------------------------------------------------------
* AUTOLOADER CONFIGURATION
* -------------------------------------------------------------------
*
* This file defines the namespaces and class maps so the Autoloader
* can find the files as needed.
*
* NOTE: If you use an identical key in $psr4 or $classmap, then
* the values in this file will overwrite the framework's values.
*/
class Autoload extends AutoloadConfig
{
/**
* -------------------------------------------------------------------
* Namespaces
* -------------------------------------------------------------------
* This maps the locations of any namespaces in your application to
* their location on the file system. These are used by the autoloader
* to locate files the first time they have been instantiated.
*
* The '/app' and '/system' directories are already mapped for you.
* you may change the name of the 'App' namespace if you wish,
* but this should be done prior to creating any namespaced classes,
* else you will need to modify all of those classes for this to work.
*
* Prototype:
* $psr4 = [
* 'CodeIgniter' => SYSTEMPATH,
* 'App' => APPPATH
* ];
*
* @var array<string, array<int, string>|string>
* @phpstan-var array<string, string|list<string>>
*/
public $psr4 = [
APP_NAMESPACE => APPPATH, // For custom app namespace
'Config' => APPPATH . 'Config',
];
/**
* -------------------------------------------------------------------
* Class Map
* -------------------------------------------------------------------
* The class map provides a map of class names and their exact
* location on the drive. Classes loaded in this manner will have
* slightly faster performance because they will not have to be
* searched for within one or more directories as they would if they
* were being autoloaded through a namespace.
*
* Prototype:
* $classmap = [
* 'MyClass' => '/path/to/class/file.php'
* ];
*
* @var array<string, string>
*/
public $classmap = [];
/**
* -------------------------------------------------------------------
* Files
* -------------------------------------------------------------------
* The files array provides a list of paths to __non-class__ files
* that will be autoloaded. This can be useful for bootstrap operations
* or for loading functions.
*
* Prototype:
* $files = [
* '/path/to/my/file.php',
* ];
*
* @var string[]
* @phpstan-var list<string>
*/
public $files = [];
/**
* -------------------------------------------------------------------
* Helpers
* -------------------------------------------------------------------
* Prototype:
* $helpers = [
* 'form',
* ];
*
* @var string[]
* @phpstan-var list<string>
*/
public $helpers = [];
}
<?php
/*
|--------------------------------------------------------------------------
| ERROR DISPLAY
|--------------------------------------------------------------------------
| In development, we want to show as many errors as possible to help
| make sure they don't make it to production. And save us hours of
| painful debugging.
*/
error_reporting(-1);
ini_set('display_errors', '1');
/*
|--------------------------------------------------------------------------
| DEBUG BACKTRACES
|--------------------------------------------------------------------------
| If true, this constant will tell the error screens to display debug
| backtraces along with the other error information. If you would
| prefer to not see this, set this value to false.
*/
defined('SHOW_DEBUG_BACKTRACE') || define('SHOW_DEBUG_BACKTRACE', true);
/*
|--------------------------------------------------------------------------
| DEBUG MODE
|--------------------------------------------------------------------------
| Debug mode is an experimental flag that can allow changes throughout
| the system. This will control whether Kint is loaded, and a few other
| items. It can always be used within your own application too.
*/
defined('CI_DEBUG') || define('CI_DEBUG', true);
<?php
/*
|--------------------------------------------------------------------------
| ERROR DISPLAY
|--------------------------------------------------------------------------
| Don't show ANY in production environments. Instead, let the system catch
| it and display a generic error message.
*/
ini_set('display_errors', '0');
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
/*
|--------------------------------------------------------------------------
| DEBUG MODE
|--------------------------------------------------------------------------
| Debug mode is an experimental flag that can allow changes throughout
| the system. It's not widely used currently, and may not survive
| release of the framework.
*/
defined('CI_DEBUG') || define('CI_DEBUG', false);
<?php
/*
|--------------------------------------------------------------------------
| ERROR DISPLAY
|--------------------------------------------------------------------------
| In development, we want to show as many errors as possible to help
| make sure they don't make it to production. And save us hours of
| painful debugging.
*/
error_reporting(-1);
ini_set('display_errors', '1');
/*
|--------------------------------------------------------------------------
| DEBUG BACKTRACES
|--------------------------------------------------------------------------
| If true, this constant will tell the error screens to display debug
| backtraces along with the other error information. If you would
| prefer to not see this, set this value to false.
*/
defined('SHOW_DEBUG_BACKTRACE') || define('SHOW_DEBUG_BACKTRACE', true);
/*
|--------------------------------------------------------------------------
| DEBUG MODE
|--------------------------------------------------------------------------
| Debug mode is an experimental flag that can allow changes throughout
| the system. It's not widely used currently, and may not survive
| release of the framework.
*/
defined('CI_DEBUG') || define('CI_DEBUG', true);
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
class CURLRequest extends BaseConfig
{
/**
* --------------------------------------------------------------------------
* CURLRequest Share Options
* --------------------------------------------------------------------------
*
* Whether share options between requests or not.
*
* If true, all the options won't be reset between requests.
* It may cause an error request with unnecessary headers.
*/
public bool $shareOptions = true;
}
<?php
namespace Config;
use CodeIgniter\Cache\Handlers\DummyHandler;
use CodeIgniter\Cache\Handlers\FileHandler;
use CodeIgniter\Cache\Handlers\MemcachedHandler;
use CodeIgniter\Cache\Handlers\PredisHandler;
use CodeIgniter\Cache\Handlers\RedisHandler;
use CodeIgniter\Cache\Handlers\WincacheHandler;
use CodeIgniter\Config\BaseConfig;
class Cache extends BaseConfig
{
/**
* --------------------------------------------------------------------------
* Primary Handler
* --------------------------------------------------------------------------
*
* The name of the preferred handler that should be used. If for some reason
* it is not available, the $backupHandler will be used in its place.
*/
public string $handler = 'file';
/**
* --------------------------------------------------------------------------
* Backup Handler
* --------------------------------------------------------------------------
*
* The name of the handler that will be used in case the first one is
* unreachable. Often, 'file' is used here since the filesystem is
* always available, though that's not always practical for the app.
*/
public string $backupHandler = 'dummy';
/**
* --------------------------------------------------------------------------
* Cache Directory Path
* --------------------------------------------------------------------------
*
* The path to where cache files should be stored, if using a file-based
* system.
*
* @deprecated Use the driver-specific variant under $file
*/
public string $storePath = WRITEPATH . 'cache/';
/**
* --------------------------------------------------------------------------
* Cache Include Query String
* --------------------------------------------------------------------------
*
* Whether to take the URL query string into consideration when generating
* output cache files. Valid options are:
*
* false = Disabled
* true = Enabled, take all query parameters into account.
* Please be aware that this may result in numerous cache
* files generated for the same page over and over again.
* array('q') = Enabled, but only take into account the specified list
* of query parameters.
*
* @var bool|string[]
*/
public $cacheQueryString = false;
/**
* --------------------------------------------------------------------------
* Key Prefix
* --------------------------------------------------------------------------
*
* This string is added to all cache item names to help avoid collisions
* if you run multiple applications with the same cache engine.
*/
public string $prefix = '';
/**
* --------------------------------------------------------------------------
* Default TTL
* --------------------------------------------------------------------------
*
* The default number of seconds to save items when none is specified.
*
* WARNING: This is not used by framework handlers where 60 seconds is
* hard-coded, but may be useful to projects and modules. This will replace
* the hard-coded value in a future release.
*/
public int $ttl = 60;
/**
* --------------------------------------------------------------------------
* Reserved Characters
* --------------------------------------------------------------------------
*
* A string of reserved characters that will not be allowed in keys or tags.
* Strings that violate this restriction will cause handlers to throw.
* Default: {}()/\@:
* Note: The default set is required for PSR-6 compliance.
*/
public string $reservedCharacters = '{}()/\@:';
/**
* --------------------------------------------------------------------------
* File settings
* --------------------------------------------------------------------------
* Your file storage preferences can be specified below, if you are using
* the File driver.
*
* @var array<string, int|string|null>
*/
public array $file = [
'storePath' => WRITEPATH . 'cache/',
'mode' => 0640,
];
/**
* -------------------------------------------------------------------------
* Memcached settings
* -------------------------------------------------------------------------
* Your Memcached servers can be specified below, if you are using
* the Memcached drivers.
*
* @see https://codeigniter.com/user_guide/libraries/caching.html#memcached
*
* @var array<string, bool|int|string>
*/
public array $memcached = [
'host' => '127.0.0.1',
'port' => 11211,
'weight' => 1,
'raw' => false,
];
/**
* -------------------------------------------------------------------------
* Redis settings
* -------------------------------------------------------------------------
* Your Redis server can be specified below, if you are using
* the Redis or Predis drivers.
*
* @var array<string, int|string|null>
*/
public array $redis = [
'host' => '127.0.0.1',
'password' => null,
'port' => 6379,
'timeout' => 0,
'database' => 0,
];
/**
* --------------------------------------------------------------------------
* Available Cache Handlers
* --------------------------------------------------------------------------
*
* This is an array of cache engine alias' and class names. Only engines
* that are listed here are allowed to be used.
*
* @var array<string, string>
*/
public array $validHandlers = [
'dummy' => DummyHandler::class,
'file' => FileHandler::class,
'memcached' => MemcachedHandler::class,
'predis' => PredisHandler::class,
'redis' => RedisHandler::class,
'wincache' => WincacheHandler::class,
];
}
<?php
/*
| --------------------------------------------------------------------
| App Namespace
| --------------------------------------------------------------------
|
| This defines the default Namespace that is used throughout
| CodeIgniter to refer to the Application directory. Change
| this constant to change the namespace that all application
| classes should use.
|
| NOTE: changing this will require manually modifying the
| existing namespaces of App\* namespaced-classes.
*/
defined('APP_NAMESPACE') || define('APP_NAMESPACE', 'App');
/*
| --------------------------------------------------------------------------
| Composer Path
| --------------------------------------------------------------------------
|
| The path that Composer's autoload file is expected to live. By default,
| the vendor folder is in the Root directory, but you can customize that here.
*/
defined('COMPOSER_PATH') || define('COMPOSER_PATH', ROOTPATH . 'vendor/autoload.php');
/*
|--------------------------------------------------------------------------
| Timing Constants
|--------------------------------------------------------------------------
|
| Provide simple ways to work with the myriad of PHP functions that
| require information to be in seconds.
*/
defined('SECOND') || define('SECOND', 1);
defined('MINUTE') || define('MINUTE', 60);
defined('HOUR') || define('HOUR', 3600);
defined('DAY') || define('DAY', 86400);
defined('WEEK') || define('WEEK', 604800);
defined('MONTH') || define('MONTH', 2_592_000);
defined('YEAR') || define('YEAR', 31_536_000);
defined('DECADE') || define('DECADE', 315_360_000);
/*
| --------------------------------------------------------------------------
| Exit Status Codes
| --------------------------------------------------------------------------
|
| Used to indicate the conditions under which the script is exit()ing.
| While there is no universal standard for error codes, there are some
| broad conventions. Three such conventions are mentioned below, for
| those who wish to make use of them. The CodeIgniter defaults were
| chosen for the least overlap with these conventions, while still
| leaving room for others to be defined in future versions and user
| applications.
|
| The three main conventions used for determining exit status codes
| are as follows:
|
| Standard C/C++ Library (stdlibc):
| http://www.gnu.org/software/libc/manual/html_node/Exit-Status.html
| (This link also contains other GNU-specific conventions)
| BSD sysexits.h:
| http://www.gsp.com/cgi-bin/man.cgi?section=3&topic=sysexits
| Bash scripting:
| http://tldp.org/LDP/abs/html/exitcodes.html
|
*/
defined('EXIT_SUCCESS') || define('EXIT_SUCCESS', 0); // no errors
defined('EXIT_ERROR') || define('EXIT_ERROR', 1); // generic error
defined('EXIT_CONFIG') || define('EXIT_CONFIG', 3); // configuration error
defined('EXIT_UNKNOWN_FILE') || define('EXIT_UNKNOWN_FILE', 4); // file not found
defined('EXIT_UNKNOWN_CLASS') || define('EXIT_UNKNOWN_CLASS', 5); // unknown class
defined('EXIT_UNKNOWN_METHOD') || define('EXIT_UNKNOWN_METHOD', 6); // unknown class member
defined('EXIT_USER_INPUT') || define('EXIT_USER_INPUT', 7); // invalid user input
defined('EXIT_DATABASE') || define('EXIT_DATABASE', 8); // database error
defined('EXIT__AUTO_MIN') || define('EXIT__AUTO_MIN', 9); // lowest automatically-assigned error code
defined('EXIT__AUTO_MAX') || define('EXIT__AUTO_MAX', 125); // highest automatically-assigned error code
/**
* @deprecated Use \CodeIgniter\Events\Events::PRIORITY_LOW instead.
*/
define('EVENT_PRIORITY_LOW', 200);
/**
* @deprecated Use \CodeIgniter\Events\Events::PRIORITY_NORMAL instead.
*/
define('EVENT_PRIORITY_NORMAL', 100);
/**
* @deprecated Use \CodeIgniter\Events\Events::PRIORITY_HIGH instead.
*/
define('EVENT_PRIORITY_HIGH', 10);
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
/**
* Stores the default settings for the ContentSecurityPolicy, if you
* choose to use it. The values here will be read in and set as defaults
* for the site. If needed, they can be overridden on a page-by-page basis.
*
* Suggested reference for explanations:
*
* @see https://www.html5rocks.com/en/tutorials/security/content-security-policy/
*/
class ContentSecurityPolicy extends BaseConfig
{
// -------------------------------------------------------------------------
// Broadbrush CSP management
// -------------------------------------------------------------------------
/**
* Default CSP report context
*/
public bool $reportOnly = false;
/**
* Specifies a URL where a browser will send reports
* when a content security policy is violated.
*/
public ?string $reportURI = null;
/**
* Instructs user agents to rewrite URL schemes, changing
* HTTP to HTTPS. This directive is for websites with
* large numbers of old URLs that need to be rewritten.
*/
public bool $upgradeInsecureRequests = false;
// -------------------------------------------------------------------------
// Sources allowed
// Note: once you set a policy to 'none', it cannot be further restricted
// -------------------------------------------------------------------------
/**
* Will default to self if not overridden
*
* @var string|string[]|null
*/
public $defaultSrc;
/**
* Lists allowed scripts' URLs.
*
* @var string|string[]
*/
public $scriptSrc = 'self';
/**
* Lists allowed stylesheets' URLs.
*
* @var string|string[]
*/
public $styleSrc = 'self';
/**
* Defines the origins from which images can be loaded.
*
* @var string|string[]
*/
public $imageSrc = 'self';
/**
* Restricts the URLs that can appear in a page's `<base>` element.
*
* Will default to self if not overridden
*
* @var string|string[]|null
*/
public $baseURI;
/**
* Lists the URLs for workers and embedded frame contents
*
* @var string|string[]
*/
public $childSrc = 'self';
/**
* Limits the origins that you can connect to (via XHR,
* WebSockets, and EventSource).
*
* @var string|string[]
*/
public $connectSrc = 'self';
/**
* Specifies the origins that can serve web fonts.
*
* @var string|string[]
*/
public $fontSrc;
/**
* Lists valid endpoints for submission from `<form>` tags.
*
* @var string|string[]
*/
public $formAction = 'self';
/**
* Specifies the sources that can embed the current page.
* This directive applies to `<frame>`, `<iframe>`, `<embed>`,
* and `<applet>` tags. This directive can't be used in
* `<meta>` tags and applies only to non-HTML resources.
*
* @var string|string[]|null
*/
public $frameAncestors;
/**
* The frame-src directive restricts the URLs which may
* be loaded into nested browsing contexts.
*
* @var array|string|null
*/
public $frameSrc;
/**
* Restricts the origins allowed to deliver video and audio.
*
* @var string|string[]|null
*/
public $mediaSrc;
/**
* Allows control over Flash and other plugins.
*
* @var string|string[]
*/
public $objectSrc = 'self';
/**
* @var string|string[]|null
*/
public $manifestSrc;
/**
* Limits the kinds of plugins a page may invoke.
*
* @var string|string[]|null
*/
public $pluginTypes;
/**
* List of actions allowed.
*
* @var string|string[]|null
*/
public $sandbox;
/**
* Nonce tag for style
*/
public string $styleNonceTag = '{csp-style-nonce}';
/**
* Nonce tag for script
*/
public string $scriptNonceTag = '{csp-script-nonce}';
/**
* Replace nonce tag automatically
*/
public bool $autoNonce = true;
}
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
use DateTimeInterface;
class Cookie extends BaseConfig
{
/**
* --------------------------------------------------------------------------
* Cookie Prefix
* --------------------------------------------------------------------------
*
* Set a cookie name prefix if you need to avoid collisions.
*/
public string $prefix = '';
/**
* --------------------------------------------------------------------------
* Cookie Expires Timestamp
* --------------------------------------------------------------------------
*
* Default expires timestamp for cookies. Setting this to `0` will mean the
* cookie will not have the `Expires` attribute and will behave as a session
* cookie.
*
* @var DateTimeInterface|int|string
*/
public $expires = 0;
/**
* --------------------------------------------------------------------------
* Cookie Path
* --------------------------------------------------------------------------
*
* Typically will be a forward slash.
*/
public string $path = '/';
/**
* --------------------------------------------------------------------------
* Cookie Domain
* --------------------------------------------------------------------------
*
* Set to `.your-domain.com` for site-wide cookies.
*/
public string $domain = '';
/**
* --------------------------------------------------------------------------
* Cookie Secure
* --------------------------------------------------------------------------
*
* Cookie will only be set if a secure HTTPS connection exists.
*/
public bool $secure = false;
/**
* --------------------------------------------------------------------------
* Cookie HTTPOnly
* --------------------------------------------------------------------------
*
* Cookie will only be accessible via HTTP(S) (no JavaScript).
*/
public bool $httponly = true;
/**
* --------------------------------------------------------------------------
* Cookie SameSite
* --------------------------------------------------------------------------
*
* Configure cookie SameSite setting. Allowed values are:
* - None
* - Lax
* - Strict
* - ''
*
* Alternatively, you can use the constant names:
* - `Cookie::SAMESITE_NONE`
* - `Cookie::SAMESITE_LAX`
* - `Cookie::SAMESITE_STRICT`
*
* Defaults to `Lax` for compatibility with modern browsers. Setting `''`
* (empty string) means default SameSite attribute set by browsers (`Lax`)
* will be set on cookies. If set to `None`, `$secure` must also be set.
*/
public string $samesite = 'Lax';
/**
* --------------------------------------------------------------------------
* Cookie Raw
* --------------------------------------------------------------------------
*
* This flag allows setting a "raw" cookie, i.e., its name and value are
* not URL encoded using `rawurlencode()`.
*
* If this is set to `true`, cookie names should be compliant of RFC 2616's
* list of allowed characters.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#attributes
* @see https://tools.ietf.org/html/rfc2616#section-2.2
*/
public bool $raw = false;
}
<?php
namespace Config;
use CodeIgniter\Database\Config;
/**
* Database Configuration
*/
class Database extends Config
{
/**
* The directory that holds the Migrations
* and Seeds directories.
*/
public string $filesPath = APPPATH . 'Database' . DIRECTORY_SEPARATOR;
/**
* Lets you choose which connection group to
* use if no other is specified.
*/
public string $defaultGroup = 'default';
/**
* The default database connection.
*/
public array $default = [
'DSN' => '',
'hostname' => 'localhost',
'username' => '',
'password' => '',
'database' => '',
'DBDriver' => 'MySQLi',
'DBPrefix' => '',
'pConnect' => false,
'DBDebug' => true,
'charset' => 'utf8',
'DBCollat' => 'utf8_general_ci',
'swapPre' => '',
'encrypt' => false,
'compress' => false,
'strictOn' => false,
'failover' => [],
'port' => 3306,
];
/**
* This database connection is used when
* running PHPUnit database tests.
*/
public array $tests = [
'DSN' => '',
'hostname' => '127.0.0.1',
'username' => '',
'password' => '',
'database' => ':memory:',
'DBDriver' => 'SQLite3',
'DBPrefix' => 'db_', // Needed to ensure we're working correctly with prefixes live. DO NOT REMOVE FOR CI DEVS
'pConnect' => false,
'DBDebug' => true,
'charset' => 'utf8',
'DBCollat' => 'utf8_general_ci',
'swapPre' => '',
'encrypt' => false,
'compress' => false,
'strictOn' => false,
'failover' => [],
'port' => 3306,
'foreignKeys' => true,
'busyTimeout' => 1000,
];
public function __construct()
{
parent::__construct();
// Ensure that we always set the database group to 'tests' if
// we are currently running an automated test suite, so that
// we don't overwrite live data on accident.
if (ENVIRONMENT === 'testing') {
$this->defaultGroup = 'tests';
}
}
}
<?php
namespace Config;
class DocTypes
{
/**
* List of valid document types.
*
* @var array<string, string>
*/
public array $list = [
'xhtml11' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">',
'xhtml1-strict' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
'xhtml1-trans' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',
'xhtml1-frame' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">',
'xhtml-basic11' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">',
'html5' => '<!DOCTYPE html>',
'html4-strict' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">',
'html4-trans' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">',
'html4-frame' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">',
'mathml1' => '<!DOCTYPE math SYSTEM "http://www.w3.org/Math/DTD/mathml1/mathml.dtd">',
'mathml2' => '<!DOCTYPE math PUBLIC "-//W3C//DTD MathML 2.0//EN" "http://www.w3.org/Math/DTD/mathml2/mathml2.dtd">',
'svg10' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">',
'svg11' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">',
'svg11-basic' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Basic//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-basic.dtd">',
'svg11-tiny' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">',
'xhtml-math-svg-xh' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">',
'xhtml-math-svg-sh' => '<!DOCTYPE svg:svg PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">',
'xhtml-rdfa-1' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">',
'xhtml-rdfa-2' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.1//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd">',
];
/**
* Whether to remove the solidus (`/`) character for void HTML elements (e.g. `<input>`)
* for HTML5 compatibility.
*
* Set to:
* `true` - to be HTML5 compatible
* `false` - to be XHTML compatible
*/
public bool $html5 = true;
}
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
class Email extends BaseConfig
{
public string $fromEmail = '';
public string $fromName = '';
public string $recipients = '';
/**
* The "user agent"
*/
public string $userAgent = 'CodeIgniter';
/**
* The mail sending protocol: mail, sendmail, smtp
*/
public string $protocol = 'mail';
/**
* The server path to Sendmail.
*/
public string $mailPath = '/usr/sbin/sendmail';
/**
* SMTP Server Address
*/
public string $SMTPHost = '';
/**
* SMTP Username
*/
public string $SMTPUser = '';
/**
* SMTP Password
*/
public string $SMTPPass = '';
/**
* SMTP Port
*/
public int $SMTPPort = 25;
/**
* SMTP Timeout (in seconds)
*/
public int $SMTPTimeout = 5;
/**
* Enable persistent SMTP connections
*/
public bool $SMTPKeepAlive = false;
/**
* SMTP Encryption. Either tls or ssl
*/
public string $SMTPCrypto = 'tls';
/**
* Enable word-wrap
*/
public bool $wordWrap = true;
/**
* Character count to wrap at
*/
public int $wrapChars = 76;
/**
* Type of mail, either 'text' or 'html'
*/
public string $mailType = 'text';
/**
* Character set (utf-8, iso-8859-1, etc.)
*/
public string $charset = 'UTF-8';
/**
* Whether to validate the email address
*/
public bool $validate = false;
/**
* Email Priority. 1 = highest. 5 = lowest. 3 = normal
*/
public int $priority = 3;
/**
* Newline character. (Use “\r\n” to comply with RFC 822)
*/
public string $CRLF = "\r\n";
/**
* Newline character. (Use “\r\n” to comply with RFC 822)
*/
public string $newline = "\r\n";
/**
* Enable BCC Batch Mode.
*/
public bool $BCCBatchMode = false;
/**
* Number of emails in each BCC batch
*/
public int $BCCBatchSize = 200;
/**
* Enable notify message from server
*/
public bool $DSN = false;
}
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
/**
* Encryption configuration.
*
* These are the settings used for encryption, if you don't pass a parameter
* array to the encrypter for creation/initialization.
*/
class Encryption extends BaseConfig
{
/**
* --------------------------------------------------------------------------
* Encryption Key Starter
* --------------------------------------------------------------------------
*
* If you use the Encryption class you must set an encryption key (seed).
* You need to ensure it is long enough for the cipher and mode you plan to use.
* See the user guide for more info.
*/
public string $key = '';
/**
* --------------------------------------------------------------------------
* Encryption Driver to Use
* --------------------------------------------------------------------------
*
* One of the supported encryption drivers.
*
* Available drivers:
* - OpenSSL
* - Sodium
*/
public string $driver = 'OpenSSL';
/**
* --------------------------------------------------------------------------
* SodiumHandler's Padding Length in Bytes
* --------------------------------------------------------------------------
*
* This is the number of bytes that will be padded to the plaintext message
* before it is encrypted. This value should be greater than zero.
*
* See the user guide for more information on padding.
*/
public int $blockSize = 16;
/**
* --------------------------------------------------------------------------
* Encryption digest
* --------------------------------------------------------------------------
*
* HMAC digest to use, e.g. 'SHA512' or 'SHA256'. Default value is 'SHA512'.
*/
public string $digest = 'SHA512';
/**
* Whether the cipher-text should be raw. If set to false, then it will be base64 encoded.
* This setting is only used by OpenSSLHandler.
*
* Set to false for CI3 Encryption compatibility.
*/
public bool $rawData = true;
/**
* Encryption key info.
* This setting is only used by OpenSSLHandler.
*
* Set to 'encryption' for CI3 Encryption compatibility.
*/
public string $encryptKeyInfo = '';
/**
* Authentication key info.
* This setting is only used by OpenSSLHandler.
*
* Set to 'authentication' for CI3 Encryption compatibility.
*/
public string $authKeyInfo = '';
}
<?php
namespace Config;
use CodeIgniter\Events\Events;
use CodeIgniter\Exceptions\FrameworkException;
/*
* --------------------------------------------------------------------
* Application Events
* --------------------------------------------------------------------
* Events allow you to tap into the execution of the program without
* modifying or extending core files. This file provides a central
* location to define your events, though they can always be added
* at run-time, also, if needed.
*
* You create code that can execute by subscribing to events with
* the 'on()' method. This accepts any form of callable, including
* Closures, that will be executed when the event is triggered.
*
* Example:
* Events::on('create', [$myInstance, 'myMethod']);
*/
Events::on('pre_system', static function () {
if (ENVIRONMENT !== 'testing') {
if (ini_get('zlib.output_compression')) {
throw FrameworkException::forEnabledZlibOutputCompression();
}
while (ob_get_level() > 0) {
ob_end_flush();
}
ob_start(static fn ($buffer) => $buffer);
}
/*
* --------------------------------------------------------------------
* Debug Toolbar Listeners.
* --------------------------------------------------------------------
* If you delete, they will no longer be collected.
*/
if (CI_DEBUG && ! is_cli()) {
Events::on('DBQuery', 'CodeIgniter\Debug\Toolbar\Collectors\Database::collect');
Services::toolbar()->respond();
}
});
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
use Psr\Log\LogLevel;
/**
* Setup how the exception handler works.
*/
class Exceptions extends BaseConfig
{
/**
* --------------------------------------------------------------------------
* LOG EXCEPTIONS?
* --------------------------------------------------------------------------
* If true, then exceptions will be logged
* through Services::Log.
*
* Default: true
*/
public bool $log = true;
/**
* --------------------------------------------------------------------------
* DO NOT LOG STATUS CODES
* --------------------------------------------------------------------------
* Any status codes here will NOT be logged if logging is turned on.
* By default, only 404 (Page Not Found) exceptions are ignored.
*/
public array $ignoreCodes = [404];
/**
* --------------------------------------------------------------------------
* Error Views Path
* --------------------------------------------------------------------------
* This is the path to the directory that contains the 'cli' and 'html'
* directories that hold the views used to generate errors.
*
* Default: APPPATH.'Views/errors'
*/
public string $errorViewPath = APPPATH . 'Views/errors';
/**
* --------------------------------------------------------------------------
* HIDE FROM DEBUG TRACE
* --------------------------------------------------------------------------
* Any data that you would like to hide from the debug trace.
* In order to specify 2 levels, use "/" to separate.
* ex. ['server', 'setup/password', 'secret_token']
*/
public array $sensitiveDataInTrace = [];
/**
* --------------------------------------------------------------------------
* LOG DEPRECATIONS INSTEAD OF THROWING?
* --------------------------------------------------------------------------
* By default, CodeIgniter converts deprecations into exceptions. Also,
* starting in PHP 8.1 will cause a lot of deprecated usage warnings.
* Use this option to temporarily cease the warnings and instead log those.
* This option also works for user deprecations.
*/
public bool $logDeprecations = true;
/**
* --------------------------------------------------------------------------
* LOG LEVEL THRESHOLD FOR DEPRECATIONS
* --------------------------------------------------------------------------
* If `$logDeprecations` is set to `true`, this sets the log level
* to which the deprecation will be logged. This should be one of the log
* levels recognized by PSR-3.
*
* The related `Config\Logger::$threshold` should be adjusted, if needed,
* to capture logging the deprecations.
*/
public string $deprecationLogLevel = LogLevel::WARNING;
}
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
/**
* Enable/disable backward compatibility breaking features.
*/
class Feature extends BaseConfig
{
/**
* Enable multiple filters for a route or not.
*
* If you enable this:
* - CodeIgniter\CodeIgniter::handleRequest() uses:
* - CodeIgniter\Filters\Filters::enableFilters(), instead of enableFilter()
* - CodeIgniter\CodeIgniter::tryToRouteIt() uses:
* - CodeIgniter\Router\Router::getFilters(), instead of getFilter()
* - CodeIgniter\Router\Router::handle() uses:
* - property $filtersInfo, instead of $filterInfo
* - CodeIgniter\Router\RouteCollection::getFiltersForRoute(), instead of getFilterForRoute()
*/
public bool $multipleFilters = false;
/**
* Use improved new auto routing instead of the default legacy version.
*/
public bool $autoRoutesImproved = false;
}
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Filters\CSRF;
use CodeIgniter\Filters\DebugToolbar;
use CodeIgniter\Filters\Honeypot;
use CodeIgniter\Filters\InvalidChars;
use CodeIgniter\Filters\SecureHeaders;
class Filters extends BaseConfig
{
/**
* Configures aliases for Filter classes to
* make reading things nicer and simpler.
*/
public array $aliases = [
'csrf' => CSRF::class,
'toolbar' => DebugToolbar::class,
'honeypot' => Honeypot::class,
'invalidchars' => InvalidChars::class,
'secureheaders' => SecureHeaders::class,
'user_auth' => \App\Filters\UserAuth::class,
'admin_auth' => \App\Filters\AdminAuth::class,
];
/**
* List of filter aliases that are always
* applied before and after every request.
*/
public array $globals = [
'before' => [
// 'honeypot',
// 'csrf',
// 'invalidchars',
],
'after' => [
'toolbar',
// 'honeypot',
// 'secureheaders',
],
];
/**
* List of filter aliases that works on a
* particular HTTP method (GET, POST, etc.).
*
* Example:
* 'post' => ['foo', 'bar']
*
* If you use this, you should disable auto-routing because auto-routing
* permits any HTTP method to access a controller. Accessing the controller
* with a method you don’t expect could bypass the filter.
*/
public array $methods = [];
/**
* List of filter aliases that should run on any
* before or after URI patterns.
*
* Example:
* 'isLoggedIn' => ['before' => ['account/*', 'profiles/*']]
*/
public array $filters = [];
}
<?php
namespace Config;
use CodeIgniter\Config\ForeignCharacters as BaseForeignCharacters;
class ForeignCharacters extends BaseForeignCharacters
{
}
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Format\FormatterInterface;
use CodeIgniter\Format\JSONFormatter;
use CodeIgniter\Format\XMLFormatter;
class Format extends BaseConfig
{
/**
* --------------------------------------------------------------------------
* Available Response Formats
* --------------------------------------------------------------------------
*
* When you perform content negotiation with the request, these are the
* available formats that your application supports. This is currently
* only used with the API\ResponseTrait. A valid Formatter must exist
* for the specified format.
*
* These formats are only checked when the data passed to the respond()
* method is an array.
*
* @var string[]
*/
public array $supportedResponseFormats = [
'application/json',
'application/xml', // machine-readable XML
'text/xml', // human-readable XML
];
/**
* --------------------------------------------------------------------------
* Formatters
* --------------------------------------------------------------------------
*
* Lists the class to use to format responses with of a particular type.
* For each mime type, list the class that should be used. Formatters
* can be retrieved through the getFormatter() method.
*
* @var array<string, string>
*/
public array $formatters = [
'application/json' => JSONFormatter::class,
'application/xml' => XMLFormatter::class,
'text/xml' => XMLFormatter::class,
];
/**
* --------------------------------------------------------------------------
* Formatters Options
* --------------------------------------------------------------------------
*
* Additional Options to adjust default formatters behaviour.
* For each mime type, list the additional options that should be used.
*
* @var array<string, int>
*/
public array $formatterOptions = [
'application/json' => JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES,
'application/xml' => 0,
'text/xml' => 0,
];
/**
* A Factory method to return the appropriate formatter for the given mime type.
*
* @return FormatterInterface
*
* @deprecated This is an alias of `\CodeIgniter\Format\Format::getFormatter`. Use that instead.
*/
public function getFormatter(string $mime)
{
return Services::format()->getFormatter($mime);
}
}
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
class Generators extends BaseConfig
{
/**
* --------------------------------------------------------------------------
* Generator Commands' Views
* --------------------------------------------------------------------------
*
* This array defines the mapping of generator commands to the view files
* they are using. If you need to customize them for your own, copy these
* view files in your own folder and indicate the location here.
*
* You will notice that the views have special placeholders enclosed in
* curly braces `{...}`. These placeholders are used internally by the
* generator commands in processing replacements, thus you are warned
* not to delete them or modify the names. If you will do so, you may
* end up disrupting the scaffolding process and throw errors.
*
* YOU HAVE BEEN WARNED!
*
* @var array<string, string>
*/
public array $views = [
'make:command' => 'CodeIgniter\Commands\Generators\Views\command.tpl.php',
'make:config' => 'CodeIgniter\Commands\Generators\Views\config.tpl.php',
'make:controller' => 'CodeIgniter\Commands\Generators\Views\controller.tpl.php',
'make:entity' => 'CodeIgniter\Commands\Generators\Views\entity.tpl.php',
'make:filter' => 'CodeIgniter\Commands\Generators\Views\filter.tpl.php',
'make:migration' => 'CodeIgniter\Commands\Generators\Views\migration.tpl.php',
'make:model' => 'CodeIgniter\Commands\Generators\Views\model.tpl.php',
'make:seeder' => 'CodeIgniter\Commands\Generators\Views\seeder.tpl.php',
'make:validation' => 'CodeIgniter\Commands\Generators\Views\validation.tpl.php',
'session:migration' => 'CodeIgniter\Commands\Generators\Views\migration.tpl.php',
];
}
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
class Honeypot extends BaseConfig
{
/**
* Makes Honeypot visible or not to human
*/
public bool $hidden = true;
/**
* Honeypot Label Content
*/
public string $label = 'Fill This Field';
/**
* Honeypot Field Name
*/
public string $name = 'honeypot';
/**
* Honeypot HTML Template
*/
public string $template = '<label>{label}</label><input type="text" name="{name}" value="">';
/**
* Honeypot container
*
* If you enabled CSP, you can remove `style="display:none"`.
*/
public string $container = '<div style="display:none">{template}</div>';
/**
* The id attribute for Honeypot container tag
*
* Used when CSP is enabled.
*/
public string $containerId = 'hpc';
}
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Images\Handlers\GDHandler;
use CodeIgniter\Images\Handlers\ImageMagickHandler;
class Images extends BaseConfig
{
/**
* Default handler used if no other handler is specified.
*/
public string $defaultHandler = 'gd';
/**
* The path to the image library.
* Required for ImageMagick, GraphicsMagick, or NetPBM.
*/
public string $libraryPath = '/usr/local/bin/convert';
/**
* The available handler classes.
*
* @var array<string, string>
*/
public array $handlers = [
'gd' => GDHandler::class,
'imagick' => ImageMagickHandler::class,
];
}
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
use Kint\Renderer\AbstractRenderer;
/**
* --------------------------------------------------------------------------
* Kint
* --------------------------------------------------------------------------
*
* We use Kint's `RichRenderer` and `CLIRenderer`. This area contains options
* that you can set to customize how Kint works for you.
*
* @see https://kint-php.github.io/kint/ for details on these settings.
*/
class Kint extends BaseConfig
{
/*
|--------------------------------------------------------------------------
| Global Settings
|--------------------------------------------------------------------------
*/
public $plugins;
public int $maxDepth = 6;
public bool $displayCalledFrom = true;
public bool $expanded = false;
/*
|--------------------------------------------------------------------------
| RichRenderer Settings
|--------------------------------------------------------------------------
*/
public string $richTheme = 'aante-light.css';
public bool $richFolder = false;
public int $richSort = AbstractRenderer::SORT_FULL;
public $richObjectPlugins;
public $richTabPlugins;
/*
|--------------------------------------------------------------------------
| CLI Settings
|--------------------------------------------------------------------------
*/
public bool $cliColors = true;
public bool $cliForceUTF8 = false;
public bool $cliDetectWidth = true;
public int $cliMinWidth = 40;
}
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Log\Handlers\FileHandler;
class Logger extends BaseConfig
{
/**
* --------------------------------------------------------------------------
* Error Logging Threshold
* --------------------------------------------------------------------------
*
* You can enable error logging by setting a threshold over zero. The
* threshold determines what gets logged. Any values below or equal to the
* threshold will be logged.
*
* Threshold options are:
*
* - 0 = Disables logging, Error logging TURNED OFF
* - 1 = Emergency Messages - System is unusable
* - 2 = Alert Messages - Action Must Be Taken Immediately
* - 3 = Critical Messages - Application component unavailable, unexpected exception.
* - 4 = Runtime Errors - Don't need immediate action, but should be monitored.
* - 5 = Warnings - Exceptional occurrences that are not errors.
* - 6 = Notices - Normal but significant events.
* - 7 = Info - Interesting events, like user logging in, etc.
* - 8 = Debug - Detailed debug information.
* - 9 = All Messages
*
* You can also pass an array with threshold levels to show individual error types
*
* array(1, 2, 3, 8) = Emergency, Alert, Critical, and Debug messages
*
* For a live site you'll usually enable Critical or higher (3) to be logged otherwise
* your log files will fill up very fast.
*
* @var array|int
*/
public $threshold = (ENVIRONMENT === 'production') ? 4 : 9;
/**
* --------------------------------------------------------------------------
* Date Format for Logs
* --------------------------------------------------------------------------
*
* Each item that is logged has an associated date. You can use PHP date
* codes to set your own date formatting
*/
public string $dateFormat = 'Y-m-d H:i:s';
/**
* --------------------------------------------------------------------------
* Log Handlers
* --------------------------------------------------------------------------
*
* The logging system supports multiple actions to be taken when something
* is logged. This is done by allowing for multiple Handlers, special classes
* designed to write the log to their chosen destinations, whether that is
* a file on the getServer, a cloud-based service, or even taking actions such
* as emailing the dev team.
*
* Each handler is defined by the class name used for that handler, and it
* MUST implement the `CodeIgniter\Log\Handlers\HandlerInterface` interface.
*
* The value of each key is an array of configuration items that are sent
* to the constructor of each handler. The only required configuration item
* is the 'handles' element, which must be an array of integer log levels.
* This is most easily handled by using the constants defined in the
* `Psr\Log\LogLevel` class.
*
* Handlers are executed in the order defined in this array, starting with
* the handler on top and continuing down.
*/
public array $handlers = [
/*
* --------------------------------------------------------------------
* File Handler
* --------------------------------------------------------------------
*/
FileHandler::class => [
// The log levels that this handler will handle.
'handles' => [
'critical',
'alert',
'emergency',
'debug',
'error',
'info',
'notice',
'warning',
],
/*
* The default filename extension for log files.
* An extension of 'php' allows for protecting the log files via basic
* scripting, when they are to be stored under a publicly accessible directory.
*
* Note: Leaving it blank will default to 'log'.
*/
'fileExtension' => '',
/*
* The file system permissions to be applied on newly created log files.
*
* IMPORTANT: This MUST be an integer (no quotes) and you MUST use octal
* integer notation (i.e. 0700, 0644, etc.)
*/
'filePermissions' => 0644,
/*
* Logging Directory Path
*
* By default, logs are written to WRITEPATH . 'logs/'
* Specify a different destination here, if desired.
*/
'path' => '',
],
/*
* The ChromeLoggerHandler requires the use of the Chrome web browser
* and the ChromeLogger extension. Uncomment this block to use it.
*/
// 'CodeIgniter\Log\Handlers\ChromeLoggerHandler' => [
// /*
// * The log levels that this handler will handle.
// */
// 'handles' => ['critical', 'alert', 'emergency', 'debug',
// 'error', 'info', 'notice', 'warning'],
// ],
/*
* The ErrorlogHandler writes the logs to PHP's native `error_log()` function.
* Uncomment this block to use it.
*/
// 'CodeIgniter\Log\Handlers\ErrorlogHandler' => [
// /* The log levels this handler can handle. */
// 'handles' => ['critical', 'alert', 'emergency', 'debug', 'error', 'info', 'notice', 'warning'],
//
// /*
// * The message type where the error should go. Can be 0 or 4, or use the
// * class constants: `ErrorlogHandler::TYPE_OS` (0) or `ErrorlogHandler::TYPE_SAPI` (4)
// */
// 'messageType' => 0,
// ],
];
}
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
class Migrations extends BaseConfig
{
/**
* --------------------------------------------------------------------------
* Enable/Disable Migrations
* --------------------------------------------------------------------------
*
* Migrations are enabled by default.
*
* You should enable migrations whenever you intend to do a schema migration
* and disable it back when you're done.
*/
public bool $enabled = true;
/**
* --------------------------------------------------------------------------
* Migrations Table
* --------------------------------------------------------------------------
*
* This is the name of the table that will store the current migrations state.
* When migrations runs it will store in a database table which migration
* level the system is at. It then compares the migration level in this
* table to the $config['migration_version'] if they are not the same it
* will migrate up. This must be set.
*/
public string $table = 'migrations';
/**
* --------------------------------------------------------------------------
* Timestamp Format
* --------------------------------------------------------------------------
*
* This is the format that will be used when creating new migrations
* using the CLI command:
* > php spark make:migration
*
* Note: if you set an unsupported format, migration runner will not find
* your migration files.
*
* Supported formats:
* - YmdHis_
* - Y-m-d-His_
* - Y_m_d_His_
*/
public string $timestampFormat = 'Y-m-d-His_';
}
<?php
namespace Config;
use CodeIgniter\Modules\Modules as BaseModules;
class Modules extends BaseModules
{
/**
* --------------------------------------------------------------------------
* Enable Auto-Discovery?
* --------------------------------------------------------------------------
*
* If true, then auto-discovery will happen across all elements listed in
* $aliases below. If false, no auto-discovery will happen at all,
* giving a slight performance boost.
*
* @var bool
*/
public $enabled = true;
/**
* --------------------------------------------------------------------------
* Enable Auto-Discovery Within Composer Packages?
* --------------------------------------------------------------------------
*
* If true, then auto-discovery will happen across all namespaces loaded
* by Composer, as well as the namespaces configured locally.
*
* @var bool
*/
public $discoverInComposer = true;
/**
* The Composer package list for Auto-Discovery
* This setting is optional.
*
* E.g.:
* [
* 'only' => [
* // List up all packages to auto-discover
* 'codeigniter4/shield',
* ],
* ]
* or
* [
* 'exclude' => [
* // List up packages to exclude.
* 'pestphp/pest',
* ],
* ]
*
* @var array
*/
public $composerPackages = [];
/**
* --------------------------------------------------------------------------
* Auto-Discovery Rules
* --------------------------------------------------------------------------
*
* Aliases list of all discovery classes that will be active and used during
* the current application request.
*
* If it is not listed, only the base application elements will be used.
*
* @var string[]
*/
public $aliases = [
'events',
'filters',
'registrars',
'routes',
'services',
];
}
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
class Pager extends BaseConfig
{
/**
* --------------------------------------------------------------------------
* Templates
* --------------------------------------------------------------------------
*
* Pagination links are rendered out using views to configure their
* appearance. This array contains aliases and the view names to
* use when rendering the links.
*
* Within each view, the Pager object will be available as $pager,
* and the desired group as $pagerGroup;
*
* @var array<string, string>
*/
public array $templates = [
'default_full' => 'CodeIgniter\Pager\Views\default_full',
'default_simple' => 'CodeIgniter\Pager\Views\default_simple',
'default_head' => 'CodeIgniter\Pager\Views\default_head',
];
/**
* --------------------------------------------------------------------------
* Items Per Page
* --------------------------------------------------------------------------
*
* The default number of results shown in a single page.
*/
public int $perPage = 20;
}
<?php
namespace Config;
/**
* Paths
*
* Holds the paths that are used by the system to
* locate the main directories, app, system, etc.
*
* Modifying these allows you to restructure your application,
* share a system folder between multiple applications, and more.
*
* All paths are relative to the project's root folder.
*/
class Paths
{
/**
* ---------------------------------------------------------------
* SYSTEM FOLDER NAME
* ---------------------------------------------------------------
*
* This must contain the name of your "system" folder. Include
* the path if the folder is not in the same directory as this file.
*/
public string $systemDirectory = __DIR__ . '/../../system';
/**
* ---------------------------------------------------------------
* APPLICATION FOLDER NAME
* ---------------------------------------------------------------
*
* If you want this front controller to use a different "app"
* folder than the default one you can set its name here. The folder
* can also be renamed or relocated anywhere on your server. If
* you do, use a full server path.
*
* @see http://codeigniter.com/user_guide/general/managing_apps.html
*/
public string $appDirectory = __DIR__ . '/..';
/**
* ---------------------------------------------------------------
* WRITABLE DIRECTORY NAME
* ---------------------------------------------------------------
*
* This variable must contain the name of your "writable" directory.
* The writable directory allows you to group all directories that
* need write permission to a single place that can be tucked away
* for maximum security, keeping it out of the app and/or
* system directories.
*/
public string $writableDirectory = __DIR__ . '/../../writable';
/**
* ---------------------------------------------------------------
* TESTS DIRECTORY NAME
* ---------------------------------------------------------------
*
* This variable must contain the name of your "tests" directory.
*/
public string $testsDirectory = __DIR__ . '/../../tests';
/**
* ---------------------------------------------------------------
* VIEW DIRECTORY NAME
* ---------------------------------------------------------------
*
* This variable must contain the name of the directory that
* contains the view files used by your application. By
* default this is in `app/Views`. This value
* is used when no value is provided to `Services::renderer()`.
*/
public string $viewDirectory = __DIR__ . '/../Views';
}
<?php
namespace Config;
use CodeIgniter\Config\Publisher as BasePublisher;
/**
* Publisher Configuration
*
* Defines basic security restrictions for the Publisher class
* to prevent abuse by injecting malicious files into a project.
*/
class Publisher extends BasePublisher
{
/**
* A list of allowed destinations with a (pseudo-)regex
* of allowed files for each destination.
* Attempts to publish to directories not in this list will
* result in a PublisherException. Files that do no fit the
* pattern will cause copy/merge to fail.
*
* @var array<string,string>
*/
public $restrictions = [
ROOTPATH => '*',
FCPATH => '#\.(s?css|js|map|html?|xml|json|webmanifest|ttf|eot|woff2?|gif|jpe?g|tiff?|png|webp|bmp|ico|svg)$#i',
];
}
<?php
namespace Config;
// Create a new instance of our RouteCollection class.
$routes = Services::routes();
/*
* --------------------------------------------------------------------
* Router Setup
* --------------------------------------------------------------------
*/
$routes->setDefaultNamespace('App\Controllers');
$routes->setDefaultController('Home');
$routes->setDefaultMethod('index');
$routes->setTranslateURIDashes(false);
$routes->set404Override();
// The Auto Routing (Legacy) is very dangerous. It is easy to create vulnerable apps
// where controller filters or CSRF protection are bypassed.
// If you don't want to define all routes, please use the Auto Routing (Improved).
// Set `$autoRoutesImproved` to true in `app/Config/Feature.php` and set the following to true.
// $routes->setAutoRoute(false);
/*
* --------------------------------------------------------------------
* Route Definitions
* --------------------------------------------------------------------
*/
// We get a performance increase by specifying the default
// route since we don't have to scan directories.
use App\Controllers\User;
$routes->match(['get'], '/', [User::class, 'login']);
$routes->match(['get', 'post'], '/login', [User::class, 'login']);
$routes->match(['get', 'post'], '/register', [User::class, 'register']);
$routes->match(['get'], '/home', [User::class, 'user_ok']);
$routes->get('login','Pages::viewLogin');
$routes->get('users','User::list');
$routes->get('home','Pages::prueba');
$routes->get('(:segment)', 'Home::index');
/*
* --------------------------------------------------------------------
* Additional Routing
* --------------------------------------------------------------------
*
* There will often be times that you need additional routing and you
* need it to be able to override any defaults in this file. Environment
* based routes is one such time. require() additional route files here
* to make that happen.
*
* You will have access to the $routes object within that file without
* needing to reload it.
*/
if (is_file(APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php')) {
require APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php';
}
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
class Security extends BaseConfig
{
/**
* --------------------------------------------------------------------------
* CSRF Protection Method
* --------------------------------------------------------------------------
*
* Protection Method for Cross Site Request Forgery protection.
*
* @var string 'cookie' or 'session'
*/
public string $csrfProtection = 'cookie';
/**
* --------------------------------------------------------------------------
* CSRF Token Randomization
* --------------------------------------------------------------------------
*
* Randomize the CSRF Token for added security.
*/
public bool $tokenRandomize = false;
/**
* --------------------------------------------------------------------------
* CSRF Token Name
* --------------------------------------------------------------------------
*
* Token name for Cross Site Request Forgery protection.
*/
public string $tokenName = 'csrf_test_name';
/**
* --------------------------------------------------------------------------
* CSRF Header Name
* --------------------------------------------------------------------------
*
* Header name for Cross Site Request Forgery protection.
*/
public string $headerName = 'X-CSRF-TOKEN';
/**
* --------------------------------------------------------------------------
* CSRF Cookie Name
* --------------------------------------------------------------------------
*
* Cookie name for Cross Site Request Forgery protection.
*/
public string $cookieName = 'csrf_cookie_name';
/**
* --------------------------------------------------------------------------
* CSRF Expires
* --------------------------------------------------------------------------
*
* Expiration time for Cross Site Request Forgery protection cookie.
*
* Defaults to two hours (in seconds).
*/
public int $expires = 7200;
/**
* --------------------------------------------------------------------------
* CSRF Regenerate
* --------------------------------------------------------------------------
*
* Regenerate CSRF Token on every submission.
*/
public bool $regenerate = true;
/**
* --------------------------------------------------------------------------
* CSRF Redirect
* --------------------------------------------------------------------------
*
* Redirect to previous page with error on failure.
*/
public bool $redirect = false;
/**
* --------------------------------------------------------------------------
* CSRF SameSite
* --------------------------------------------------------------------------
*
* Setting for CSRF SameSite cookie token.
*
* Allowed values are: None - Lax - Strict - ''.
*
* Defaults to `Lax` as recommended in this link:
*
* @see https://portswigger.net/web-security/csrf/samesite-cookies
*
* @deprecated `Config\Cookie` $samesite property is used.
*/
public string $samesite = 'Lax';
}
<?php
namespace Config;
use CodeIgniter\Config\BaseService;
/**
* Services Configuration file.
*
* Services are simply other classes/libraries that the system uses
* to do its job. This is used by CodeIgniter to allow the core of the
* framework to be swapped out easily without affecting the usage within
* the rest of your application.
*
* This file holds any application-specific services, or service overrides
* that you might need. An example has been included with the general
* method format you should use for your service methods. For more examples,
* see the core Services file at system/Config/Services.php.
*/
class Services extends BaseService
{
/*
* public static function example($getShared = true)
* {
* if ($getShared) {
* return static::getSharedInstance('example');
* }
*
* return new \CodeIgniter\Example();
* }
*/
}
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Session\Handlers\BaseHandler;
use CodeIgniter\Session\Handlers\FileHandler;
class Session extends BaseConfig
{
/**
* --------------------------------------------------------------------------
* Session Driver
* --------------------------------------------------------------------------
*
* The session storage driver to use:
* - `CodeIgniter\Session\Handlers\FileHandler`
* - `CodeIgniter\Session\Handlers\DatabaseHandler`
* - `CodeIgniter\Session\Handlers\MemcachedHandler`
* - `CodeIgniter\Session\Handlers\RedisHandler`
*
* @phpstan-var class-string<BaseHandler>
*/
public string $driver = FileHandler::class;
/**
* --------------------------------------------------------------------------
* Session Cookie Name
* --------------------------------------------------------------------------
*
* The session cookie name, must contain only [0-9a-z_-] characters
*/
public string $cookieName = 'ci_session';
/**
* --------------------------------------------------------------------------
* Session Expiration
* --------------------------------------------------------------------------
*
* The number of SECONDS you want the session to last.
* Setting to 0 (zero) means expire when the browser is closed.
*/
public int $expiration = 7200;
/**
* --------------------------------------------------------------------------
* Session Save Path
* --------------------------------------------------------------------------
*
* The location to save sessions to and is driver dependent.
*
* For the 'files' driver, it's a path to a writable directory.
* WARNING: Only absolute paths are supported!
*
* For the 'database' driver, it's a table name.
* Please read up the manual for the format with other session drivers.
*
* IMPORTANT: You are REQUIRED to set a valid save path!
*/
public string $savePath = WRITEPATH . 'session';
/**
* --------------------------------------------------------------------------
* Session Match IP
* --------------------------------------------------------------------------
*
* Whether to match the user's IP address when reading the session data.
*
* WARNING: If you're using the database driver, don't forget to update
* your session table's PRIMARY KEY when changing this setting.
*/
public bool $matchIP = false;
/**
* --------------------------------------------------------------------------
* Session Time to Update
* --------------------------------------------------------------------------
*
* How many seconds between CI regenerating the session ID.
*/
public int $timeToUpdate = 300;
/**
* --------------------------------------------------------------------------
* Session Regenerate Destroy
* --------------------------------------------------------------------------
*
* Whether to destroy session data associated with the old session ID
* when auto-regenerating the session ID. When set to FALSE, the data
* will be later deleted by the garbage collector.
*/
public bool $regenerateDestroy = false;
/**
* --------------------------------------------------------------------------
* Session Database Group
* --------------------------------------------------------------------------
*
* DB Group for the database session.
*/
public ?string $DBGroup = null;
}
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Debug\Toolbar\Collectors\Database;
use CodeIgniter\Debug\Toolbar\Collectors\Events;
use CodeIgniter\Debug\Toolbar\Collectors\Files;
use CodeIgniter\Debug\Toolbar\Collectors\Logs;
use CodeIgniter\Debug\Toolbar\Collectors\Routes;
use CodeIgniter\Debug\Toolbar\Collectors\Timers;
use CodeIgniter\Debug\Toolbar\Collectors\Views;
/**
* --------------------------------------------------------------------------
* Debug Toolbar
* --------------------------------------------------------------------------
*
* The Debug Toolbar provides a way to see information about the performance
* and state of your application during that page display. By default it will
* NOT be displayed under production environments, and will only display if
* `CI_DEBUG` is true, since if it's not, there's not much to display anyway.
*/
class Toolbar extends BaseConfig
{
/**
* --------------------------------------------------------------------------
* Toolbar Collectors
* --------------------------------------------------------------------------
*
* List of toolbar collectors that will be called when Debug Toolbar
* fires up and collects data from.
*
* @var string[]
*/
public array $collectors = [
Timers::class,
Database::class,
Logs::class,
Views::class,
// \CodeIgniter\Debug\Toolbar\Collectors\Cache::class,
Files::class,
Routes::class,
Events::class,
];
/**
* --------------------------------------------------------------------------
* Collect Var Data
* --------------------------------------------------------------------------
*
* If set to false var data from the views will not be colleted. Useful to
* avoid high memory usage when there are lots of data passed to the view.
*/
public bool $collectVarData = true;
/**
* --------------------------------------------------------------------------
* Max History
* --------------------------------------------------------------------------
*
* `$maxHistory` sets a limit on the number of past requests that are stored,
* helping to conserve file space used to store them. You can set it to
* 0 (zero) to not have any history stored, or -1 for unlimited history.
*/
public int $maxHistory = 20;
/**
* --------------------------------------------------------------------------
* Toolbar Views Path
* --------------------------------------------------------------------------
*
* The full path to the the views that are used by the toolbar.
* This MUST have a trailing slash.
*/
public string $viewsPath = SYSTEMPATH . 'Debug/Toolbar/Views/';
/**
* --------------------------------------------------------------------------
* Max Queries
* --------------------------------------------------------------------------
*
* If the Database Collector is enabled, it will log every query that the
* the system generates so they can be displayed on the toolbar's timeline
* and in the query log. This can lead to memory issues in some instances
* with hundreds of queries.
*
* `$maxQueries` defines the maximum amount of queries that will be stored.
*/
public int $maxQueries = 100;
}
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
/**
* -------------------------------------------------------------------
* User Agents
* -------------------------------------------------------------------
*
* This file contains four arrays of user agent data. It is used by the
* User Agent Class to help identify browser, platform, robot, and
* mobile device data. The array keys are used to identify the device
* and the array values are used to set the actual name of the item.
*/
class UserAgents extends BaseConfig
{
/**
* -------------------------------------------------------------------
* OS Platforms
* -------------------------------------------------------------------
*
* @var array<string, string>
*/
public array $platforms = [
'windows nt 10.0' => 'Windows 10',
'windows nt 6.3' => 'Windows 8.1',
'windows nt 6.2' => 'Windows 8',
'windows nt 6.1' => 'Windows 7',
'windows nt 6.0' => 'Windows Vista',
'windows nt 5.2' => 'Windows 2003',
'windows nt 5.1' => 'Windows XP',
'windows nt 5.0' => 'Windows 2000',
'windows nt 4.0' => 'Windows NT 4.0',
'winnt4.0' => 'Windows NT 4.0',
'winnt 4.0' => 'Windows NT',
'winnt' => 'Windows NT',
'windows 98' => 'Windows 98',
'win98' => 'Windows 98',
'windows 95' => 'Windows 95',
'win95' => 'Windows 95',
'windows phone' => 'Windows Phone',
'windows' => 'Unknown Windows OS',
'android' => 'Android',
'blackberry' => 'BlackBerry',
'iphone' => 'iOS',
'ipad' => 'iOS',
'ipod' => 'iOS',
'os x' => 'Mac OS X',
'ppc mac' => 'Power PC Mac',
'freebsd' => 'FreeBSD',
'ppc' => 'Macintosh',
'linux' => 'Linux',
'debian' => 'Debian',
'sunos' => 'Sun Solaris',
'beos' => 'BeOS',
'apachebench' => 'ApacheBench',
'aix' => 'AIX',
'irix' => 'Irix',
'osf' => 'DEC OSF',
'hp-ux' => 'HP-UX',
'netbsd' => 'NetBSD',
'bsdi' => 'BSDi',
'openbsd' => 'OpenBSD',
'gnu' => 'GNU/Linux',
'unix' => 'Unknown Unix OS',
'symbian' => 'Symbian OS',
];
/**
* -------------------------------------------------------------------
* Browsers
* -------------------------------------------------------------------
*
* The order of this array should NOT be changed. Many browsers return
* multiple browser types so we want to identify the subtype first.
*
* @var array<string, string>
*/
public array $browsers = [
'OPR' => 'Opera',
'Flock' => 'Flock',
'Edge' => 'Spartan',
'Edg' => 'Edge',
'Chrome' => 'Chrome',
// Opera 10+ always reports Opera/9.80 and appends Version/<real version> to the user agent string
'Opera.*?Version' => 'Opera',
'Opera' => 'Opera',
'MSIE' => 'Internet Explorer',
'Internet Explorer' => 'Internet Explorer',
'Trident.* rv' => 'Internet Explorer',
'Shiira' => 'Shiira',
'Firefox' => 'Firefox',
'Chimera' => 'Chimera',
'Phoenix' => 'Phoenix',
'Firebird' => 'Firebird',
'Camino' => 'Camino',
'Netscape' => 'Netscape',
'OmniWeb' => 'OmniWeb',
'Safari' => 'Safari',
'Mozilla' => 'Mozilla',
'Konqueror' => 'Konqueror',
'icab' => 'iCab',
'Lynx' => 'Lynx',
'Links' => 'Links',
'hotjava' => 'HotJava',
'amaya' => 'Amaya',
'IBrowse' => 'IBrowse',
'Maxthon' => 'Maxthon',
'Ubuntu' => 'Ubuntu Web Browser',
'Vivaldi' => 'Vivaldi',
];
/**
* -------------------------------------------------------------------
* Mobiles
* -------------------------------------------------------------------
*
* @var array<string, string>
*/
public array $mobiles = [
// legacy array, old values commented out
'mobileexplorer' => 'Mobile Explorer',
// 'openwave' => 'Open Wave',
// 'opera mini' => 'Opera Mini',
// 'operamini' => 'Opera Mini',
// 'elaine' => 'Palm',
'palmsource' => 'Palm',
// 'digital paths' => 'Palm',
// 'avantgo' => 'Avantgo',
// 'xiino' => 'Xiino',
'palmscape' => 'Palmscape',
// 'nokia' => 'Nokia',
// 'ericsson' => 'Ericsson',
// 'blackberry' => 'BlackBerry',
// 'motorola' => 'Motorola'
// Phones and Manufacturers
'motorola' => 'Motorola',
'nokia' => 'Nokia',
'palm' => 'Palm',
'iphone' => 'Apple iPhone',
'ipad' => 'iPad',
'ipod' => 'Apple iPod Touch',
'sony' => 'Sony Ericsson',
'ericsson' => 'Sony Ericsson',
'blackberry' => 'BlackBerry',
'cocoon' => 'O2 Cocoon',
'blazer' => 'Treo',
'lg' => 'LG',
'amoi' => 'Amoi',
'xda' => 'XDA',
'mda' => 'MDA',
'vario' => 'Vario',
'htc' => 'HTC',
'samsung' => 'Samsung',
'sharp' => 'Sharp',
'sie-' => 'Siemens',
'alcatel' => 'Alcatel',
'benq' => 'BenQ',
'ipaq' => 'HP iPaq',
'mot-' => 'Motorola',
'playstation portable' => 'PlayStation Portable',
'playstation 3' => 'PlayStation 3',
'playstation vita' => 'PlayStation Vita',
'hiptop' => 'Danger Hiptop',
'nec-' => 'NEC',
'panasonic' => 'Panasonic',
'philips' => 'Philips',
'sagem' => 'Sagem',
'sanyo' => 'Sanyo',
'spv' => 'SPV',
'zte' => 'ZTE',
'sendo' => 'Sendo',
'nintendo dsi' => 'Nintendo DSi',
'nintendo ds' => 'Nintendo DS',
'nintendo 3ds' => 'Nintendo 3DS',
'wii' => 'Nintendo Wii',
'open web' => 'Open Web',
'openweb' => 'OpenWeb',
// Operating Systems
'android' => 'Android',
'symbian' => 'Symbian',
'SymbianOS' => 'SymbianOS',
'elaine' => 'Palm',
'series60' => 'Symbian S60',
'windows ce' => 'Windows CE',
// Browsers
'obigo' => 'Obigo',
'netfront' => 'Netfront Browser',
'openwave' => 'Openwave Browser',
'mobilexplorer' => 'Mobile Explorer',
'operamini' => 'Opera Mini',
'opera mini' => 'Opera Mini',
'opera mobi' => 'Opera Mobile',
'fennec' => 'Firefox Mobile',
// Other
'digital paths' => 'Digital Paths',
'avantgo' => 'AvantGo',
'xiino' => 'Xiino',
'novarra' => 'Novarra Transcoder',
'vodafone' => 'Vodafone',
'docomo' => 'NTT DoCoMo',
'o2' => 'O2',
// Fallback
'mobile' => 'Generic Mobile',
'wireless' => 'Generic Mobile',
'j2me' => 'Generic Mobile',
'midp' => 'Generic Mobile',
'cldc' => 'Generic Mobile',
'up.link' => 'Generic Mobile',
'up.browser' => 'Generic Mobile',
'smartphone' => 'Generic Mobile',
'cellphone' => 'Generic Mobile',
];
/**
* -------------------------------------------------------------------
* Robots
* -------------------------------------------------------------------
*
* There are hundred of bots but these are the most common.
*
* @var array<string, string>
*/
public array $robots = [
'googlebot' => 'Googlebot',
'msnbot' => 'MSNBot',
'baiduspider' => 'Baiduspider',
'bingbot' => 'Bing',
'slurp' => 'Inktomi Slurp',
'yahoo' => 'Yahoo',
'ask jeeves' => 'Ask Jeeves',
'fastcrawler' => 'FastCrawler',
'infoseek' => 'InfoSeek Robot 1.0',
'lycos' => 'Lycos',
'yandex' => 'YandexBot',
'mediapartners-google' => 'MediaPartners Google',
'CRAZYWEBCRAWLER' => 'Crazy Webcrawler',
'adsbot-google' => 'AdsBot Google',
'feedfetcher-google' => 'Feedfetcher Google',
'curious george' => 'Curious George',
'ia_archiver' => 'Alexa Crawler',
'MJ12bot' => 'Majestic-12',
'Uptimebot' => 'Uptimebot',
];
}
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Validation\StrictRules\CreditCardRules;
use CodeIgniter\Validation\StrictRules\FileRules;
use CodeIgniter\Validation\StrictRules\FormatRules;
use CodeIgniter\Validation\StrictRules\Rules;
class Validation extends BaseConfig
{
// --------------------------------------------------------------------
// Setup
// --------------------------------------------------------------------
/**
* Stores the classes that contain the
* rules that are available.
*
* @var string[]
*/
public array $ruleSets = [
Rules::class,
FormatRules::class,
FileRules::class,
CreditCardRules::class,
];
/**
* Specifies the views that are used to display the
* errors.
*
* @var array<string, string>
*/
public array $templates = [
'list' => 'CodeIgniter\Validation\Views\list',
'single' => 'CodeIgniter\Validation\Views\single',
'is_unique' => 'El valor del campo {field} ya está en uso. Por favor, elige otro valor.',
];
// --------------------------------------------------------------------
// Rules
// --------------------------------------------------------------------
}
<?php
namespace Config;
use CodeIgniter\Config\View as BaseView;
use CodeIgniter\View\ViewDecoratorInterface;
class View extends BaseView
{
/**
* When false, the view method will clear the data between each
* call. This keeps your data safe and ensures there is no accidental
* leaking between calls, so you would need to explicitly pass the data
* to each view. You might prefer to have the data stick around between
* calls so that it is available to all views. If that is the case,
* set $saveData to true.
*
* @var bool
*/
public $saveData = true;
/**
* Parser Filters map a filter name with any PHP callable. When the
* Parser prepares a variable for display, it will chain it
* through the filters in the order defined, inserting any parameters.
* To prevent potential abuse, all filters MUST be defined here
* in order for them to be available for use within the Parser.
*
* Examples:
* { title|esc(js) }
* { created_on|date(Y-m-d)|esc(attr) }
*
* @var array
*/
public $filters = [];
/**
* Parser Plugins provide a way to extend the functionality provided
* by the core Parser by creating aliases that will be replaced with
* any callable. Can be single or tag pair.
*
* @var array
*/
public $plugins = [];
/**
* View Decorators are class methods that will be run in sequence to
* have a chance to alter the generated output just prior to caching
* the results.
*
* All classes must implement CodeIgniter\View\ViewDecoratorInterface
*
* @var class-string<ViewDecoratorInterface>[]
*/
public array $decorators = [];
}
......@@ -47,7 +47,7 @@ class App extends BaseConfig
* something else. If you are using mod_rewrite to remove the page set this
* variable so that it is blank.
*/
public string $indexPage = 'index.php';
public string $indexPage = '';
/**
* --------------------------------------------------------------------------
......
......@@ -20,7 +20,7 @@ class Cache extends BaseConfig
* The name of the preferred handler that should be used. If for some reason
* it is not available, the $backupHandler will be used in its place.
*/
public string $handler = 'file';
public string $handler = 'memcached';
/**
* --------------------------------------------------------------------------
......
......@@ -21,6 +21,9 @@ class Filters extends BaseConfig
'honeypot' => Honeypot::class,
'invalidchars' => InvalidChars::class,
'secureheaders' => SecureHeaders::class,
'user_auth' => \App\Filters\UserAuth::class,
'admin_auth' => \App\Filters\AdminAuth::class,
];
/**
......
......@@ -50,7 +50,7 @@ class Paths
* for maximum security, keeping it out of the app and/or
* system directories.
*/
public string $writableDirectory = __DIR__ . '/../../writable';
public string $writableDirectory = '/tmp';
/**
* ---------------------------------------------------------------
......
<?php
namespace Config;
use App\Controllers\RecipesController;
// Create a new instance of our RouteCollection class.
$routes = Services::routes();
......@@ -29,12 +31,59 @@ $routes->set404Override();
// We get a performance increase by specifying the default
// route since we don't have to scan directories.
$routes->get('/', 'Home::index');
use App\Controllers\User;
$routes->match(['get'], '/', [User::class, 'login']);
$routes->match(['get', 'post'], '/login', [User::class, 'login']);
$routes->match(['get', 'post'], '/loginAjax', [User::class, 'loginAjax']);
$routes->match(['get', 'post'], '/registerAjax', [User::class, 'registerAjax']);
$routes->match(['get'], '/home', [User::class, 'user_ok']);
// Ruta para boorar una receta dada un id
$routes->get('/recipes/delete/(:num)', 'RecipesController::delete/$1');
// Ruta cuando se cierra la sesión
$routes->get('/logout', 'User::logout');
// Ruta para ver una receta
$routes->get('/recipe/(:num)', 'RecipesController::view_recipe/$1');
// Ruta para obtener una imagen de una receta dado un id
$routes->get('recipe/image/(:num)', 'RecipesController::show_image/$1');
// Ruta para obtener un nombre de usuario dado un email
$routes->get('username/(:any)', 'User::show_name/$1');
// Rutas para formulario de ingresar recetas
$routes->get('/insert_recipe', 'InsertRecipeController::index', ['filter' => 'user_auth']);
$routes->match(['get', 'post'], '/search_ingredient', 'InsertRecipeController::search_ingredient');
$routes->post('/insert_recipe', 'InsertRecipeController::insert_recipe');
// Ruta para la búsqueda de recetas
$routes->match(['get', 'post'], '/search_recipe', 'RecipesController::search_recipe');
// Ruta para vista "Mis recetas"
$routes->get('/myrecipes', 'User::personalRecipes', ['filter' => 'user_auth']);
// Ruta para vista "Mi perfil"
$routes->get('/profile', 'User::myprofile', ['filter' => 'user_auth']);
$routes->post('/profile', 'User::editProfile'); // Cambia la ruta para editar perfil
$routes->get('login','Pages::viewLogin');
$routes->get('users', 'User::list', ['filter' => 'admin_auth']);
$routes->get('home','Pages::prueba');
$routes->get('(:segment)', 'Home::index');
// Ruta para el filtrado de recetas usando AJAX
$routes->match(['get', 'post'], '/getFilteredRecipes', [RecipesController::class, 'getFilteredRecipes']);
/*
* --------------------------------------------------------------------
* Additional Routing
......
......@@ -36,6 +36,7 @@ class Validation extends BaseConfig
public array $templates = [
'list' => 'CodeIgniter\Validation\Views\list',
'single' => 'CodeIgniter\Validation\Views\single',
'is_unique' => 'El valor del campo {field} ya está en uso. Por favor, elige otro valor.',
];
// --------------------------------------------------------------------
......
......@@ -8,4 +8,6 @@ class Home extends BaseController
{
return view('welcome_message');
}
}
<?php
namespace App\Controllers;
class Insert extends BaseController
{
public function insertAjax()
{
$validation = \Config\Services::validation();
$rules = [
"recipe_name" => [
"label" => "name",
"rules" => "required"
],
"recipe_description" => [
"label" => "description",
"rules" => "required"
],
"is_vegan" => [
"label" => "is_vegan"
],
"origin" => [
"label" => "origin"
],
"season" => [
"label" => "season"
],
"instructions" => [
"label" => "instructions"
],
"recipe_photo" => [
"label" => "photo"
],
"recipe_video" => [
"label" => "link"
]
];
$data = [];
$session = session();
$recipes_model = model('RecipesModel');
if ($this->request->getMethod() == "post") {
if ($this->validate($rules)) {
// Código de registro y respuesta exitosa
$recipe_name = $this->request->getVar('recipe_name');
$recipe_description = $this->request->getVar('recipe_description');
$is_vegan = $this->request->getPost('is_vegan') !== null ? 1 : 0;
$origin = $this->request->getVar('origin');
$season = $this->request->getVar('season');
$instructions = $this->request->getVar('instructions');
$recipe_photo = $this->request->getVar('recipe_photo');
$recipe_video = $this->request->getVar('recipe_video');
$recipeData = [
'recipe_name' => $recipe_name,
'recipe_description' => $recipe_description,
'is_vegan' => $is_vegan, // Aquí usamos $is_vegan
'origin' => $origin,
'season' => $season,
'instructions' => $instructions,
'recipe_photo' => $recipe_photo,
'recipe_video' => $recipe_video,
];
$recipes_model->saveRecipe($recipe_name,$season,$origin,$recipe_photo,$is_vegan,$recipe_description,$instructions,$recipe_video);
return $this->response->setStatusCode(200)->setJSON([
'text' => 'Receta añadida'
]);
} else {
$error_message = '';
if ($validation->getError('recipe_name')) {
$error_message = 'Hay que añadir nombre a la receta';
} elseif ($validation->getError('recipe_description')) {
$error_message = 'Se necesita una descripcion';
} else {
$error_message = 'Error desconocido';
}
return $this->response->setStatusCode(400)->setJSON([
'text' => $error_message
]);
}
}
return $this->response->setStatusCode(400)->setJSON([
'text' => 'Solo se aceptan post request'
]);
}
}
\ No newline at end of file
<?php
namespace App\Controllers;
use CodeIgniter\Controller;
class InsertRecipeController extends Controller
{
public function index()
{
$data['vista'] = 'insert';
return view('templates/header', $data)
. view('pages/insertRecipe')
. view('templates/footer');
}
public function search_ingredient()
{
// Obtener la consulta de búsqueda desde el formulario
$query = $this->request->getVar('query');
// Cargar el modelo de ingredientes (si no lo has hecho)
$ingredientModel = new \App\Models\IngredientModel();
// Buscar ingredientes en la base de datos que coincidan con la consulta
$ingredients = $ingredientModel->search_ingredient($query);
// Devolver los ingredientes coincidentes en formato JSON
return $this->response->setJSON($ingredients);
}
public function insert_recipe()
{
// Cargar los modelos necesarios
$recipeModel = new \App\Models\RecipesModel();
$recipesIngredientModel = new \App\Models\RecipesIngredientModel();
// Obtener los datos del formulario
$recipeData = $this->request->getPost();
$selectedIngredients = json_decode($recipeData['selected_ingredients'], true);
// Eliminar el elemento 'selected_ingredients' de los datos de la receta
unset($recipeData['selected_ingredients']);
// Manejar el archivo de imagen
$photo = $this->request->getFile('photo');
if ($photo->isValid() && !$photo->hasMoved()) {
$photoBlob = file_get_contents($photo->getRealPath());
$recipeData['photo'] = $photoBlob;
}
// Obtener el email del usuario de la sesión
$session = session();
$userEmail = $session->get('user')->email;
// Agregar el email del usuario a los datos de la receta
$recipeData['email_user'] = $userEmail;
// Insertar la receta en la tabla 'recipes'
$recipeId = $recipeModel->insert($recipeData);
// Insertar los ingredientes seleccionados y sus cantidades en la tabla 'recipes_ingredient'
foreach ($selectedIngredients as $ingredient) {
$recipesIngredientModel->insert([
'id_recipe' => $recipeId,
'id_ingredient' => $ingredient['id'],
'amount' => $ingredient['amount']
]);
}
// Redireccionar a la página principal
return redirect()->to('/home');
}
}
\ No newline at end of file
......@@ -22,7 +22,7 @@ public function index()
throw new PageNotFoundException($page);
}
$data['title'] = ucfirst($page); // Capitalize the first letter
$data['vista'] = 'home';
return view('templates/header', $data)
.view('pages/' . $page)
.view('templates/footer');
......@@ -39,4 +39,7 @@ public function index()
$data['title'] = ucfirst($page); // Capitalize the first letter
return view('pages/' . $page);
}
}
\ No newline at end of file
<?php
namespace App\Controllers;
use App\Models\RecipesModel;
use App\Models\RecipesIngredientModel;
use CodeIgniter\Controller;
class RecipesController extends Controller
{
public function view_recipe($recipe_id)
{
$recipesModel = new RecipesModel();
$recipe = $recipesModel->find($recipe_id);
$ingredients = $recipesModel->get_recipe_ingredients($recipe_id);
// Obtén el nombre de usuario a partir del correo electrónico
$userModel = new \App\Models\UserModel();
$email = $recipe->email_user;
$user = $userModel->where('email', $email)->first();
$username = $user->username;
$photo = $user->photo;
if ($recipe == null) {
// Mostrar un mensaje de error si no se encuentra la receta
return redirect()->to('/');
}
$data = [
'recipe' => $recipe,
'ingredients' => $ingredients,
'username' => $username,
'photoUser' => $photo,
];
$data2['vista'] = 'view';
return view('templates/header',$data2)
. view('pages/recipe_view', $data)
. view('templates/footer');
}
public function show_image($id)
{
$recipesModel = new \App\Models\RecipesModel();
$recipe = $recipesModel->find($id);
if ($recipe) {
$photo = $recipe->photo;
$finfo = new \finfo(FILEINFO_MIME_TYPE);
$mimeType = $finfo->buffer($photo);
$this->response->setHeader('Content-Type', $mimeType);
$this->response->setBody($photo);
$this->response->send();
}
}
public function search_recipe()
{
$query = $this->request->getVar('query');
$recipesModel = new \App\Models\RecipesModel();
$recipes = $recipesModel->searchRecipe($query);
return $this->response->setJSON($recipes);
}
public function delete($id)
{
$recipeModel = new RecipesModel();
$recipeIngredientModel = new RecipesIngredientModel();
// Primero, borra todas las entradas de la tabla recipes_ingredient
if ($recipeIngredientModel->deleteRelation($id)) {
// Si se eliminaron las relaciones correctamente, borra la receta
if ($recipeModel->deleteRecipe($id)) {
// La receta se eliminó correctamente
return redirect()->to('/users')->with('message', 'Receta eliminada correctamente');
} else {
// Hubo un error al eliminar la receta
return redirect()->back()->with('error', 'No se pudo eliminar la receta');
}
} else {
// Hubo un error al eliminar las relaciones
return redirect()->back()->with('error', 'No se pudieron eliminar las relaciones de ingredientes de la receta');
}
}
public function getFilteredRecipes()
{
$model = new RecipesModel();
$filters = $this->request->getPost();
$recipes = $model->filterRecipes($filters);
return $this->response->setJSON($recipes);
}
}
\ No newline at end of file
<?php
namespace App\Controllers;
class User extends BaseController
{
public function list()
{
$userModel = new \App\Models\UserModel();
$data['users'] = $userModel->findAll();
$data2['vista'] = 'list';
return view('templates/header',$data2)
. view('user/list', $data)
. view('templates/footer');
}
public function admin_list()
{
$userModel = new \App\Models\UserModel();
$data['users'] = $userModel->findAll();
return view('templates/header')
. view('user/list', $data)
. view('templates/footer');
}
public function login()
{
return view('pages/login', []);
}
public function loginAjax()
{
$validation = \Config\Services::validation();
$rules = [
"email" => [
"label" => "Email",
"rules" => "required"
//"rules" => "required|min_length[3]|max_length[20]|valid_email|is_unique[user.email]"
],
"password" => [
"label" => "Password",
"rules" => "required"
//"rules" => "required|min_length[8]|max_length[20]"
]
];
$session = session();
$userModel = model('UserModel');
if ($this->request->getMethod() == "post") {
if ($this->validate($rules)) {
$email = $this->request->getVar('email');
$password = $this->request->getVar('password');
$user = model('UserModel')->authenticate($email, $password);
if ($user) {
$session->set('logged_in', TRUE);
$session->set('user', $user);
return $this->response->setStatusCode(200)->setJSON([
'text' => 'Usuario logeado'
]);
} else {
return $this->response->setStatusCode(403)->setJSON([
'text' => 'Usuario no logeado'
]);
}
} else {
return $this->output->set_content_type('application/json')
->set_status_header(400)
->set_output(json_encode([
'text' => 'Email o pasword incorrecto'
]));
}
}
return $this->response->setStatusCode(400)->setJSON([
'text' => 'Solo se aceptan post request'
]);
}
public function user_ok()
{
$data['vista'] = 'home';
return view('templates/header', $data)
. view('pages/home')
. view('templates/footer');
}
public function logout()
{
$session = session();
$session->destroy();
return redirect()->to('/login');
}
public function unauthorized()
{
return view('templates/header')
. view('user/unauthorized')
. view('templates/footer');
}
public function registerAjax()
{
$validation = \Config\Services::validation();
$rules = [
"username" => [
"label" => "Username",
"rules" => "required"
],
"email" => [
"label" => "Email",
"rules" => "required|valid_email|is_unique[user.email]"
],
"password" => [
"label" => "Password",
"rules" => "required|min_length[8]|max_length[20]"
]
];
$data = [];
$session = session();
$userModel = model('UserModel');
if ($this->request->getMethod() == "post") {
if ($this->validate($rules)) {
// Código de registro y respuesta exitosa
$name = $this->request->getVar('username');
$email = $this->request->getVar('email');
$password = $this->request->getVar('password');
$role = $this->request->getVar('rol');
$userData = [
'username' => $name,
'email' => $email,
'password' => password_hash($password, PASSWORD_DEFAULT),
'rol' => $role,
'photo' => null
];
$userModel->saveUser($email, $name, $password);
$newUser = $userModel->authenticate($email, $password);
$session->set('logged_in', TRUE);
$session->set('user', $newUser);
return $this->response->setStatusCode(200)->setJSON([
'text' => 'Usuario logeado'
]);
} else {
$error_message = '';
if ($validation->getError('email')) {
$error_message = 'Email ya en uso o inválido';
} elseif ($validation->getError('password')) {
$error_message = 'La contraseña debe tener entre 8 y 20 caracteres';
} else {
$error_message = 'Error desconocido';
}
return $this->response->setStatusCode(400)->setJSON([
'text' => $error_message
]);
}
}
return $this->response->setStatusCode(400)->setJSON([
'text' => 'Solo se aceptan post request'
]);
}
public function show_name($email)
{
$userModel = new \App\Models\UserModel();
$user = $userModel->find($email);
if ($user) {
return $user->username;
}
return false;
}
public function personalRecipes()
{
$data['vista'] = 'profile';
return view('templates/header', $data)
. view('pages/userRecipes')
. view('templates/footer');
}
public function myprofile()
{
$data['vista'] = 'profile';
return view('templates/header', $data)
. view('pages/profile_view')
. view('templates/footer');
}
public function editProfile()
{
$session = session();
$userModel = new \App\Models\UserModel();
if($this->request->getMethod() === 'post') {
$username = $this->request->getPost('username');
// Manejar el archivo de imagen
$photo = $this->request->getFile('photo');
$photoBlob = null;
if ($photo->isValid() && !$photo->hasMoved()) {
$photoBlob = file_get_contents($photo->getRealPath());
$userModel->updateUser($session->get('user')->email, $username, $photoBlob);
} else {
// Actualiza solo el nombre de usuario si no se ha subido una nueva foto
$userModel->updateUser($session->get('user')->email, $username, $session->get('user')->photo);
}
// Actualizar datos de la sesión
$session->set('user', $userModel->find($session->get('user')->email));
$session->setFlashdata('success', 'Profile updated successfully');
return redirect()->to('/profile'); // Cambia la redirección a '/profile'
}
$data['user'] = $session->get('user');
return view('edit_profile', $data);
}
}
\ No newline at end of file
<?php
namespace App\Filters;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use CodeIgniter\Filters\FilterInterface;
class AdminAuth implements FilterInterface
{
public function before(RequestInterface $request, $arguments = null)
{
if (!session('logged_in'))
return redirect()->to(site_url('/login'));
elseif ((session('user')->rol & 2) == 0)
return redirect()->to(site_url('/login'));
}
public function after(
RequestInterface $request, ResponseInterface $response,
$arguments = null
) {
}
}
\ No newline at end of file
<?php
namespace App\Filters;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use CodeIgniter\Filters\FilterInterface;
class UserAuth implements FilterInterface
{
public function before(RequestInterface $request, $arguments = null)
{
if (!session('logged_in'))
return redirect()->to(site_url('/login'));
}
public function after(
RequestInterface $request, ResponseInterface $response,
$arguments = null
) {
}
}
\ No newline at end of file
<?php
namespace App\Models;
use CodeIgniter\Model;
class IngredientModel extends Model
{
protected $table = 'ingredient';
protected $primaryKey = 'id';
protected $useAutoIncrement = true; # db takes care of it
protected $returnType = 'object'; # 'object' or 'array'
protected $useSoftDeletes = false; # true if you expect to recover data
# Fields that can be set during save, insert, or update methods
protected $allowedFields = ['id', 'name', 'icon'];
protected $useTimestamps = false; # no timestamps on inserts and updates
# Do not use validations rules (for the time being...)
protected $validationRules = [];
protected $validationMessages = [];
protected $skipValidation = false;
public function saveIngredient($id, $name, $icon)
{
$data = [
'id' => $id,
'name' => $name,
'icon' => $icon,
];
return $this->insert($data);
}
public function search_ingredient($query)
{
if ($query) {
return $this->like('name', $query)->findAll();
}
return [];
}
}
\ No newline at end of file
<?php
namespace App\Models;
use CodeIgniter\Model;
class RecipesIngredientModel extends Model
{
protected $table = 'recipes_ingredient';
protected $primaryKey = 'id';
protected $useAutoIncrement = true; # db takes care of it
protected $returnType = 'object'; # 'object' or 'array'
protected $useSoftDeletes = false; # true if you expect to recover data
# Fields that can be set during save, insert, or update methods
protected $allowedFields = ['id', 'amount', 'id_recipe','id_ingredient'];
protected $useTimestamps = false; # no timestamps on inserts and updates
# Do not use validations rules (for the time being...)
protected $validationRules = [];
protected $validationMessages = [];
protected $skipValidation = false;
public function saveRecipe($id, $amount, $id_recipe, $id_ingredient)
{
$data = [
'id' => $id,
'amount' => $amount,
'id_recipe' => $id_recipe,
'id_ingredient' => $id_ingredient,
];
return $this->insert($data);
}
public function deleteRelation($id_recipe) {
return $this->where('id_recipe', $id_recipe)->delete();
}
}
\ No newline at end of file
<?php
namespace App\Models;
use CodeIgniter\Model;
class RecipesModel extends Model
{
protected $table = 'recipes';
protected $primaryKey = 'id';
protected $useAutoIncrement = true; # db takes care of it
protected $returnType = 'object'; # 'object' or 'array'
protected $useSoftDeletes = false; # true if you expect to recover data
# Fields that can be set during save, insert, or update methods
protected $allowedFields = ['id', 'name', 'season', 'origin', 'photo', 'is_vegan', 'description', 'instructions', 'link', 'email_user'];
protected $useTimestamps = false; # no timestamps on inserts and updates
# Do not use validations rules (for the time being...)
protected $validationRules = [];
protected $validationMessages = [];
protected $skipValidation = false;
public function saveRecipe($id, $name, $season, $origin, $photo, $is_vegan, $description, $instructions, $link, $email_user)
{
$data = [
'id' => $id,
'name' => $name,
'season' => $season,
'origin' => $origin,
'photo' => $photo,
'is_vegan' => $is_vegan,
'description' => $description,
'instructions' => $instructions,
'link' => $link,
'email_user' => $email_user
];
return $this->insert($data);
}
public function get_recipe_ingredients($recipe_id)
{
$builder = $this->db->table('recipes_ingredient');
$builder->select('ingredient.name, ingredient.icon, recipes_ingredient.amount');
$builder->join('ingredient', 'recipes_ingredient.id_ingredient = ingredient.id');
$builder->where('recipes_ingredient.id_recipe', $recipe_id);
$query = $builder->get();
return $query->getResult();
}
public function searchRecipe($query)
{
if ($query) {
// Seleccionar todas las columnas excepto 'photo'
$this->select('id, name, season, origin, is_vegan, description, instructions, link');
return $this->like('name', $query)->findAll();
}
return [];
}
public function deleteRecipe($id) {
return $this->delete($id);
}
/* public function filterRecipes($filters){
$builder = $this->builder();
if(isset($filters['origin'])){
$builder->whereIn('origin', $filters['origin']);
}
if(isset($filters['season'])){
$builder->whereIn('season', $filters['season']);
}
if(isset($filters['is_vegan'])){
$builder->whereIn('is_vegan', $filters['is_vegan']);
}
return $builder->get()->getResultArray();*/
public function filterRecipes($filters)
{
$builder = $this->db->table('recipes');
$builder->select('id, name, season, origin, is_vegan, description, instructions, link');
if (!empty($filters['origin'])) {
$builder->whereIn('origin', $filters['origin']);
}
if (!empty($filters['season'])) {
$builder->whereIn('season', $filters['season']);
}
if (!empty($filters['is_vegan'])) {
$builder->where('is_vegan', $filters['is_vegan']);
}
$query = $builder->get();
$recipes = $query->getResult();
// Itera sobre cada receta y obtén los ingredientes de cada una
foreach ($recipes as $recipe) {
$recipe->ingredients = $this->get_recipe_ingredients($recipe->id);
}
return $recipes;
}
}
<?php
namespace App\Models;
use CodeIgniter\Model;
class UserModel extends Model
{
protected $table = 'user';
protected $primaryKey = 'email';
protected $useAutoIncrement = true; # db takes care of it
protected $returnType = 'object'; # 'object' or 'array'
protected $useSoftDeletes = false; # true if you expect to recover data
# Fields that can be set during save, insert, or update methods
protected $allowedFields = ['email', 'username', 'password', 'photo'];
protected $useTimestamps = false; # no timestamps on inserts and updates
# Do not use validations rules (for the time being...)
protected $validationRules = [];
protected $validationMessages = [];
protected $skipValidation = false;
public function authenticate($email, $password)
{
$user = $this->where('email', $email)->first();
if ($user && password_verify($password, $user->password))
return $user;
return FALSE;
}
public function saveUser($email, $username, $password)
{
$data = [
'email' => $email,
'username' => $username,
'password' => password_hash($password, PASSWORD_DEFAULT),
];
return $this->insert($data);
}
public function updateUser($email, $username, $photo)
{
$data = [
'username' => $username,
'photo' => $photo,
];
return $this->update($email, $data);
}
}
\ No newline at end of file
<<<<<<< HEAD
<!-- ======= Sidebar ======= -->
<aside id="sidebar" class="sidebar">
......@@ -244,11 +245,22 @@
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="index.html">Home</a></li>
<li class="breadcrumb-item active">Dashboard</li>
=======
<main id="main" class="main">
<div class="pagetitle">
<h1>Recetas</h1>
<nav>
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="index.html">Home</a></li>
<li class="breadcrumb-item active">Recetas</li>
>>>>>>> developJC
</ol>
</nav>
</div><!-- End Page Title -->
<section class="section dashboard">
<<<<<<< HEAD
<div class="row">
<!-- Left side columns -->
......@@ -899,7 +911,131 @@
</div><!-- End Right side columns -->
</div>
=======
<?php
$recipesModel = new \App\Models\RecipesModel();
$recipes = $recipesModel->findAll();
if (sizeof($recipes) > 0) {
foreach ($recipes as $row) {
$ingredients = $recipesModel->get_recipe_ingredients($row->id);
?>
<!-- Inicio de la tarjeta de la receta -->
<div class="card info-card sales-card recipe-card"
onclick="window.location.href='<?php echo base_url('recipe/' . $row->id); ?>'">
<a href="<?php echo base_url('recipe/' . $row->id); ?>">
</a>
<div class="row flex-nowrap">
<div class="col-lg-3 col-md-4 col-sm-12 imagen-container">
<img src="<?php echo base_url('recipe/image/' . $row->id); ?>" alt=""
class="img-fluid rounded-start">
</div>
<div class="col-lg-9 col-md-8 col-sm-12">
<div class="card-body">
<h5 class="card-title">
<?php echo $row->name; ?> <span>|
<?php echo $row->origin; ?>
</span>
</h5>
<!--ingredientes-->
<?php foreach ($ingredients as $ingredient) { ?>
<div class="chip" title="Cantidad: <?php echo $ingredient->amount; ?>">
<img src="imagenes/ingredientes/<?php echo $ingredient->icon; ?>">
<b style="font-size: 14px">
<?php echo $ingredient->name; ?>
</b>
</div>
<?php } ?>
<!--fin ingredientes-->
</div>
</div>
</div>
</div>
<!-- Fin de la tarjeta de la receta -->
<?php
}
}
?>
>>>>>>> developJC
</section>
</main><!-- End #main -->
<<<<<<< HEAD
=======
<script type="text/javascript">
var base_url = '<?php echo base_url(); ?>';
</script>
<script>
$(document).ready(function () {
$('.filter-checkbox').on('change', function () {
let filters = {
is_vegan: $('#checkboxOne').is(':checked') ? 1 : 0,
origin: [],
season: []
};
// agrega los valores de los checkboxes seleccionados a los filtros
$('.indian-cboxtags input:checked, .french-cboxtags input:checked, .chinese-cboxtags input:checked, .mexican-cboxtags input:checked, .spanish-cboxtags input:checked, .japanese-cboxtags input:checked').each(function () {
filters.origin.push($(this).val());
});
$('.winter-cboxtags input:checked, .spring-cboxtags input:checked, .summer-cboxtags input:checked, .autumn-cboxtags input:checked').each(function () {
filters.season.push($(this).val());
});
$.post('/getFilteredRecipes', filters, function (data) {
// Limpia la sección de recetas antes de agregar las nuevas recetas
$('.section.dashboard').empty();
// Genera el contenido HTML para cada receta y lo agrega a la sección de recetas
$.each(data, function (i, recipe) {
let ingredientsHtml = '';
$.each(recipe.ingredients, function (j, ingredient) {
ingredientsHtml += `
<div class="chip" title="Cantidad: ${ingredient.amount}">
<img src="imagenes/ingredientes/${ingredient.icon}">
<b style="font-size: 14px">${ingredient.name}</b>
</div>`;
});
let recipeHtml = `
<div class="card info-card sales-card recipe-card" onclick="window.location.href='recipe/${recipe.id}'">
<a href="recipe/${recipe.id}"></a>
<div class="row flex-nowrap">
<div class="col-lg-3 col-md-4 col-sm-12 imagen-container">
<img src="${base_url}/recipe/image/${recipe.id}" alt="" class="img-fluid rounded-start">
</div>
<div class="col-lg-9 col-md-8 col-sm-12">
<div class="card-body">
<h5 class="card-title">
${recipe.name} <span>| ${recipe.origin}</span>
</h5>
${ingredientsHtml}
</div>
</div>
</div>
</div>`;
$('.section.dashboard').append(recipeHtml);
});
}, 'json');
});
});
</script>
>>>>>>> developJC
<link rel="stylesheet" href="<?= base_url("css/insert.css") ?>">
<main id="main" class="main">
<section class="section dashboard">
<h1>Subir una receta</h1>
<form action=<?= base_url('/insert_recipe'); ?> method="post" enctype="multipart/form-data" class="my-form">
<div class="form-content">
<div class="form-group name-group">
<label for="name">Nombre de la receta:</label>
<input type="text" id="name" name="name" required class="form-control name-input">
</div>
<div class="form-group photo-group">
<div class="image-upload-container">
<input type="file" id="photo" name="photo" accept="image/*" class="form-control-file" style="display:none;">
<label for="photo" class="image-upload-label">Selecciona o arrastra aquí una imagen de la receta</label>
<img id="image-preview" src="#" alt="Vista previa de la imagen" style="display:none;">
</div>
</div>
</div>
<!-- Seleccionar descripción -->
<div class="form-group">
<label for="description">Descripción de la receta:</label>
<textarea id="description" name="description" rows="4" cols="50" required class="form-control"></textarea>
</div>
<!-- Seleccionar instrucciones -->
<div class="form-group">
<label for="instructions">Instrucciones:</label>
<textarea id="instructions" name="instructions" rows="6" cols="50" required class="form-control"></textarea>
</div>
<div class="form-row">
<!-- Seleccionar origen -->
<div class="form-group col-md-4">
<label for="origin">Origen:</label>
<select id="origin" name="origin" class="form-control">
<option value="España">Española</option>
<option value="Francia">Francesa</option>
<option value="Japón">Japonesa</option>
<option value="México">Mexicana</option>
<option value="China">China</option>
<option value="India">India</option>
<option value="Otro">Otro</option>
</select>
</div>
<!-- Seleccionar temporada -->
<div class="form-group col-md-4">
<label for="season">Temporada:</label>
<select id="season" name="season" class="form-control">
<option value="Invierno">Invierno</option>
<option value="Primavera">Primavera</option>
<option value="Verano">Verano</option>
<option value="Otoño">Otoño</option>
<option value="4estaciones">4 estaciones</option>
</select>
</div>
<!-- Seleccionar vegano -->
<div class="form-group col-md-4">
<label for="is_vegan">Vegana?</label>
<select id="is_vegan" name="is_vegan" class="form-control">
<option value="1">Si</option>
<option value="0">No</option>
</select>
</div>
</div>
<!-- Seleccionar ingredientes -->
<label>Ingredientes:</label>
<div class="input-group my-form">
<input type="search" id="ingredient_search" name="ingredient_search" placeholder="Buscar ingredientes..."
class="form-control" />
</div>
<ul id="ingredients_list" class="ingredients-list list-unstyled"></ul>
<div class="form-group">
<label for="selected_ingredients">Ingredientes seleccionados:</label>
<div id="selected_ingredients" class="selected-ingredients-container"></div>
</div>
<!-- Modal para ingresar la cantidad del ingrediente -->
<div class="modal fade" id="quantityModal" tabindex="-1" role="dialog" aria-labelledby="quantityModalLabel"
aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="quantityModalLabel">Ingresa la cantidad</h5>
</button>
</div>
<div class="modal-body">
<div class="form-group">
<label for="ingredient_quantity">Cantidad</label>
<input type="text" class="form-control" id="ingredient_quantity" name="ingredient_quantity"
placeholder="Ej: 2 tazas, 1/2 cucharada, 4 kg...">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" id="cancel_quantity"
data-dismiss="modal">Cancelar</button>
<button type="button" class="btn btn-primary" id="save_quantity">Guardar</button>
</div>
</div>
</div>
</div>
<!-- Añadir ingrediente -->
<h5>¿No ves tu ingrediente en la lista?
<!-- Seleccionar enlace de video-->
<div class="form-group">
<label for="link">Ingrese el enlace del video:</label>
<input type="text" id="link" name="link" class="form-control"
placeholder="ej: https://www.youtube.com/watch?v=cks8liHVdZg">
</div>
<input type="submit" value="Subir receta" class="btn btn-primary">
</form>
<script src="<?= base_url("js/insert.js") ?>"></script>
</section>
</main><!-- End #main -->
\ No newline at end of file
......@@ -10,11 +10,23 @@
integrity="sha512-Wq3znUOIZtqZkpWpkTVRtRwQ2YyPCvT03zWlj+iS9dH1eNTjiOVlG2xgC4np4FXwL+Hgx1pjcTXy09pgH5u5HA=="
crossorigin="anonymous" referrerpolicy="no-referrer" />
<link rel="stylesheet" href="<?= base_url("css/login.css") ?>">
<<<<<<< HEAD
=======
<style>
body {
background-image: url("imagenes/fondoLogin.jpg");
background-size: 100% auto;
}
</style>
<script src="https://code.jquery.com/jquery-3.6.4.min.js"
integrity="sha256-oP6HI9z1XaZNBrJURtCoUT5SUnxFr8s3BzRl+cbzUq8=" crossorigin="anonymous"></script>
>>>>>>> developJC
</head>
<body>
<<<<<<< HEAD
<div class="col-md-8">
<div class="container" id="container">
......@@ -52,17 +64,102 @@
<input style="background-color: #eee;"type="password" placeholder="Contraseña" />
<a href="#">¿Olvidaste tu contraseña?</a>
<button id="signin-button">Iniciar Sesión</button>
=======
<a href="/home">
<img src="iconos/logoCompleto.png" alt="Página Principal" width="300" height="70"
style="margin-bottom: 20px; margin-top: 0px;">
</a>
<div class="col-md-8">
<div class="container login-container" id="container">
<div class="form-container sign-up-container">
<!-- FORMULARIO REGISTER -->
<form action=<?= base_url('/register'); ?> method="post"
style="flex-direction: column; padding: 0 30px;">
<h1 class="mobile-text">Crear cuenta</h1>
<div class="social-container">
<a href="https://accounts.google.com/" class="social mobile-icon"><img
src="<?= base_url("iconos/google.ico") ?>" width="53" height="53"></a>
<a href="https://www.facebook.com/" class="social mobile-icon"><img
src="<?= base_url("iconos/facebook.ico") ?>" width="52" height="52"></a>
<a href="https://appleid.apple.com/" class="social mobile-icon"><img
src="<?= base_url("iconos/apple.ico") ?>" width="52" height="52"></a>
</div>
<span>o usa tu correo</span>
<input style="background-color: #eee;" id="username-register-form" class="form-control"
name="username" type="text" placeholder="Nombre" />
<input style="background-color: #eee;" id="email-register-form" class="form-control" name="email"
type="email" placeholder="Email" />
<input style="background-color: #eee;" id="password-register-form" class="form-control"
name="password" type="password" id="password" placeholder="Contraseña" />
<span class="error">
<?= \Config\Services::validation()->listErrors(); ?>
</span>
<span class="error">
<?php if (session()->getFlashdata('register_error')): ?>
<div class="alert alert-danger">
<?= session()->getFlashdata('msg') ?>
</div>
<?php endif; ?>
</span>
<span class="register-error">Error</span>
<a href="#" class="switch-form" id="signin-link">Iniciar Sesión</a>
<button id="signup-button" type="submit">Registrarse</button>
</form>
</div>
<div class="form-container sign-in-container open">
<!-- FORMULARIO LOGIN -->
<form action=<?= base_url('/login'); ?> method="post" style="flex-direction: column; padding: 0 30px;">
<h1 class="mobile-text">Iniciar Sesión</h1>
<div class="social-container">
<a href="https://accounts.google.com/" class="social mobile-icon"><img
src="<?= base_url("iconos/google.ico") ?>" width="53" height="53"></a>
<a href="https://www.facebook.com/" class="social mobile-icon"><img
src="<?= base_url("iconos/facebook.ico") ?>" width="52" height="52"></a>
<a href="https://appleid.apple.com/" class="social mobile-icon"><img
src="<?= base_url("iconos/apple.ico") ?>" width="52" height="52"></a>
</div>
<span>o usa tu correo</span>
<input style="background-color: #eee;" id="email-form" class="form-control" name="email"
type="email" placeholder="Email" />
<input style="background-color: #eee;" id="password-form" class="form-control" name="password"
type="password" placeholder="Contraseña" />
<span class="login-error">Credenciales incorrectas</span>
<a href="#" class="switch-form" id="signup-link">Crear cuenta</a>
<button id="signin-button" type="submit">Iniciar Sesión</button>
>>>>>>> developJC
</form>
</div>
<div class="overlay-container">
<div class="overlay">
<div class="overlay-panel overlay-left">
<<<<<<< HEAD
<h1>¡Bienvenido a Wa2Eat!</h1>
=======
<h1 class="mobile-text">¡Bienvenido a Wa2Eat!</h1>
>>>>>>> developJC
<h8>Únete a la mayor comunidad de recetas en línea</h8>
<button class="ghost" id="signIn" style="margin-top: 10px;">Iniciar Sesión</button>
</div>
<div class="overlay-panel overlay-right">
<<<<<<< HEAD
<h1>¡Bienvenido de nuevo!</h1>
=======
<h1 class="mobile-text">¡Bienvenido de nuevo!</h1>
>>>>>>> developJC
<h8>Introduce tus credenciales y comienza a navegar</h8>
<button class="ghost" id="signUp" style="margin-top: 10px;">Registrarse</button>
</div>
......
<style>
.profile-container {
max-width: 500px;
margin: auto;
}
.profile-photo {
max-width: 200px;
display: block;
margin: 10px 0;
}
.save-btn-container {
margin-top: 20px;
}
</style>
<main id="main" class="main">
<section class="section dashboard">
<?php
$session = session();
$user = $session->get('user');
?>
<div class="container profile-container">
<div class="card">
<div class="card-header">
Editar usuario
</div>
<div class="card-body">
<form method="post" enctype="multipart/form-data">
<div class="form-group">
<label for="email">Email</label>
<input type="email" class="form-control" id="email" name="email" value="<?= $user->email ?>" readonly>
</div>
<div class="form-group">
<label for="username">Nombre de usuario</label>
<input type="text" class="form-control" id="username" name="username" value="<?= $user->username ?>">
</div>
<div class="form-group">
<label for="photo">Foto de perfil</label>
<?php if ($user->photo): ?>
<img src="data:image/jpeg;base64,<?= base64_encode($user->photo) ?>" alt="User photo" class="profile-photo" />
<?php endif; ?>
<input type="file" class="form-control" id="photo" name="photo">
</div>
<div class="text-center save-btn-container">
<button type="submit" class="btn btn-primary">Guardar cambios</button>
</div>
</form>
</div>
</div>
</div>
</section>
</main><!-- End #main -->
<?php
function getYoutubeVideoId($url)
{
$pattern = '/^(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([^"&?\/\s]{11})/i';
preg_match($pattern, $url, $matches);
return isset($matches[1]) ? $matches[1] : null;
}
?>
<link rel="stylesheet" href="<?= base_url("css/recipe_view.css") ?>">
<main id="main" class="main">
<section class="section dashboard">
<div class="container">
<div class="recipe-header">
<h1>
<?php echo $recipe->name; ?>
</h1>
<img src="<?php echo base_url('recipe/image/' . $recipe->id); ?>" alt="<?php echo $recipe->name; ?>" />
</div>
<p>
<?php echo $recipe->description; ?>
</p>
<div class="recipe-header">
<p>Receta subida por:
<b>
<?= $username ?>
<?php if (empty($photoUser)): ?>
<img src="<?= base_url("imagenes/profile.png") ?>" alt="Profile" id="profile-pic">
<?php else: ?>
<img src="data:image/jpeg;base64,<?= base64_encode($photoUser) ?>" alt="Profile"
id="profile-pic">
<?php endif; ?>
</b>
</p>
</div>
<h2>Ingredientes</h2>
<ul class="ingredient-list">
<?php foreach ($ingredients as $ingredient) { ?>
<li class="ingredient-item">
<img src="../imagenes/ingredientes/<?php echo $ingredient->icon; ?>"
alt="<?php echo $ingredient->name; ?>" />
<span>
<?php echo $ingredient->amount; ?>
</span>
</li>
<?php } ?>
</ul>
<h2>Instrucciones</h2>
<p class="instructions">
<?php echo $recipe->instructions; ?>
</p>
<?php if (!empty($recipe->link)): ?>
<?php $videoId = getYoutubeVideoId($recipe->link); ?>
<?php if ($videoId): ?>
<h2>Video de la receta</h2>
<div class="video-container">
<iframe width="560" height="315" src="https://www.youtube.com/embed/<?php echo $videoId; ?>"
title="YouTube video player" frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen></iframe>
</div>
<?php endif; ?>
<?php endif; ?>
</div>
</section>
</main><!-- End #main -->
<?php $session = session(); ?>
<main id="main" class="main">
<section class="section dashboard">
<?php
$recipesModel = new \App\Models\RecipesModel();
$recipes = $recipesModel->findAll();
if (sizeof($recipes) > 0) {
foreach ($recipes as $row) {
$ingredients = $recipesModel->get_recipe_ingredients($row->id);
?>
<?php if ($session->get('user')->email == $row->email_user): ?>
<!-- Inicio de la tarjeta de la receta -->
<div class="card info-card sales-card recipe-card"
onclick="window.location.href='<?php echo base_url('recipe/' . $row->id); ?>'">
<a href="<?php echo base_url('recipe/' . $row->id); ?>">
</a>
<div class="row flex-nowrap">
<div class="col-lg-3 col-md-4 col-sm-12 imagen-container">
<img src="<?php echo base_url('recipe/image/' . $row->id); ?>" alt=""
class="img-fluid rounded-start">
</div>
<div class="col-lg-9 col-md-8 col-sm-12">
<div class="card-body">
<h5 class="card-title">
<?php echo $row->name; ?> <span>|
<?php echo $row->origin; ?>
</span>
</h5>
<!--ingredientes-->
<?php foreach ($ingredients as $ingredient) { ?>
<div class="chip" title="Cantidad: <?php echo $ingredient->amount; ?>">
<img src="imagenes/ingredientes/<?php echo $ingredient->icon; ?>">
<b style="font-size: 14px">
<?php echo $ingredient->name; ?>
</b>
</div>
<?php } ?>
<!--fin ingredientes-->
</div>
</div>
</div>
</div>
<!-- Fin de la tarjeta de la receta -->
<?php endif; ?>
<?php
}
}
?>
</section>
</main><!-- End #main -->
\ No newline at end of file
<<<<<<< HEAD
<!-- ======= Footer ======= -->
<footer id="footer" class="footer">
<div class="copyright">
......@@ -26,4 +27,41 @@
</body>
=======
<!-- End page content -->
</div>
</main>
<!-- Vendor JS Files -->
<script src="js/apexcharts.min.js"></script>
<script src="js/bootstrap.bundle.min.js"></script>
<script src="js/chart.umd.js"></script>
<script src="js/echarts.min.js"></script>
<script src="js/quill.min.js"></script>
<script src="js/simple-datatables.js"></script>
<script src="js/tinymce.min.js"></script>
<script src="js/validate.js"></script>
<!-- Template Main JS File -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="js/main.js"></script>
</body>
<footer id="footer" class="footer">
<div class="copyright">
&copy; Copyright <strong><span>Manolo y JC</span></strong>. All Rights Reserved & Not Copyright intended
</div>
<div class="credits">
<!-- All the links in the footer should remain intact. -->
<!-- You can delete the links only if you purchased the pro version. -->
<!-- Licensing information: https://bootstrapmade.com/license/ -->
<!-- Purchase the pro version with working PHP/AJAX contact form: https://bootstrapmade.com/nice-admin-bootstrap-admin-html-template/ -->
Designed by Manolo y JC
</div>
</footer><!-- End Footer -->
>>>>>>> developJC
</html>
\ No newline at end of file
<main id="main" class="main">
<section class="section dashboard">
<h2>Usuarios</h2>
<!-- LISTA DE USUARIOS -->
<?php
if (sizeof($users) > 0) {
foreach ($users as $row) {
echo $row->email . " - ";
echo $row->username . " - ";
echo $row->password . " ";
echo "<br/>";
}
} else {
echo "No user";
}
?>
<h2> Recetas </h2>
<!-- LISTA DE RECETAS -->
<?php
$recipesModel = new \App\Models\RecipesModel();
$recipes = $recipesModel->findAll();
?>
<table class="table">
<thead>
<tr>
<th>ID</th>
<th>Nombre</th>
<th>Temporada</th>
<th>Origen</th>
<th>Foto</th>
<th>Vegano</th>
<th>Descripción</th>
<th>Instrucciones</th>
<th>Enlace</th>
<th>Acciones</th>
</tr>
</thead>
<tbody>
<?php foreach ($recipes as $row): ?>
<tr>
<td>
<?= $row->id; ?>
</td>
<td>
<?= $row->name; ?>
</td>
<td>
<?= $row->season; ?>
</td>
<td>
<?= $row->origin; ?>
</td>
<td>
<img src="<?= base_url('recipe/image/' . $row->id); ?>" alt="" class="img-thumbnail"
style="width: 100px;">
</td>
<td>
<?= $row->is_vegan ? 'Sí' : 'No'; ?>
</td>
<td>
<?= mb_strimwidth($row->description, 0, 10, "..."); ?>
</td>
<td>
<?= mb_strimwidth($row->instructions, 0, 10, "..."); ?>
</td>
<td>
<?= mb_strimwidth($row->link, 0, 50, "..."); ?>
</td>
<td>
<button class="btn btn-danger" onclick="window.location.href='<?php echo base_url('/recipes/delete/' . $row->id); ?>'">Borrar</button>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<script>
function borrarReceta(recipeId) {
}
</script>
</section>
</main><!-- End #main -->
\ No newline at end of file
h2 class="alert alert-danger">Access denied</h2>
<p>You are not authorized to access this page.</p>
\ No newline at end of file
......@@ -10,9 +10,7 @@
"ext-json": "*",
"ext-mbstring": "*",
"laminas/laminas-escaper": "^2.9",
"psr/log": "^1.1"
},
"require-dev": {
"psr/log": "^1.1",
"kint-php/kint": "^5.0.1",
"codeigniter/coding-standard": "^1.5",
"fakerphp/faker": "^1.9",
......
# Ignorar la carpeta writable/debugbar
/writable/debugbar/
\ No newline at end of file
extension=memcached.so
error_reporting = E_ALL
display_errors = On
\ No newline at end of file
/* Estilos generales */
body {
font-family: Arial, sans-serif;
background-color: #f2f2f2;
}
.container {
max-width: 800px;
margin: 0 auto;
padding: 20px;
}
.my-form label {
font-weight: bold;
color: #000000;
}
.my-form input[type="text"],
.my-form input[type="search"],
.my-form textarea {
background-color: #f5f5f5;
border-radius: 5px;
border-color: #000000;
padding: 10px;
margin-bottom: 10px;
box-shadow: none;
color: #333;
}
.my-form input[type="text"]:focus,
.my-form input[type="search"]:focus,
.my-form textarea:focus {
outline: none;
box-shadow: none;
background-color: #f2f2f2;
}
.my-form input[type="checkbox"],
.my-form input[type="radio"] {
margin-right: 5px;
}
.my-form .form-check-label {
color: #7d7d7d;
}
.my-form select {
background-color: #f5f5f5;
border-radius: 5px;
padding: 10px;
margin-bottom: 10px;
box-shadow: none;
color: #333;
}
.my-form select:focus {
outline: none;
box-shadow: none;
background-color: #f2f2f2;
}
.my-form input[type="file"] {
margin-bottom: 10px;
}
.my-form .btn-primary {
background-color: #8cb6e8;
border: none;
border-radius: 5px;
padding: 10px 20px;
font-size: 16px;
font-weight: bold;
color: #fff;
}
.my-form .btn-primary:hover {
background-color: #76a9d4;
color: #fff;
}
/* Media queries */
@media (max-width: 576px) {
.container {
padding: 10px;
}
.my-form input[type="text"],
.my-form input[type="search"],
.my-form textarea,
.my-form select {
font-size: 14px;
padding: 8px;
}
.my-form .btn-primary {
font-size: 14px;
padding: 8px 16px;
}
}
/* Estilos para el bot贸n "x" en el campo de selecci贸n de ingredientes */
.selected-ingredient button {
background-color: #f8d7da;
border: none;
border-radius: 50%;
color: #721c24;
cursor: pointer;
font-size: 0.8rem;
height: 1.5rem;
line-height: 0.8rem;
margin-left: 0.5rem;
padding: 0;
transition: background-color 0.3s ease;
width: 1.5rem;
}
.selected-ingredient button:hover {
background-color: #721c24;
color: #fff;
}
/* Agregar estilos para la lista desplegable de ingredientes */
.ingredients-list {
margin-top: 5px;
max-height: 200px;
overflow-y: auto;
}
.ingredient-item {
cursor: pointer;
transition: background-color 0.2s ease;
}
.ingredient-item:hover {
background-color: #e2e2e2;
}
.ingredient-icon {
width: 24px;
height: 24px;
}
/* Estilos para el contenedor de ingredientes seleccionados */
.selected-ingredients-container {
display: flex;
flex-wrap: wrap;
gap: 5px;
padding: 5px;
border: 1px solid #ced4da;
border-radius: 0.25rem;
min-height: 38px;
align-items: center;
}
.selected-ingredient {
display: flex;
align-items: center;
background-color: #f5f5f5;
border-radius: 4px;
padding: 4px 8px;
font-size: 0.875rem;
color: #333;
margin: 0 5px 5px 0;
}
/* Estilos para el bot贸n "x" en el campo de selecci贸n de ingredientes */
.selected-ingredient button {
background-color: #f8d7da;
border-radius: 50%;
color: #721c24;
cursor: pointer;
font-size: 0.8rem;
height: 1.5rem;
line-height: 0.8rem;
margin-left: 0.5rem;
padding: 0;
transition: background-color 0.3s ease;
width: 1.5rem;
}
.selected-ingredient button:hover {
background-color: #721c24;
color: #fff;
}
.image-upload-container {
position: relative;
width: 100%;
max-width: 400px;
border: 2px dashed #ccc;
padding: 20px;
text-align: center;
cursor: pointer;
margin-bottom: 20px;
}
.image-upload-label {
font-size: 18px;
color: #999;
}
#image-preview {
width: 100%;
max-width: 400px;
height: auto;
margin-top: 10px;
}
.form-content {
display: flex;
justify-content: space-between;
align-items: center;
flex-wrap: wrap;
}
.name-input {
border: none;
border-bottom: 1px solid #ccc;
background-color: transparent;
font-size: 2rem;
font-weight: bold;
text-align: center;
padding: 5px 0;
outline: none;
width: 100%;
max-width: 400px;
}
.name-input:focus {
border-bottom-color: #000;
}
.name-group {
flex: 1;
margin-right: 20px;
}
.photo-group {
flex: 1;
margin-left: 20px;
}
.form-row {
display: flex;
flex-wrap: nowrap;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
}
.left,
.right {
width: 49%;
}
.three-fields {
display: flex;
justify-content: space-between;
align-items: center;
}
.three-fields .form-group {
width: 32%;
}
.form-group {
margin-bottom: 20px;
}
.form-row {
display: flex;
justify-content: space-between;
align-items: center;
flex-wrap: wrap;
margin-bottom: 20px;
}
.form-row > .form-group {
flex: 1;
padding: 0 15px;
}
.form-row > .form-group:first-child {
padding-left: 0;
}
.form-row > .form-group:last-child {
padding-right: 0;
}
.label-centered {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
/* Estilos para el chip vegano */
.vegan-chip {
display: inline-flex;
align-items: center;
padding: 4px 12px;
font-size: 14px;
font-weight: 600;
background-color: #f0f0f0;
border-radius: 24px;
cursor: pointer;
user-select: none;
}
.vegan-chip.selected {
background-color: #4caf50;
color: #ffffff;
}
\ No newline at end of file
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment