@@ -12,9 +12,9 @@ class Db {
1212
1313 /**
1414 * global dir db
15- * @var string bd_path
15+ * @var string db_path
1616 */
17- protected $ bd_path ;
17+ protected $ db_path ;
1818
1919 /**
2020 * global param db
@@ -33,9 +33,9 @@ class Db {
3333 private $ dir_cached = 'db.cached ' ;
3434 private $ structure = null ;
3535
36- public function __construct ($ bd_path )
36+ public function __construct ($ db_path )
3737 {
38- $ this ->bd_path = $ bd_path ; // Директория в которой будет находится база данных
38+ $ this ->db_path = $ db_path ; // Директория в которой будет находится база данных
3939 }
4040
4141 public function run ()
@@ -44,33 +44,33 @@ public function run()
4444 $ date = date ("Y-m-d H:i:s " );
4545
4646 // Устанавливаем константу - Каталог базы данных
47- define ('JSON_DB_PATH ' , $ this ->bd_path );
47+ define ('JSON_DB_PATH ' , $ this ->db_path );
4848 define ('JSON_DB_KEY ' , $ this ->key );
4949 define ('JSON_DB_CRYPT ' , $ this ->crypt );
5050 define ('JSON_DB_TEMP ' , $ this ->temp );
5151 define ('JSON_DB_API ' , $ this ->api );
52- define ('JSON_DB_CACHET ' , $ this ->cached );
52+ define ('JSON_DB_CACHED ' , $ this ->cached );
5353 define ('JSON_DB_EXPORT ' , $ this ->export );
5454 define ('JSON_DB_SIZE ' , $ this ->size );
5555 define ('JSON_DB_MAX_SIZE ' , $ this ->max_size );
5656 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 ));
6161
6262// Проверяем наличие каталога базы данных, если нет создаем
63- if (!file_exists ($ this ->bd_path )){mkdir ($ this ->bd_path );}
63+ if (!file_exists ($ this ->db_path )){mkdir ($ this ->db_path );}
6464
6565 // Проверяем наличие главной таблицы если нет создаем
6666 try {
6767 \jsonDB \Validate::table ('db ' )->exists ();
6868
69- // Обновляем таблицу конфигурации db из параметров (new Db($bd_path , $temp, $api, $cached))->run();
69+ // Обновляем таблицу конфигурации db из параметров (new Db($db_path , $temp, $api, $cached))->run();
7070 $ update = jsonDb::table ('db ' )->find (1 ); // Edit with ID 1
7171
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 ;
7474 }
7575 if (isset ($ this ->cached )) {
7676 $ update ->cached = $ this ->cached ;
@@ -125,7 +125,7 @@ public function run()
125125 'export ' => 'string ' ,
126126 'size ' => 'integer ' ,
127127 'max_size ' => 'integer ' ,
128- 'bd_path ' => 'string ' ,
128+ 'db_path ' => 'string ' ,
129129 'dir_core ' => 'string ' ,
130130 'dir_log ' => 'string ' ,
131131 'dir_cached ' => 'string '
@@ -181,14 +181,11 @@ public function run()
181181 $ row ->export = $ this ->export ;
182182 $ row ->size = $ this ->size ;
183183 $ row ->max_size = $ this ->max_size ;
184- $ row ->bd_path = $ this ->bd_path ;
184+ $ row ->db_path = $ this ->db_path ;
185185 $ row ->dir_core = $ this ->dir_core ;
186186 $ row ->dir_log = $ this ->dir_log ;
187187 $ row ->dir_cached = $ this ->dir_cached ;
188188 $ row ->save ();
189-
190- // $row->user->name = $this->api;
191- // Добавление записи в связанную таблицу user с автоматической привязкой id
192189 }
193190
194191 // Читаем главную таблицу
@@ -197,10 +194,10 @@ public function run()
197194 define ('JSON_DB_PASSWORD ' , $ table ->password );
198195
199196 // Проверяем существуют ли необходимые каталоги, если нет создаем
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 );}
201198 if (!file_exists (JSON_DB_DIR_CORE )){mkdir (JSON_DB_DIR_CORE );}
202199 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 );}
204201
205202 // Если файла структуры базы данных нет, скачиваем его с github
206203 if (!file_exists (JSON_DB_DIR_CORE .'/db.json ' )){
@@ -303,7 +300,7 @@ public function run()
303300
304301 public static function cacheReader ($ uri ) // Читает кеш или удаляет кеш если время жизни просрочено
305302 {
306- if (JSON_DB_CACHET == true ) {
303+ if (JSON_DB_CACHED = == true ) {
307304
308305 $ row = jsonDb::table ('cached ' )->where ('cached_uri ' , '= ' , $ uri )->find ();
309306
@@ -355,12 +352,12 @@ public static function cacheWriter($uri, $arr) // Создает кеш
355352 {
356353 $ file_name = \jsonDB \Db::randomUid ();
357354
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 ));
359356
360357 $ row = jsonDb::table ('cached ' );
361358 $ row ->cached_count = 0 ;
362359 $ 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 ' ;
364361 $ row ->cached_time = date ("Y-m-d H:i:s " );
365362 $ row ->save ();
366363
0 commit comments