80 lines
3.5 KiB
PHP
80 lines
3.5 KiB
PHP
|
|
<?php
|
||
|
|
require_once($_SERVER['DOCUMENT_ROOT'] . "/config.php");
|
||
|
|
|
||
|
|
ini_set('display_errors', 1);
|
||
|
|
error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE);
|
||
|
|
|
||
|
|
include $_SERVER['DOCUMENT_ROOT'] . '/import/obj/ImportRecord.php';
|
||
|
|
include $_SERVER['DOCUMENT_ROOT'] . '/import/obj/BlockImage.php';
|
||
|
|
include $_SERVER['DOCUMENT_ROOT'] . '/import/document/target/DocTarget.php';
|
||
|
|
include $_SERVER['DOCUMENT_ROOT'] . '/import/document/target/BlockProgressImageFacade.php';
|
||
|
|
include $_SERVER['DOCUMENT_ROOT'] . '/import/obj/Block.php';
|
||
|
|
include $_SERVER['DOCUMENT_ROOT'] . '/import/ImporterService.php';
|
||
|
|
include $_SERVER['DOCUMENT_ROOT'] . '/import/document/DocumentManager.php';
|
||
|
|
include $_SERVER['DOCUMENT_ROOT'] . '/import/document/provider/DocProvider.php';
|
||
|
|
include $_SERVER['DOCUMENT_ROOT'] . '/import/document/provider/DbDocProvider.php';
|
||
|
|
include $_SERVER['DOCUMENT_ROOT'] . '/import/document/entity/Dir.php';
|
||
|
|
include $_SERVER['DOCUMENT_ROOT'] . '/import/document/entity/RootDir.php';
|
||
|
|
include $_SERVER['DOCUMENT_ROOT'] . '/import/document/entity/File.php';
|
||
|
|
include $_SERVER['DOCUMENT_ROOT'] . '/import/document/entity/DocCollection.php';
|
||
|
|
include $_SERVER['DOCUMENT_ROOT'] . '/import/document/ar/Document.php';
|
||
|
|
include $_SERVER['DOCUMENT_ROOT'] . '/import/document/exception/DocNotFoundException.php';
|
||
|
|
include $_SERVER['DOCUMENT_ROOT'] . '/import/document/exception/TargetNotFoundException.php';
|
||
|
|
|
||
|
|
if ($_SESSION['id'] && isset($_SESSION['superadmin'])) {
|
||
|
|
|
||
|
|
$post = clearInputData($_POST);
|
||
|
|
|
||
|
|
if (isset($post['blockId'])) {
|
||
|
|
|
||
|
|
if (!$flatShopDb = mysql_connect("185.76.145.152", "pubcrm", "pubcrmmysqlpass")) {
|
||
|
|
echo mysql_error();
|
||
|
|
die("No connect database FlatShop 185.76.145.152...");
|
||
|
|
}
|
||
|
|
if (!mysql_select_db("pub_crm", $flatShopDb)) {
|
||
|
|
die("No selected database pub_crm...");
|
||
|
|
}
|
||
|
|
$sql = "SET NAMES 'utf8'";
|
||
|
|
mysql_query($sql, $flatShopDb);
|
||
|
|
|
||
|
|
$block = Block::findOne($post['blockId']);
|
||
|
|
|
||
|
|
$sql = "SELECT additional FROM blocks where id = '" . $block->id . "'";
|
||
|
|
$rez = mysql_query($sql, $flatShopDb);
|
||
|
|
|
||
|
|
if (mysql_num_rows($rez) > 0) {
|
||
|
|
$dbObject = mysql_fetch_assoc($rez);
|
||
|
|
|
||
|
|
$sql = "UPDATE blocks SET additional = '" . $dbObject['additional'] . "' WHERE id = '" . $block->id . "'";
|
||
|
|
mysql_query($sql, $mdb);
|
||
|
|
}
|
||
|
|
|
||
|
|
$sql = "SELECT * FROM documents where target_type = '" . Document::TYPE_BLOCK . "' AND target_id = '" . $block->id . "' ORDER BY created_at";
|
||
|
|
$rez = mysql_query($sql, $flatShopDb);
|
||
|
|
|
||
|
|
$ids_array = array();
|
||
|
|
|
||
|
|
if (mysql_num_rows($rez) > 0) {
|
||
|
|
|
||
|
|
$sql = "DELETE FROM documents where target_type = '" . Document::TYPE_BLOCK . "' AND target_id = '" . $block->id . "'";
|
||
|
|
mysql_query($sql, $mdb);
|
||
|
|
|
||
|
|
while ($dbObject = mysql_fetch_assoc($rez)) {
|
||
|
|
$parent = 0;
|
||
|
|
if ($dbObject['parent'] > 0) {
|
||
|
|
$parent = $ids_array[$dbObject['parent']];
|
||
|
|
}
|
||
|
|
$sql = "INSERT INTO documents (name, created_at, target_id, target_type, parent, file) VALUES ('" . $dbObject['name'] .
|
||
|
|
"', NOW(), '" . $block->id . "', '" . $dbObject['target_type'] . "', '" . $parent . "', '" . $dbObject['file'] . "')";
|
||
|
|
mysql_query($sql, $mdb);
|
||
|
|
$err = mysql_errno($mdb);
|
||
|
|
if ($err > 0) {
|
||
|
|
echo mysql_error($mdb);
|
||
|
|
continue;
|
||
|
|
}
|
||
|
|
|
||
|
|
$ids_array[$dbObject['id']] = mysql_insert_id($mdb);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|