@@ -12,9 +12,9 @@ class Db {
12
12
13
13
/**
14
14
* global dir db
15
- * @var string bd_path
15
+ * @var string db_path
16
16
*/
17
- protected $ bd_path ;
17
+ protected $ db_path ;
18
18
19
19
/**
20
20
* global param db
@@ -33,9 +33,9 @@ class Db {
33
33
private $ dir_cached = 'db.cached ' ;
34
34
private $ structure = null ;
35
35
36
- public function __construct ($ bd_path )
36
+ public function __construct ($ db_path )
37
37
{
38
- $ this ->bd_path = $ bd_path ; // Директория в которой будет находится база данных
38
+ $ this ->db_path = $ db_path ; // Директория в которой будет находится база данных
39
39
}
40
40
41
41
public function run ()
@@ -44,33 +44,33 @@ public function run()
44
44
$ date = date ("Y-m-d H:i:s " );
45
45
46
46
// Устанавливаем константу - Каталог базы данных
47
- define ('JSON_DB_PATH ' , $ this ->bd_path );
47
+ define ('JSON_DB_PATH ' , $ this ->db_path );
48
48
define ('JSON_DB_KEY ' , $ this ->key );
49
49
define ('JSON_DB_CRYPT ' , $ this ->crypt );
50
50
define ('JSON_DB_TEMP ' , $ this ->temp );
51
51
define ('JSON_DB_API ' , $ this ->api );
52
- define ('JSON_DB_CACHET ' , $ this ->cached );
52
+ define ('JSON_DB_CACHED ' , $ this ->cached );
53
53
define ('JSON_DB_EXPORT ' , $ this ->export );
54
54
define ('JSON_DB_SIZE ' , $ this ->size );
55
55
define ('JSON_DB_MAX_SIZE ' , $ this ->max_size );
56
56
define ('JSON_DB_CACHE_LIFE_TIME ' , $ this ->cache_lifetime );
57
- define ('JSON_DB_bd_path ' , $ this ->bd_path );
58
- define ('JSON_DB_DIR_CORE ' , str_replace ('db. ' , $ this ->bd_path , $ this ->dir_core ));
59
- define ('JSON_DB_DIR_LOG ' , str_replace ('db. ' , $ this ->bd_path , $ this ->dir_log ));
60
- define ('JSON_DB_DIR_CACHET ' , str_replace ('db. ' , $ this ->bd_path , $ this ->dir_cached ));
57
+ define ('JSON_DB_DB_PATH ' , $ this ->db_path );
58
+ define ('JSON_DB_DIR_CORE ' , str_replace ('db. ' , $ this ->db_path , $ this ->dir_core ));
59
+ define ('JSON_DB_DIR_LOG ' , str_replace ('db. ' , $ this ->db_path , $ this ->dir_log ));
60
+ define ('JSON_DB_DIR_CACHED ' , str_replace ('db. ' , $ this ->db_path , $ this ->dir_cached ));
61
61
62
62
// Проверяем наличие каталога базы данных, если нет создаем
63
- if (!file_exists ($ this ->bd_path )){mkdir ($ this ->bd_path );}
63
+ if (!file_exists ($ this ->db_path )){mkdir ($ this ->db_path );}
64
64
65
65
// Проверяем наличие главной таблицы если нет создаем
66
66
try {
67
67
\jsonDB \Validate::table ('db ' )->exists ();
68
68
69
- // Обновляем таблицу конфигурации db из параметров (new Db($bd_path , $temp, $api, $cached))->run();
69
+ // Обновляем таблицу конфигурации db из параметров (new Db($db_path , $temp, $api, $cached))->run();
70
70
$ update = jsonDb::table ('db ' )->find (1 ); // Edit with ID 1
71
71
72
- if (isset ($ this ->bd_path )) {
73
- $ update ->bd_path = $ this ->bd_path ;
72
+ if (isset ($ this ->db_path )) {
73
+ $ update ->db_path = $ this ->db_path ;
74
74
}
75
75
if (isset ($ this ->cached )) {
76
76
$ update ->cached = $ this ->cached ;
@@ -125,7 +125,7 @@ public function run()
125
125
'export ' => 'string ' ,
126
126
'size ' => 'integer ' ,
127
127
'max_size ' => 'integer ' ,
128
- 'bd_path ' => 'string ' ,
128
+ 'db_path ' => 'string ' ,
129
129
'dir_core ' => 'string ' ,
130
130
'dir_log ' => 'string ' ,
131
131
'dir_cached ' => 'string '
@@ -181,14 +181,11 @@ public function run()
181
181
$ row ->export = $ this ->export ;
182
182
$ row ->size = $ this ->size ;
183
183
$ row ->max_size = $ this ->max_size ;
184
- $ row ->bd_path = $ this ->bd_path ;
184
+ $ row ->db_path = $ this ->db_path ;
185
185
$ row ->dir_core = $ this ->dir_core ;
186
186
$ row ->dir_log = $ this ->dir_log ;
187
187
$ row ->dir_cached = $ this ->dir_cached ;
188
188
$ row ->save ();
189
-
190
- // $row->user->name = $this->api;
191
- // Добавление записи в связанную таблицу user с автоматической привязкой id
192
189
}
193
190
194
191
// Читаем главную таблицу
@@ -197,10 +194,10 @@ public function run()
197
194
define ('JSON_DB_PASSWORD ' , $ table ->password );
198
195
199
196
// Проверяем существуют ли необходимые каталоги, если нет создаем
200
- if (!file_exists (JSON_DB_bd_path )){mkdir (JSON_DB_bd_path );}
197
+ if (!file_exists (JSON_DB_DB_PATH )){mkdir (JSON_DB_DB_PATH );}
201
198
if (!file_exists (JSON_DB_DIR_CORE )){mkdir (JSON_DB_DIR_CORE );}
202
199
if (!file_exists (JSON_DB_DIR_LOG )){mkdir (JSON_DB_DIR_LOG );}
203
- if (!file_exists (JSON_DB_DIR_CACHET )){mkdir (JSON_DB_DIR_CACHET );}
200
+ if (!file_exists (JSON_DB_DIR_CACHED )){mkdir (JSON_DB_DIR_CACHED );}
204
201
205
202
// Если файла структуры базы данных нет, скачиваем его с github
206
203
if (!file_exists (JSON_DB_DIR_CORE .'/db.json ' )){
@@ -303,7 +300,7 @@ public function run()
303
300
304
301
public static function cacheReader ($ uri ) // Читает кеш или удаляет кеш если время жизни просрочено
305
302
{
306
- if (JSON_DB_CACHET == true ) {
303
+ if (JSON_DB_CACHED = == true ) {
307
304
308
305
$ row = jsonDb::table ('cached ' )->where ('cached_uri ' , '= ' , $ uri )->find ();
309
306
@@ -355,12 +352,12 @@ public static function cacheWriter($uri, $arr) // Создает кеш
355
352
{
356
353
$ file_name = \jsonDB \Db::randomUid ();
357
354
358
- file_put_contents (JSON_DB_DIR_CACHET .'/ ' .$ file_name .'.json ' , json_encode ($ arr ));
355
+ file_put_contents (JSON_DB_DIR_CACHED .'/ ' .$ file_name .'.json ' , json_encode ($ arr ));
359
356
360
357
$ row = jsonDb::table ('cached ' );
361
358
$ row ->cached_count = 0 ;
362
359
$ row ->cached_uri = $ uri ;
363
- $ row ->cached_file = JSON_DB_DIR_CACHET .'/ ' .$ file_name .'.json ' ;
360
+ $ row ->cached_file = JSON_DB_DIR_CACHED .'/ ' .$ file_name .'.json ' ;
364
361
$ row ->cached_time = date ("Y-m-d H:i:s " );
365
362
$ row ->save ();
366
363
0 commit comments