@@ -13,43 +13,43 @@ |
||
13 | 13 | |
14 | 14 | class Init extends \Exchange1c\Mode { |
15 | 15 | |
16 | - public function process() { |
|
16 | + public function process() { |
|
17 | 17 | echo "zip=no\n"; |
18 | 18 | echo 'file_limit=' . \Tools::toBytes(ini_get('post_max_size')); |
19 | 19 | $this->end(); |
20 | 20 | |
21 | 21 | //clean files |
22 | 22 | if (!empty(\App::$cur->exchange1c->config['maxSaveFilesInterval'])) { |
23 | - $query = \App::$cur->db->newQuery(); |
|
24 | - $query->operation = 'select'; |
|
25 | - $query->table = \Exchange1c\Exchange\File::table(); |
|
26 | - $query->cols = \Exchange1c\Exchange\File::colPrefix() . 'id'; |
|
27 | - $queryArr = $query->buildQuery(); |
|
28 | - $queryArr['query'].=' where `' . \Exchange1c\Exchange\File::colPrefix() . 'deleted` = 0 AND `' . \Exchange1c\Exchange\File::colPrefix() . 'date_create` < NOW() - INTERVAL ' . \App::$cur->exchange1c->config['maxSaveFilesInterval']; |
|
29 | - try { |
|
23 | + $query = \App::$cur->db->newQuery(); |
|
24 | + $query->operation = 'select'; |
|
25 | + $query->table = \Exchange1c\Exchange\File::table(); |
|
26 | + $query->cols = \Exchange1c\Exchange\File::colPrefix() . 'id'; |
|
27 | + $queryArr = $query->buildQuery(); |
|
28 | + $queryArr['query'].=' where `' . \Exchange1c\Exchange\File::colPrefix() . 'deleted` = 0 AND `' . \Exchange1c\Exchange\File::colPrefix() . 'date_create` < NOW() - INTERVAL ' . \App::$cur->exchange1c->config['maxSaveFilesInterval']; |
|
29 | + try { |
|
30 | 30 | $ids = array_keys($query->query($queryArr)->getArray(\Exchange1c\Exchange\File::colPrefix().'id')); |
31 | - } catch (\PDOException $exc) { |
|
31 | + } catch (\PDOException $exc) { |
|
32 | 32 | if ($exc->getCode() == '42S02') { |
33 | - \Exchange1c\Exchange\File::createTable(); |
|
33 | + \Exchange1c\Exchange\File::createTable(); |
|
34 | 34 | } elseif ($exc->getCode() == '42S22') { |
35 | - $cols = \Exchange1c\Exchange\File::cols(); |
|
36 | - foreach (\Exchange1c\Exchange\File::$cols as $colName => $params) { |
|
35 | + $cols = \Exchange1c\Exchange\File::cols(); |
|
36 | + foreach (\Exchange1c\Exchange\File::$cols as $colName => $params) { |
|
37 | 37 | if (!isset($cols[\Exchange1c\Exchange\File::colPrefix() . $colName])) { |
38 | - \Exchange1c\Exchange\File::createCol($colName); |
|
38 | + \Exchange1c\Exchange\File::createCol($colName); |
|
39 | + } |
|
39 | 40 | } |
40 | - } |
|
41 | 41 | } |
42 | 42 | $ids = array_keys($query->query($queryArr)->getArray(\Exchange1c\Exchange\File::colPrefix().'id')); |
43 | - } |
|
44 | - foreach (array_chunk($ids, 500) as $idGroup) { |
|
43 | + } |
|
44 | + foreach (array_chunk($ids, 500) as $idGroup) { |
|
45 | 45 | $dfiles = \Exchange1c\Exchange\File::getList(['where' => ['id', $idGroup, 'IN']]); |
46 | 46 | foreach ($dfiles as $dfile) { |
47 | - $dfile->deleteFile(); |
|
48 | - unset($dfile); |
|
47 | + $dfile->deleteFile(); |
|
48 | + unset($dfile); |
|
49 | 49 | } |
50 | 50 | unset($dfiles); |
51 | - } |
|
51 | + } |
|
52 | + } |
|
52 | 53 | } |
53 | - } |
|
54 | 54 | |
55 | 55 | } |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | public function process() { |
17 | 17 | echo "zip=no\n"; |
18 | - echo 'file_limit=' . \Tools::toBytes(ini_get('post_max_size')); |
|
18 | + echo 'file_limit='.\Tools::toBytes(ini_get('post_max_size')); |
|
19 | 19 | $this->end(); |
20 | 20 | |
21 | 21 | //clean files |
@@ -23,9 +23,9 @@ discard block |
||
23 | 23 | $query = \App::$cur->db->newQuery(); |
24 | 24 | $query->operation = 'select'; |
25 | 25 | $query->table = \Exchange1c\Exchange\File::table(); |
26 | - $query->cols = \Exchange1c\Exchange\File::colPrefix() . 'id'; |
|
26 | + $query->cols = \Exchange1c\Exchange\File::colPrefix().'id'; |
|
27 | 27 | $queryArr = $query->buildQuery(); |
28 | - $queryArr['query'].=' where `' . \Exchange1c\Exchange\File::colPrefix() . 'deleted` = 0 AND `' . \Exchange1c\Exchange\File::colPrefix() . 'date_create` < NOW() - INTERVAL ' . \App::$cur->exchange1c->config['maxSaveFilesInterval']; |
|
28 | + $queryArr['query'] .= ' where `'.\Exchange1c\Exchange\File::colPrefix().'deleted` = 0 AND `'.\Exchange1c\Exchange\File::colPrefix().'date_create` < NOW() - INTERVAL '.\App::$cur->exchange1c->config['maxSaveFilesInterval']; |
|
29 | 29 | try { |
30 | 30 | $ids = array_keys($query->query($queryArr)->getArray(\Exchange1c\Exchange\File::colPrefix().'id')); |
31 | 31 | } catch (\PDOException $exc) { |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | } elseif ($exc->getCode() == '42S22') { |
35 | 35 | $cols = \Exchange1c\Exchange\File::cols(); |
36 | 36 | foreach (\Exchange1c\Exchange\File::$cols as $colName => $params) { |
37 | - if (!isset($cols[\Exchange1c\Exchange\File::colPrefix() . $colName])) { |
|
37 | + if (!isset($cols[\Exchange1c\Exchange\File::colPrefix().$colName])) { |
|
38 | 38 | \Exchange1c\Exchange\File::createCol($colName); |
39 | 39 | } |
40 | 40 | } |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | |
14 | 14 | class File extends \Exchange1c\Mode { |
15 | 15 | |
16 | - public function process() { |
|
16 | + public function process() { |
|
17 | 17 | $dir = $this->exchange->path; |
18 | 18 | \Tools::createDir($dir); |
19 | 19 | $file = new \Exchange1c\Exchange\File(); |
@@ -24,26 +24,26 @@ discard block |
||
24 | 24 | |
25 | 25 | $filename = \Tools::parsePath($_GET['filename']); |
26 | 26 | if (strpos($filename, '/') !== false) { |
27 | - $subDir = substr($filename, 0, strrpos($filename, "/") + 1); |
|
28 | - \Tools::createDir($dir . '/' . $subDir); |
|
27 | + $subDir = substr($filename, 0, strrpos($filename, "/") + 1); |
|
28 | + \Tools::createDir($dir . '/' . $subDir); |
|
29 | 29 | } |
30 | 30 | $text = ''; |
31 | 31 | if (false === file_put_contents($dir . '/' . $filename, file_get_contents("php://input"))) { |
32 | - $text = 'Fail on save file: ' . $filename; |
|
33 | - $file->status = 'failure'; |
|
32 | + $text = 'Fail on save file: ' . $filename; |
|
33 | + $file->status = 'failure'; |
|
34 | 34 | } else { |
35 | - $file->size = ceil(filesize($dir . '/' . $filename)); |
|
36 | - $file->name = $filename; |
|
37 | - $file->status = 'success'; |
|
35 | + $file->size = ceil(filesize($dir . '/' . $filename)); |
|
36 | + $file->name = $filename; |
|
37 | + $file->status = 'success'; |
|
38 | 38 | } |
39 | 39 | $file->save(); |
40 | 40 | if (strpos($filename, '1cbitrix') !== false) { |
41 | - $data = new \SimpleXMLElement(file_get_contents($dir . '/' . $filename)); |
|
42 | - $orders = new \Exchange1c\Parser\Orders($data); |
|
43 | - $orders->process(); |
|
41 | + $data = new \SimpleXMLElement(file_get_contents($dir . '/' . $filename)); |
|
42 | + $orders = new \Exchange1c\Parser\Orders($data); |
|
43 | + $orders->process(); |
|
44 | 44 | } |
45 | 45 | \App::$cur->exchange1c->response($file->status, $text, false); |
46 | 46 | $this->end($file->status); |
47 | - } |
|
47 | + } |
|
48 | 48 | |
49 | 49 | } |
@@ -25,20 +25,20 @@ |
||
25 | 25 | $filename = \Tools::parsePath($_GET['filename']); |
26 | 26 | if (strpos($filename, '/') !== false) { |
27 | 27 | $subDir = substr($filename, 0, strrpos($filename, "/") + 1); |
28 | - \Tools::createDir($dir . '/' . $subDir); |
|
28 | + \Tools::createDir($dir.'/'.$subDir); |
|
29 | 29 | } |
30 | 30 | $text = ''; |
31 | - if (false === file_put_contents($dir . '/' . $filename, file_get_contents("php://input"))) { |
|
32 | - $text = 'Fail on save file: ' . $filename; |
|
31 | + if (false === file_put_contents($dir.'/'.$filename, file_get_contents("php://input"))) { |
|
32 | + $text = 'Fail on save file: '.$filename; |
|
33 | 33 | $file->status = 'failure'; |
34 | 34 | } else { |
35 | - $file->size = ceil(filesize($dir . '/' . $filename)); |
|
35 | + $file->size = ceil(filesize($dir.'/'.$filename)); |
|
36 | 36 | $file->name = $filename; |
37 | 37 | $file->status = 'success'; |
38 | 38 | } |
39 | 39 | $file->save(); |
40 | 40 | if (strpos($filename, '1cbitrix') !== false) { |
41 | - $data = new \SimpleXMLElement(file_get_contents($dir . '/' . $filename)); |
|
41 | + $data = new \SimpleXMLElement(file_get_contents($dir.'/'.$filename)); |
|
42 | 42 | $orders = new \Exchange1c\Parser\Orders($data); |
43 | 43 | $orders->process(); |
44 | 44 | } |
@@ -13,37 +13,37 @@ |
||
13 | 13 | |
14 | 14 | class File extends \Model { |
15 | 15 | |
16 | - public static $cols = [ |
|
17 | - 'name' => ['type' => 'text'], |
|
18 | - 'exchange_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'exchange'], |
|
19 | - 'size' => ['type' => 'number'], |
|
20 | - 'status' => ['type' => 'text'], |
|
21 | - 'deleted' => ['type' => 'bool'], |
|
22 | - 'date_create' => ['type' => 'dateTime'], |
|
23 | - ]; |
|
24 | - public static $dataManagers = [ |
|
25 | - 'manager' => [ |
|
26 | - 'cols' => [ |
|
27 | - 'name', 'size', 'status', 'deleted', 'date_create' |
|
28 | - ], |
|
29 | - ] |
|
30 | - ]; |
|
16 | + public static $cols = [ |
|
17 | + 'name' => ['type' => 'text'], |
|
18 | + 'exchange_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'exchange'], |
|
19 | + 'size' => ['type' => 'number'], |
|
20 | + 'status' => ['type' => 'text'], |
|
21 | + 'deleted' => ['type' => 'bool'], |
|
22 | + 'date_create' => ['type' => 'dateTime'], |
|
23 | + ]; |
|
24 | + public static $dataManagers = [ |
|
25 | + 'manager' => [ |
|
26 | + 'cols' => [ |
|
27 | + 'name', 'size', 'status', 'deleted', 'date_create' |
|
28 | + ], |
|
29 | + ] |
|
30 | + ]; |
|
31 | 31 | |
32 | - public function deleteFile() { |
|
32 | + public function deleteFile() { |
|
33 | 33 | if ($this->exchange && file_exists($this->exchange->path . '/' . $this->name)) { |
34 | - unlink($this->exchange->path . '/' . $this->name); |
|
34 | + unlink($this->exchange->path . '/' . $this->name); |
|
35 | 35 | } |
36 | 36 | $this->deleted = 1; |
37 | 37 | $this->save(); |
38 | - } |
|
38 | + } |
|
39 | 39 | |
40 | - public static function relations() { |
|
40 | + public static function relations() { |
|
41 | 41 | return [ |
42 | 42 | 'exchange' => [ |
43 | 43 | 'model' => 'Exchange1c\Exchange', |
44 | 44 | 'col' => 'exchange_id' |
45 | 45 | ] |
46 | 46 | ]; |
47 | - } |
|
47 | + } |
|
48 | 48 | |
49 | 49 | } |
@@ -30,8 +30,8 @@ |
||
30 | 30 | ]; |
31 | 31 | |
32 | 32 | public function deleteFile() { |
33 | - if ($this->exchange && file_exists($this->exchange->path . '/' . $this->name)) { |
|
34 | - unlink($this->exchange->path . '/' . $this->name); |
|
33 | + if ($this->exchange && file_exists($this->exchange->path.'/'.$this->name)) { |
|
34 | + unlink($this->exchange->path.'/'.$this->name); |
|
35 | 35 | } |
36 | 36 | $this->deleted = 1; |
37 | 37 | $this->save(); |