Преглед изворни кода

Funciones helpers mas usadas, setup rutas y gitignore

Christian пре 3 година
родитељ
комит
61a2c80030

+ 1 - 0
.gitignore Прегледај датотеку

@@ -29,3 +29,4 @@ user_guide_src/cilexer/pycilexer.egg-info/*
29 29
 *.sublime-project
30 30
 /tests/tests/
31 31
 /tests/results/
32
+DOWNLOADS/

+ 25 - 0
.vscode/launch.json Прегледај датотеку

@@ -0,0 +1,25 @@
1
+{
2
+  "version": "0.2.0",
3
+  "configurations": [
4
+    {
5
+      "name": "Listen for XDebug",
6
+      "type": "php",
7
+      "request": "launch",
8
+      "port": 9003,
9
+      "xdebugSettings": {
10
+        "max_children": 999,
11
+      },
12
+      "pathMappings": {
13
+        "/shared/httpd/rielchyc/htdocs": "${workspaceFolder}/htdocs"
14
+      }
15
+    },
16
+    {
17
+      "name": "Launch currently open script",
18
+      "type": "php",
19
+      "request": "launch",
20
+      "program": "${file}",
21
+      "cwd": "${fileDirname}",
22
+      "port": 9003
23
+    }
24
+  ]
25
+}

+ 52 - 28
application/config/constants.php Прегледај датотеку

@@ -1,5 +1,5 @@
1 1
 <?php
2
-defined('BASEPATH') OR exit('No direct script access allowed');
2
+defined('BASEPATH') or exit('No direct script access allowed');
3 3
 
4 4
 /*
5 5
 |--------------------------------------------------------------------------
@@ -10,8 +10,8 @@ defined('BASEPATH') OR exit('No direct script access allowed');
10 10
 | error_reporting is disabled, the backtrace will not display, regardless
11 11
 | of this setting
12 12
 |
13
-*/
14
-defined('SHOW_DEBUG_BACKTRACE') OR define('SHOW_DEBUG_BACKTRACE', TRUE);
13
+ */
14
+defined('SHOW_DEBUG_BACKTRACE') or define('SHOW_DEBUG_BACKTRACE', true);
15 15
 
16 16
 /*
17 17
 |--------------------------------------------------------------------------
@@ -25,11 +25,11 @@ defined('SHOW_DEBUG_BACKTRACE') OR define('SHOW_DEBUG_BACKTRACE', TRUE);
25 25
 | user, PHP under CGI with Apache suEXEC, etc.).  Octal values should
26 26
 | always be used to set the mode correctly.
27 27
 |
28
-*/
29
-defined('FILE_READ_MODE')  OR define('FILE_READ_MODE', 0644);
30
-defined('FILE_WRITE_MODE') OR define('FILE_WRITE_MODE', 0666);
31
-defined('DIR_READ_MODE')   OR define('DIR_READ_MODE', 0755);
32
-defined('DIR_WRITE_MODE')  OR define('DIR_WRITE_MODE', 0755);
28
+ */
29
+defined('FILE_READ_MODE') or define('FILE_READ_MODE', 0644);
30
+defined('FILE_WRITE_MODE') or define('FILE_WRITE_MODE', 0666);
31
+defined('DIR_READ_MODE') or define('DIR_READ_MODE', 0755);
32
+defined('DIR_WRITE_MODE') or define('DIR_WRITE_MODE', 0755);
33 33
 
34 34
 /*
35 35
 |--------------------------------------------------------------------------
@@ -38,15 +38,15 @@ defined('DIR_WRITE_MODE')  OR define('DIR_WRITE_MODE', 0755);
38 38
 |
39 39
 | These modes are used when working with fopen()/popen()
40 40
 |
41
-*/
42
-defined('FOPEN_READ')                           OR define('FOPEN_READ', 'rb');
43
-defined('FOPEN_READ_WRITE')                     OR define('FOPEN_READ_WRITE', 'r+b');
44
-defined('FOPEN_WRITE_CREATE_DESTRUCTIVE')       OR define('FOPEN_WRITE_CREATE_DESTRUCTIVE', 'wb'); // truncates existing file data, use with care
45
-defined('FOPEN_READ_WRITE_CREATE_DESTRUCTIVE')  OR define('FOPEN_READ_WRITE_CREATE_DESTRUCTIVE', 'w+b'); // truncates existing file data, use with care
46
-defined('FOPEN_WRITE_CREATE')                   OR define('FOPEN_WRITE_CREATE', 'ab');
47
-defined('FOPEN_READ_WRITE_CREATE')              OR define('FOPEN_READ_WRITE_CREATE', 'a+b');
48
-defined('FOPEN_WRITE_CREATE_STRICT')            OR define('FOPEN_WRITE_CREATE_STRICT', 'xb');
49
-defined('FOPEN_READ_WRITE_CREATE_STRICT')       OR define('FOPEN_READ_WRITE_CREATE_STRICT', 'x+b');
41
+ */
42
+defined('FOPEN_READ') or define('FOPEN_READ', 'rb');
43
+defined('FOPEN_READ_WRITE') or define('FOPEN_READ_WRITE', 'r+b');
44
+defined('FOPEN_WRITE_CREATE_DESTRUCTIVE') or define('FOPEN_WRITE_CREATE_DESTRUCTIVE', 'wb'); // truncates existing file data, use with care
45
+defined('FOPEN_READ_WRITE_CREATE_DESTRUCTIVE') or define('FOPEN_READ_WRITE_CREATE_DESTRUCTIVE', 'w+b'); // truncates existing file data, use with care
46
+defined('FOPEN_WRITE_CREATE') or define('FOPEN_WRITE_CREATE', 'ab');
47
+defined('FOPEN_READ_WRITE_CREATE') or define('FOPEN_READ_WRITE_CREATE', 'a+b');
48
+defined('FOPEN_WRITE_CREATE_STRICT') or define('FOPEN_WRITE_CREATE_STRICT', 'xb');
49
+defined('FOPEN_READ_WRITE_CREATE_STRICT') or define('FOPEN_READ_WRITE_CREATE_STRICT', 'x+b');
50 50
 
51 51
 /*
52 52
 |--------------------------------------------------------------------------
@@ -72,14 +72,38 @@ defined('FOPEN_READ_WRITE_CREATE_STRICT')       OR define('FOPEN_READ_WRITE_CREA
72 72
 |    Bash scripting:
73 73
 |       http://tldp.org/LDP/abs/html/exitcodes.html
74 74
 |
75
-*/
76
-defined('EXIT_SUCCESS')        OR define('EXIT_SUCCESS', 0); // no errors
77
-defined('EXIT_ERROR')          OR define('EXIT_ERROR', 1); // generic error
78
-defined('EXIT_CONFIG')         OR define('EXIT_CONFIG', 3); // configuration error
79
-defined('EXIT_UNKNOWN_FILE')   OR define('EXIT_UNKNOWN_FILE', 4); // file not found
80
-defined('EXIT_UNKNOWN_CLASS')  OR define('EXIT_UNKNOWN_CLASS', 5); // unknown class
81
-defined('EXIT_UNKNOWN_METHOD') OR define('EXIT_UNKNOWN_METHOD', 6); // unknown class member
82
-defined('EXIT_USER_INPUT')     OR define('EXIT_USER_INPUT', 7); // invalid user input
83
-defined('EXIT_DATABASE')       OR define('EXIT_DATABASE', 8); // database error
84
-defined('EXIT__AUTO_MIN')      OR define('EXIT__AUTO_MIN', 9); // lowest automatically-assigned error code
85
-defined('EXIT__AUTO_MAX')      OR define('EXIT__AUTO_MAX', 125); // highest automatically-assigned error code
75
+ */
76
+defined('EXIT_SUCCESS') or define('EXIT_SUCCESS', 0); // no errors
77
+defined('EXIT_ERROR') or define('EXIT_ERROR', 1); // generic error
78
+defined('EXIT_CONFIG') or define('EXIT_CONFIG', 3); // configuration error
79
+defined('EXIT_UNKNOWN_FILE') or define('EXIT_UNKNOWN_FILE', 4); // file not found
80
+defined('EXIT_UNKNOWN_CLASS') or define('EXIT_UNKNOWN_CLASS', 5); // unknown class
81
+defined('EXIT_UNKNOWN_METHOD') or define('EXIT_UNKNOWN_METHOD', 6); // unknown class member
82
+defined('EXIT_USER_INPUT') or define('EXIT_USER_INPUT', 7); // invalid user input
83
+defined('EXIT_DATABASE') or define('EXIT_DATABASE', 8); // database error
84
+defined('EXIT__AUTO_MIN') or define('EXIT__AUTO_MIN', 9); // lowest automatically-assigned error code
85
+defined('EXIT__AUTO_MAX') or define('EXIT__AUTO_MAX', 125); // highest automatically-assigned error code
86
+
87
+defined('MAIN_LICI_URL') or define('MAIN_LICI_URL', 'https://www.hacienda.gob.es/es-ES/GobiernoAbierto/Datos%20Abiertos/Paginas/licitaciones_plataforma_contratacion.aspx');
88
+
89
+//Contiene la información relativa a las licitaciones publicadas por los órganos de contratación que tienen su perfil del contratante en la Plataforma de Contratación del Sector Público.
90
+//El conjunto de entidades que tienen su perfil del contratante en esta Plataforma ha ido creciendo progresivamente
91
+//por lo que el periodo que cubre estos datos no es homogéneo para todas ellas.
92
+//Diariamente se publican las actualizaciones producidas durante el día anterior, por lo que una misma licitación puede aparecer tantas veces como modificaciones se hayan producido en los datos de dicha licitación.
93
+defined('URL_DIARIA') or define('URL_DIARIA', "https://contrataciondelsectorpublico.gob.es/sindicacion/sindicacion_643/licitacionesPerfilesContratanteCompleto3.atom");
94
+defined('URL_COMPLETO_FECHA') or define('URL_COMPLETO_FECHA', "http://contrataciondelsectorpublico.gob.es/sindicacion/sindicacion_643/licitacionesPerfilesContratanteCompleto3_");
95
+//Contiene la información relativa a las licitaciones publicadas mediante mecanismos de agregación por entidades del Sector Público
96
+//que no tienen su perfil del contratante dado de alta en la Plataforma de Contratación del Sector Público.
97
+//Las entidades que publican mediante mecanismos de agregación ha ido variando a lo largo del tiempo,
98
+// por lo que la información corresponderá al periodo en el que han utilizado este modo de publicación.
99
+defined('URL_DIARIA_AGREGACION_EXCLU_CONTRATOS_MENORES') or define('URL_DIARIA_AGREGACION_EXCLU_CONTRATOS_MENORES', 'https://contrataciondelsectorpublico.gob.es/sindicacion/sindicacion_1044/PlataformasAgregadasSinMenores.atom');
100
+defined('URL_DIARIA_AGREGACION_EXCLU_CONTRATOS_MENORES_FECHA') or define('URL_DIARIA_AGREGACION_EXCLU_CONTRATOS_MENORES_FECHA', "http://contrataciondelsectorpublico.gob.es/sindicacion/sindicacion_1044/PlataformasAgregadasSinMenores_");
101
+
102
+//Contiene la información relativa a los contratos menores publicados por los órganos de contratación que tienen su perfil de contratante en la Plataforma de Contratación del Sector Público.
103
+//Diariamente se publican las actualizaciones producidas durante el día anterior.
104
+defined('URL_DIARIA_CONTRATOS_MENORES_PERFILES_CONTRATANES') or define('URL_DIARIA_CONTRATOS_MENORES_PERFILES_CONTRATANES', 'https://contrataciondelsectorpublico.gob.es/sindicacion/sindicacion_1143/contratosMenoresPerfilesContratantes.atom');
105
+defined('URL_DIARIA_CONTRATOS_MENORES_PERFILES_CONTRATANES_FECHA') or define('URL_DIARIA_CONTRATOS_MENORES_PERFILES_CONTRATANES_FECHA', 'http://contrataciondelsectorpublico.gob.es/sindicacion/sindicacion_1143/contratosMenoresPerfilesContratantes_');
106
+
107
+//Este conjunto de datos contiene una relación de los órganos de contratación que se alojan en la Plataforma de Contratación del Sector Público, tanto activos como inactivos.
108
+//Por cada órgano de contratación, se proporcionan los datos más relevantes.
109
+defined('PERFILES_CONTRATANTES') or define('PERFILES_CONTRATANTES', 'https://contrataciondelsectorpublico.gob.es/datosabiertos/OrganosContratacion.xlsx');

+ 139 - 68
application/config/database.php Прегледај датотеку

@@ -1,5 +1,5 @@
1 1
 <?php
2
-defined('BASEPATH') OR exit('No direct script access allowed');
2
+defined('BASEPATH') or exit('No direct script access allowed');
3 3
 
4 4
 /*
5 5
 | -------------------------------------------------------------------
@@ -14,83 +14,154 @@ defined('BASEPATH') OR exit('No direct script access allowed');
14 14
 | EXPLANATION OF VARIABLES
15 15
 | -------------------------------------------------------------------
16 16
 |
17
-|	['dsn']      The full DSN string describe a connection to the database.
18
-|	['hostname'] The hostname of your database server.
19
-|	['username'] The username used to connect to the database
20
-|	['password'] The password used to connect to the database
21
-|	['database'] The name of the database you want to connect to
22
-|	['dbdriver'] The database driver. e.g.: mysqli.
23
-|			Currently supported:
24
-|				 cubrid, ibase, mssql, mysql, mysqli, oci8,
25
-|				 odbc, pdo, postgre, sqlite, sqlite3, sqlsrv
26
-|	['dbprefix'] You can add an optional prefix, which will be added
27
-|				 to the table name when using the  Query Builder class
28
-|	['pconnect'] TRUE/FALSE - Whether to use a persistent connection
29
-|	['db_debug'] TRUE/FALSE - Whether database errors should be displayed.
30
-|	['cache_on'] TRUE/FALSE - Enables/disables query caching
31
-|	['cachedir'] The path to the folder where cache files should be stored
32
-|	['char_set'] The character set used in communicating with the database
33
-|	['dbcollat'] The character collation used in communicating with the database
34
-|				 NOTE: For MySQL and MySQLi databases, this setting is only used
35
-| 				 as a backup if your server is running PHP < 5.2.3 or MySQL < 5.0.7
36
-|				 (and in table creation queries made with DB Forge).
37
-| 				 There is an incompatibility in PHP with mysql_real_escape_string() which
38
-| 				 can make your site vulnerable to SQL injection if you are using a
39
-| 				 multi-byte character set and are running versions lower than these.
40
-| 				 Sites using Latin-1 or UTF-8 database character set and collation are unaffected.
41
-|	['swap_pre'] A default table prefix that should be swapped with the dbprefix
42
-|	['encrypt']  Whether or not to use an encrypted connection.
17
+|    ['dsn']      The full DSN string describe a connection to the database.
18
+|    ['hostname'] The hostname of your database server.
19
+|    ['username'] The username used to connect to the database
20
+|    ['password'] The password used to connect to the database
21
+|    ['database'] The name of the database you want to connect to
22
+|    ['dbdriver'] The database driver. e.g.: mysqli.
23
+|            Currently supported:
24
+|                 cubrid, ibase, mssql, mysql, mysqli, oci8,
25
+|                 odbc, pdo, postgre, sqlite, sqlite3, sqlsrv
26
+|    ['dbprefix'] You can add an optional prefix, which will be added
27
+|                 to the table name when using the  Query Builder class
28
+|    ['pconnect'] TRUE/FALSE - Whether to use a persistent connection
29
+|    ['db_debug'] TRUE/FALSE - Whether database errors should be displayed.
30
+|    ['cache_on'] TRUE/FALSE - Enables/disables query caching
31
+|    ['cachedir'] The path to the folder where cache files should be stored
32
+|    ['char_set'] The character set used in communicating with the database
33
+|    ['dbcollat'] The character collation used in communicating with the database
34
+|                 NOTE: For MySQL and MySQLi databases, this setting is only used
35
+|                  as a backup if your server is running PHP < 5.2.3 or MySQL < 5.0.7
36
+|                 (and in table creation queries made with DB Forge).
37
+|                  There is an incompatibility in PHP with mysql_real_escape_string() which
38
+|                  can make your site vulnerable to SQL injection if you are using a
39
+|                  multi-byte character set and are running versions lower than these.
40
+|                  Sites using Latin-1 or UTF-8 database character set and collation are unaffected.
41
+|    ['swap_pre'] A default table prefix that should be swapped with the dbprefix
42
+|    ['encrypt']  Whether or not to use an encrypted connection.
43 43
 |
44
-|			'mysql' (deprecated), 'sqlsrv' and 'pdo/sqlsrv' drivers accept TRUE/FALSE
45
-|			'mysqli' and 'pdo/mysql' drivers accept an array with the following options:
44
+|            'mysql' (deprecated), 'sqlsrv' and 'pdo/sqlsrv' drivers accept TRUE/FALSE
45
+|            'mysqli' and 'pdo/mysql' drivers accept an array with the following options:
46 46
 |
47
-|				'ssl_key'    - Path to the private key file
48
-|				'ssl_cert'   - Path to the public key certificate file
49
-|				'ssl_ca'     - Path to the certificate authority file
50
-|				'ssl_capath' - Path to a directory containing trusted CA certificates in PEM format
51
-|				'ssl_cipher' - List of *allowed* ciphers to be used for the encryption, separated by colons (':')
52
-|				'ssl_verify' - TRUE/FALSE; Whether verify the server certificate or not
47
+|                'ssl_key'    - Path to the private key file
48
+|                'ssl_cert'   - Path to the public key certificate file
49
+|                'ssl_ca'     - Path to the certificate authority file
50
+|                'ssl_capath' - Path to a directory containing trusted CA certificates in PEM format
51
+|                'ssl_cipher' - List of *allowed* ciphers to be used for the encryption, separated by colons (':')
52
+|                'ssl_verify' - TRUE/FALSE; Whether verify the server certificate or not
53 53
 |
54
-|	['compress'] Whether or not to use client compression (MySQL only)
55
-|	['stricton'] TRUE/FALSE - forces 'Strict Mode' connections
56
-|							- good for ensuring strict SQL while developing
57
-|	['ssl_options']	Used to set various SSL options that can be used when making SSL connections.
58
-|	['failover'] array - A array with 0 or more data for connections if the main should fail.
59
-|	['save_queries'] TRUE/FALSE - Whether to "save" all executed queries.
60
-| 				NOTE: Disabling this will also effectively disable both
61
-| 				$this->db->last_query() and profiling of DB queries.
62
-| 				When you run a query, with this setting set to TRUE (default),
63
-| 				CodeIgniter will store the SQL statement for debugging purposes.
64
-| 				However, this may cause high memory usage, especially if you run
65
-| 				a lot of SQL queries ... disable this to avoid that problem.
54
+|    ['compress'] Whether or not to use client compression (MySQL only)
55
+|    ['stricton'] TRUE/FALSE - forces 'Strict Mode' connections
56
+|                            - good for ensuring strict SQL while developing
57
+|    ['ssl_options']    Used to set various SSL options that can be used when making SSL connections.
58
+|    ['failover'] array - A array with 0 or more data for connections if the main should fail.
59
+|    ['save_queries'] TRUE/FALSE - Whether to "save" all executed queries.
60
+|                 NOTE: Disabling this will also effectively disable both
61
+|                 $this->db->last_query() and profiling of DB queries.
62
+|                 When you run a query, with this setting set to TRUE (default),
63
+|                 CodeIgniter will store the SQL statement for debugging purposes.
64
+|                 However, this may cause high memory usage, especially if you run
65
+|                 a lot of SQL queries ... disable this to avoid that problem.
66 66
 |
67 67
 | The $active_group variable lets you choose which connection group to
68 68
 | make active.  By default there is only one group (the 'default' group).
69 69
 |
70 70
 | The $query_builder variables lets you determine whether or not to load
71 71
 | the query builder class.
72
-*/
72
+ */
73 73
 $active_group = 'default';
74
-$query_builder = TRUE;
74
+$query_builder = true;
75 75
 
76 76
 $db['default'] = array(
77
-	'dsn'	=> '',
78
-	'hostname' => 'localhost',
79
-	'username' => '',
80
-	'password' => '',
81
-	'database' => '',
82
-	'dbdriver' => 'mysqli',
83
-	'dbprefix' => '',
84
-	'pconnect' => FALSE,
85
-	'db_debug' => (ENVIRONMENT !== 'production'),
86
-	'cache_on' => FALSE,
87
-	'cachedir' => '',
88
-	'char_set' => 'utf8',
89
-	'dbcollat' => 'utf8_general_ci',
90
-	'swap_pre' => '',
91
-	'encrypt' => FALSE,
92
-	'compress' => FALSE,
93
-	'stricton' => FALSE,
94
-	'failover' => array(),
95
-	'save_queries' => TRUE
77
+    'dsn' => '',
78
+    'hostname' => 'office.mindden.com',
79
+    //'hostname' => "localhost",
80
+    'port' => '33306',
81
+    //'port' => '3306',
82
+    'username' => 'root',
83
+    'password' => 'mindden2017',
84
+    //'password' => '',
85
+    'database' => 'liciagbar',
86
+    'dbdriver' => 'mysqli',
87
+    'dbprefix' => '',
88
+    'pconnect' => false,
89
+    'db_debug' => (ENVIRONMENT !== 'production'),
90
+    'cache_on' => false,
91
+    'cachedir' => '',
92
+    'char_set' => 'utf8',
93
+    'dbcollat' => 'utf8_general_ci',
94
+    'swap_pre' => '',
95
+    'encrypt' => false,
96
+    'compress' => false,
97
+    'stricton' => false,
98
+    'failover' => array(),
99
+    'save_queries' => true,
96 100
 );
101
+
102
+/*
103
+if (isset($_SERVER["SERVER_NAME"])) {
104
+switch ($_SERVER["SERVER_NAME"]) {
105
+
106
+//DESARROLLO
107
+case "rielchyc":
108
+$db['default'] = array(
109
+'dsn'    => '',
110
+'hostname' => '217.125.90.43',
111
+//'hostname' => "localhost",
112
+'port' => '33306',
113
+//'port' => '3306',
114
+'username' => 'root',
115
+'password' => 'mindden2017',
116
+//'password' => '',
117
+'database' => 'rielchyc',
118
+'dbdriver' => 'mysqli',
119
+'dbprefix' => '',
120
+'pconnect' => FALSE,
121
+'db_debug' => (ENVIRONMENT !== 'production'),
122
+'cache_on' => FALSE,
123
+'cachedir' => '',
124
+'char_set' => 'utf8',
125
+'dbcollat' => 'utf8_general_ci',
126
+'swap_pre' => '',
127
+'encrypt' => FALSE,
128
+'compress' => FALSE,
129
+'stricton' => FALSE,
130
+'failover' => array(),
131
+'save_queries' => TRUE
132
+);
133
+break;
134
+
135
+//DESARROLLO STP
136
+case "mediosdev.stpnettraining.com":
137
+$db['default'] = array(
138
+'dsn'    => '',
139
+'hostname' => 'localhost',
140
+'port' => '3306',
141
+'username' => 'root_medios',
142
+'password' => 'uRp60x!9',
143
+'database' => 'admin_mediosdev',
144
+'dbdriver' => 'mysqli',
145
+'dbprefix' => '',
146
+'pconnect' => FALSE,
147
+'db_debug' => (ENVIRONMENT !== 'production'),
148
+'cache_on' => FALSE,
149
+'cachedir' => '',
150
+'char_set' => 'utf8',
151
+'dbcollat' => 'utf8_general_ci',
152
+'swap_pre' => '',
153
+'encrypt' => FALSE,
154
+'compress' => FALSE,
155
+'stricton' => FALSE,
156
+'failover' => array(),
157
+'save_queries' => TRUE
158
+);
159
+break;
160
+
161
+}
162
+}
163
+else {
164
+
165
+//CRONS
166
+$db['default']['database'] = 'rielchyc';
167
+}*/

+ 11 - 11
application/config/routes.php Прегледај датотеку

@@ -1,5 +1,5 @@
1 1
 <?php
2
-defined('BASEPATH') OR exit('No direct script access allowed');
2
+defined('BASEPATH') or exit('No direct script access allowed');
3 3
 
4 4
 /*
5 5
 | -------------------------------------------------------------------------
@@ -11,7 +11,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
11 11
 | and its corresponding controller class/method. The segments in a
12 12
 | URL normally follow this pattern:
13 13
 |
14
-|	example.com/class/method/id/
14
+|    example.com/class/method/id/
15 15
 |
16 16
 | In some instances, however, you may want to remap this relationship
17 17
 | so that a different class/function is called than the one
@@ -19,7 +19,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
19 19
 |
20 20
 | Please see the user guide for complete details:
21 21
 |
22
-|	https://codeigniter.com/user_guide/general/routing.html
22
+|    https://codeigniter.com/user_guide/general/routing.html
23 23
 |
24 24
 | -------------------------------------------------------------------------
25 25
 | RESERVED ROUTES
@@ -27,18 +27,18 @@ defined('BASEPATH') OR exit('No direct script access allowed');
27 27
 |
28 28
 | There are three reserved routes:
29 29
 |
30
-|	$route['default_controller'] = 'welcome';
30
+|    $route['default_controller'] = 'welcome';
31 31
 |
32 32
 | This route indicates which controller class should be loaded if the
33 33
 | URI contains no data. In the above example, the "welcome" class
34 34
 | would be loaded.
35 35
 |
36
-|	$route['404_override'] = 'errors/page_missing';
36
+|    $route['404_override'] = 'errors/page_missing';
37 37
 |
38 38
 | This route will tell the Router which controller/method to use if those
39 39
 | provided in the URL cannot be matched to a valid route.
40 40
 |
41
-|	$route['translate_uri_dashes'] = FALSE;
41
+|    $route['translate_uri_dashes'] = FALSE;
42 42
 |
43 43
 | This is not exactly a route, but allows you to automatically route
44 44
 | controller and method names that contain dashes. '-' isn't a valid
@@ -46,9 +46,9 @@ defined('BASEPATH') OR exit('No direct script access allowed');
46 46
 | When you set this option to TRUE, it will replace ALL dashes in the
47 47
 | controller and method URI segments.
48 48
 |
49
-| Examples:	my-controller/index	-> my_controller/index
50
-|		my-controller/my-method	-> my_controller/my_method
51
-*/
52
-$route['default_controller'] = 'welcome';
49
+| Examples:    my-controller/index    -> my_controller/index
50
+|        my-controller/my-method    -> my_controller/my_method
51
+ */
52
+$route['default_controller'] = 'FileDownload';
53 53
 $route['404_override'] = '';
54
-$route['translate_uri_dashes'] = FALSE;
54
+$route['translate_uri_dashes'] = false;

+ 89 - 0
application/core/MY_DB_mysqli_driver.php Прегледај датотеку

@@ -0,0 +1,89 @@
1
+<?php
2
+class MY_DB_mysqli_driver extends CI_DB_mysqli_driver {
3
+
4
+   final public function __construct($params)
5
+{
6
+  parent::__construct($params);
7
+}
8
+
9
+  /**
10
+   * Insert_On_Duplicate_Update_Batch
11
+   *
12
+   * Compiles batch insert strings and runs the queries
13
+   * MODIFIED to do a MySQL 'ON DUPLICATE KEY UPDATE'
14
+   *
15
+   * @access public
16
+   * @param string the table to retrieve the results from
17
+   * @param array an associative array of insert values
18
+   * @return object
19
+   */
20
+  function insert_on_duplicate_update_batch($table = '', $set = NULL)
21
+  {
22
+    if ( ! is_null($set))
23
+    {
24
+     $this->set_insert_batch($set);
25
+    }
26
+
27
+    if (count($this->qb_set) == 0)
28
+    {
29
+     if ($this->db_debug)
30
+     {
31
+      //No valid data array.  Folds in cases where keys and values did not match up
32
+      return $this->display_error('db_must_use_set');
33
+     }
34
+     return FALSE;
35
+    }
36
+
37
+    if ($table == '')
38
+    {
39
+     if ( ! isset($this->qb_from[0]))
40
+     {
41
+      if ($this->db_debug)
42
+      {
43
+       return $this->display_error('db_must_set_table');
44
+      }
45
+      return FALSE;
46
+     }
47
+
48
+     $table = $this->qb_from[0];
49
+    }
50
+
51
+    // Batch this baby
52
+    for ($i = 0, $total = count($this->qb_set); $i < $total; $i = $i + 5000)
53
+    {
54
+
55
+     $sql = $this->_insert_on_duplicate_update_batch($this->protect_identifiers($table, TRUE, NULL, FALSE), $this->qb_keys, array_slice($this->qb_set, $i, 5000));
56
+
57
+     // echo $sql;
58
+
59
+     $this->query($sql);
60
+    }
61
+
62
+    $this->_reset_write();
63
+
64
+
65
+    return TRUE;
66
+  }
67
+
68
+  /**
69
+   * Insert_on_duplicate_update_batch statement
70
+   *
71
+   * Generates a platform-specific insert string from the supplied data
72
+   * MODIFIED to include ON DUPLICATE UPDATE
73
+   *
74
+   * @access public
75
+   * @param string the table name
76
+   * @param array the insert keys
77
+   * @param array the insert values
78
+   * @return string
79
+   */
80
+  private function _insert_on_duplicate_update_batch($table, $keys, $values)
81
+  {
82
+    foreach($keys as $key)
83
+     $update_fields[] = $key.'=VALUES('.$key.')';
84
+
85
+    return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES ".implode(', ', $values)." ON DUPLICATE KEY UPDATE ".implode(', ', $update_fields);
86
+  }
87
+
88
+}
89
+?>

+ 44 - 0
application/core/MY_Loader.php Прегледај датотеку

@@ -0,0 +1,44 @@
1
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2
+
3
+class MY_Loader extends CI_Loader {
4
+
5
+public function database($params = '', $return = FALSE, $active_record = NULL)
6
+{
7
+  // Grab the super object
8
+  $CI =& get_instance();
9
+
10
+  // Do we even need to load the database class?
11
+  if (class_exists('CI_DB') AND $return == FALSE AND $active_record == NULL AND isset($CI->db) AND is_object($CI->db))
12
+  {
13
+   return FALSE;
14
+  }
15
+
16
+  require_once(BASEPATH.'database/DB.php');
17
+
18
+  $db = DB($params, $active_record);
19
+
20
+  // Load extended DB driver
21
+  $custom_db_driver = config_item('subclass_prefix').'DB_'.$db->dbdriver.'_driver';
22
+  $custom_db_driver_file = APPPATH.'core/'.$custom_db_driver.'.php';
23
+
24
+  if (file_exists($custom_db_driver_file))
25
+  {
26
+   require_once($custom_db_driver_file);
27
+
28
+   $db = new $custom_db_driver(get_object_vars($db));
29
+  }
30
+
31
+  // Return DB instance
32
+  if ($return === TRUE)
33
+  {
34
+   return $db;
35
+  }
36
+
37
+  // Initialize the db variable. Needed to prevent reference errors with some configurations
38
+  $CI->db = '';
39
+  $CI->db =& $db;
40
+}
41
+}
42
+
43
+/* End of file MY_Loader.php */
44
+/* Location: ./application/core/MY_Loader.php */

+ 9 - 0
application/core/README.md Прегледај датотеку

@@ -0,0 +1,9 @@
1
+# CodeIgniter-Insert-Batch-on-DUPLICATE-KEY-Update
2
+This class helps you to extend the codeigniter mysqli driver to be able to support update on duplicate while inserting batch feature. This allows you to be able to supply an array of key value pairs to be inserted into separate rows.
3
+
4
+1. Copy Both My_Loader.php and MY_DB_mysqli_driver.php to "application/core" folder.
5
+2. Use $this->db->insert_on_duplicate_update_batch() inseated of $this->db->insert_batch()
6
+
7
+This will auto update data if duplicate key occurs in DB.
8
+
9
+Support By: <a href="https://www.ranglerz.com">Ranglerz</a>

+ 207 - 0
application/helpers/funciones_helper.php Прегледај датотеку

@@ -0,0 +1,207 @@
1
+<?php
2
+defined('BASEPATH') or exit('No direct script access allowed');
3
+
4
+/**
5
+ *
6
+ * Helpers Funciones_helper
7
+ *
8
+ * This Helpers for ...
9
+ *
10
+ * @package   CodeIgniter
11
+ * @category  Helpers
12
+ * @author    Setiawan Jodi <jodisetiawan@fisip-untirta.ac.id>
13
+ * @link      https://github.com/setdjod/myci-extension/
14
+ *
15
+ */
16
+
17
+// ------------------------------------------------------------------------
18
+
19
+if (!function_exists('guardar_log')) {
20
+
21
+    function guardar_log($nombre_archivo = "", $texto = "", $echo = false, $tipo = 1)
22
+    {
23
+        $textoTipoLogico = "";
24
+        if ($tipo == 1) {
25
+            $textoTipoLogico = "INFO";
26
+        } else if ($tipo == 2) {
27
+            $textoTipoLogico = "ERROR";
28
+        }
29
+
30
+        //CREAMOS EL REGISTRO PARA EL LOG
31
+        $registro = date('d-m-Y H:i:s') . ' - ' . $textoTipoLogico . " - " . $texto;
32
+
33
+        //FICHERO DE LOG
34
+        $file_name = APPPATH . 'logs/' . $nombre_archivo . '.txt';
35
+
36
+        //GUARDAMOS EL REGISTRO EN EL FICHERO DE LOG
37
+        $f = fopen($file_name, "a");
38
+        fwrite($f, $registro . PHP_EOL);
39
+        fclose($f);
40
+
41
+        //SI ES NECESARIO SE MUESTRA POR PANTALLA
42
+        if ($echo == true) {
43
+            echo $registro . '<br>';
44
+        }
45
+
46
+        return $texto . '<br>';
47
+    }
48
+}
49
+
50
+if (!function_exists("insertBucle")) {
51
+    function insertBucle($fila_archivo, $nombreTabla, $nombreLog): int
52
+    {
53
+        $contador = 1;
54
+
55
+        $conjunto = array();
56
+
57
+        $CI = &get_instance();
58
+
59
+        foreach ($fila_archivo as $row) {
60
+
61
+            $conjunto[] = $row;
62
+
63
+            $contador++;
64
+
65
+            if ($contador % 5000 == 0) {
66
+                guardar_log($nombreLog, count($conjunto));
67
+                $CI->db->insert_batch($nombreTabla, $conjunto);
68
+
69
+                $conjunto = array();
70
+            }
71
+        }
72
+
73
+        if (count($conjunto) > 0) {
74
+
75
+            $CI->db->insert_batch($nombreTabla, $conjunto);
76
+        }
77
+
78
+        return $CI->db->insert_id();
79
+    }
80
+}
81
+
82
+if (!function_exists("insertBucleDuplicateOnKey")) {
83
+    function insertBucleDuplicateOnKey($fila_archivo, $nombreTabla, $nombreLog)
84
+    {
85
+        $contador = 1;
86
+
87
+        $conjunto = array();
88
+
89
+        $CI = &get_instance();
90
+
91
+        foreach ($fila_archivo as $row) {
92
+
93
+            $conjunto[] = $row;
94
+
95
+            $contador++;
96
+
97
+            if ($contador % 5000 == 0) {
98
+                guardar_log($nombreLog, count($conjunto));
99
+                //$CI->db->insert_batch($nombreTabla, $conjunto);
100
+                $CI->db->insert_on_duplicate_update_batch($nombreTabla, $conjunto);
101
+
102
+                $conjunto = array();
103
+            }
104
+        }
105
+
106
+        if (count($conjunto) > 0) {
107
+
108
+            //$CI->db->insert_batch($nombreTabla, $conjunto);
109
+            $CI->db->insert_on_duplicate_update_batch($nombreTabla, $conjunto);
110
+        }
111
+
112
+        return $CI->db->insert_id();
113
+    }
114
+}
115
+
116
+if (!function_exists(("check_permisos_template"))) {
117
+    function check_permisos_template($view_file_name, $data_array = array(), $vista_permiso = "home")
118
+    {
119
+
120
+        $CI = &get_instance();
121
+        if ($CI->session->zonas != "") {
122
+            $CI->load->model("Home_model");
123
+            $vistas = $CI->Home_model->getPermisosVistaUsuario($CI->session->tipo_usuario);
124
+
125
+            if ($CI->session->tipo_usuario == 1) {
126
+                $CI->template_dashboard->load_template($view_file_name, $data_array);
127
+            } else {
128
+                if (in_array($vista_permiso, $vistas)) {
129
+                    $CI->template_dashboard->load_template($view_file_name, $data_array);
130
+                } else {
131
+                    redirect("home");
132
+                }
133
+            }
134
+        } else {
135
+            redirect("login", "refresh");
136
+        }
137
+    }
138
+}
139
+
140
+if (!function_exists("pretty_dump")) {
141
+    function pretty_dump($data)
142
+    {
143
+        echo '<pre>' . var_export($data, true) . '</pre>';
144
+    }
145
+}
146
+
147
+if (!function_exists("enviarEmail")) {
148
+    function enviarEmail($asunto, $body, $email_envio, $adjuntos = array(), $print_result = true)
149
+    {
150
+        print_r($body);
151
+        $CI = &get_instance();
152
+
153
+        $CI->load->library('email');
154
+
155
+        $config = array();
156
+        if ($_SERVER["SERVER_NAME"] == "rielchyc.test") {
157
+            $config['protocol'] = 'smtp';
158
+            $config['smtp_host'] = 'smtp.gmail.com';
159
+            $config['smtp_user'] = 'chcalvoleon@mindden.com';
160
+            $config['smtp_pass'] = '';
161
+            $config['smtp_crypto'] = 'ssl';
162
+            $config['smtp_port'] = 465;
163
+            $config['mailtype'] = 'html';
164
+            $config['wordwrap'] = 'TRUE';
165
+            $config['newline'] = "\r\n";
166
+            $config['priority'] = 5;
167
+            $config['crlf'] = "\r\n";
168
+        } else {
169
+            $config['protocol'] = 'smtp';
170
+            $config['smtp_host'] = 'b2b.rielchyc.es';
171
+            $config['smtp_user'] = 'webmaster@b2b.rielchyc.es';
172
+            $config['smtp_pass'] = 'Mindden2021!';
173
+            $config['smtp_crypto'] = 'ssl';
174
+            $config['smtp_port'] = 465;
175
+            $config['mailtype'] = 'html';
176
+            $config['wordwrap'] = 'TRUE';
177
+            $config['newline'] = "\r\n";
178
+            $config['priority'] = 5;
179
+            $config['crlf'] = "\r\n";
180
+        }
181
+
182
+        $CI->email->initialize($config);
183
+        $CI->email->clear(true);
184
+
185
+        $CI->email->from('webmaster@b2b.rielchyc.es');
186
+        $CI->email->to($email_envio);
187
+        $CI->email->bcc("chcalvoleon@mindden.com");
188
+        $CI->email->subject($asunto);
189
+        $CI->email->message($body);
190
+
191
+        foreach ($adjuntos as $row) {
192
+            $CI->email->attach($row);
193
+        }
194
+
195
+        if ($print_result) {
196
+            echo $CI->email->send(false);
197
+            echo $CI->email->print_debugger();
198
+        } else {
199
+            $CI->email->send(false);
200
+        }
201
+    }
202
+}
203
+
204
+// ------------------------------------------------------------------------
205
+
206
+/* End of file Funciones_helper.php */
207
+/* Location: ./application/helpers/Funciones_helper.php */