$link = new mysqli(HOST, USER, PASSWORD, DATABASE);
$host = HOST;
// Host name
$username = USER;
// Mysql username
$password = PASSWORD;
// Mysql password
$db_name = DATABASE;
// Database name
$tbl_name = "books";
// Table name
$sqli = mysqli_connect("{$host}", "{$username}", "{$password}", "{$db_name}") or die('Could not connect: ' . mysqli_connect_error());
$isbn = '0451458737';
$userid = $_SESSION['userid'];
if (isset($_POST['wishlist'])) {
    addToList($_SESSION['userid'], $isbn, $link);
}
if (isset($_POST['review'])) {
    addReview($_SESSION['userid'], $isbn, $_POST['review'], $link);
}
?>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

  <title>Alexandria Bookstore </title>
Exemplo n.º 2
0
 /**
  * Обработчик действия: Импорт каталога.
  */
 function Import()
 {
     @set_time_limit(0);
     require_once "Structures/DataGrid.php";
     require_once "Structures/DataGrid/DataSource/Excel.php";
     require_once "Structures/DataGrid/DataSource/CSV.php";
     require_once 'Image/Transform.php';
     mk_dir("files/" . DOMAIN . "/tmp");
     clearDir("files/" . DOMAIN . "/tmp");
     if (isset($_FILES['file']['tmp_name']) && file_exists($_FILES['file']['tmp_name'])) {
         $path_parts = pathinfo($_FILES['file']['name']);
         $ext = preg_replace("/[^a-z0-9]+/i", "", mb_strtolower($path_parts['extension']));
         if ($ext == 'xls' || $ext == 'csv' || $ext == 'gz') {
             if ($ext == 'gz') {
                 if (extractArchive($_FILES['file']['tmp_name'], "files/" . DOMAIN . "/tmp")) {
                     $sourcefile1 = preg_replace("/tar\\.gz\$/i", "xls", $_FILES['file']['name']);
                     $sourcefile2 = preg_replace("/tar\\.gz\$/i", "csv", $_FILES['file']['name']);
                     if (is_file("files/" . DOMAIN . "/tmp/{$sourcefile1}")) {
                         $sourcefile = "files/" . DOMAIN . "/tmp/{$sourcefile1}";
                         $ext = "xls";
                     } elseif (is_file("files/" . DOMAIN . "/tmp/{$sourcefile2}")) {
                         $sourcefile = "files/" . DOMAIN . "/tmp/{$sourcefile2}";
                         $content = @file_get_contents($sourcefile);
                         if ($content && !mb_check_encoding($content, 'UTF-8')) {
                             file_put_contents($sourcefile, mb_convert_encoding($content, 'UTF-8', 'Windows-1251'));
                         }
                         $ext = "csv";
                     } else {
                         return false;
                     }
                 } else {
                     return false;
                 }
             } elseif ($ext == 'csv') {
                 $sourcefile = $_FILES['file']['tmp_name'];
                 $content = @file_get_contents($sourcefile);
                 if ($content && !mb_check_encoding($content, 'UTF-8')) {
                     file_put_contents($sourcefile, mb_convert_encoding($content, 'UTF-8', 'Windows-1251'));
                 }
             } else {
                 $sourcefile = $_FILES['file']['tmp_name'];
             }
             if (!empty($_REQUEST['clear'])) {
                 switch ($_REQUEST['clear']) {
                     case 1:
                         A::$DB->execute("TRUNCATE " . SECTION . "_categories");
                     case 2:
                         A::$DB->execute("TRUNCATE " . SECTION . "_catalog");
                         A::$DB->execute("DELETE FROM " . DOMAIN . "_images WHERE idsec=" . SECTION_ID . " AND iditem>0");
                         A::$DB->execute("DELETE FROM " . DOMAIN . "_files WHERE idsec=" . SECTION_ID . " AND iditem>0");
                         A::$DB->execute("DELETE FROM " . DOMAIN . "_comments WHERE idsec=" . SECTION_ID);
                         A_SearchEngine::getInstance()->deleteSection(SECTION_ID);
                         break;
                 }
             }
             A::$OPTIONS['imgpath'] = !empty(A::$OPTIONS['imgpath']) ? preg_replace("/[^a-zA-Z0-9-_\\/]/i", "", A::$OPTIONS['imgpath']) : "ifiles";
             A::$OPTIONS['filepath'] = !empty(A::$OPTIONS['filepath']) ? preg_replace("/[^a-zA-Z0-9-_\\/]/i", "", A::$OPTIONS['filepath']) : "ifiles";
             $categories = array();
             $fields = array();
             $cfiles = array();
             A::$DB->query("SELECT * FROM " . SECTION . "_cols ORDER BY sort");
             $i = 0;
             while ($row = A::$DB->fetchRow()) {
                 if ($row['type'] == 'select' || $row['type'] == 'mselect') {
                     if ($row['idvar'] = A::$DB->getOne("SELECT property FROM " . DOMAIN . "_fields WHERE item='" . SECTION . "' AND field='{$row['field']}'")) {
                         if (isset($vars[$row['idvar']])) {
                             $row['vars'] =& $vars[$row['idvar']];
                         } else {
                             $row['vars'] = array();
                             $_vars = loadList($row['idvar']);
                             foreach ($_vars as $key => $name) {
                                 $row['vars'][$key] = is_array($name) ? $name['name'] : $name;
                             }
                             $vars[$row['idvar']] =& $row['vars'];
                         }
                     }
                 }
                 $row['id'] = $i++;
                 if (preg_match("/^category[0-9]{1}\$/i", $row['field'])) {
                     $categories[$row['field']] = $row;
                 } elseif ($row['type'] == 'image' || $row['type'] == 'file') {
                     $cfiles[$row['field']] = $row;
                 } else {
                     $fields[$row['field']] = $row;
                 }
             }
             A::$DB->free();
             if ($ext == 'xls') {
                 $datasource = new Structures_DataGrid_DataSource_Excel();
                 $datasource->bind($sourcefile);
             } elseif ($ext == 'csv') {
                 $datasource = new Structures_DataGrid_DataSource_CSV();
                 $datasource->bind($sourcefile, array('delimiter' => ';', 'enclosure' => '"'));
             } else {
                 return false;
             }
             $datagrid = new Structures_DataGrid();
             $datagrid->bindDataSource($datasource);
             A::$DB->caching = false;
             $prevgoods = A::$DB->getCount(SECTION . "_catalog", "active='Y'");
             $curgoods = 0;
             $arts = array();
             $catn = array();
             $catr = array();
             $cats = array();
             $i = 0;
             $gsort = A::$DB->getOne("SELECT MAX(sort) FROM " . SECTION . "_catalog") + 1;
             foreach ($datagrid->recordSet as $row) {
                 $i++;
                 if ($i == 1) {
                     continue;
                 }
                 if (empty($row)) {
                     continue;
                 }
                 if ($ext == 'xls') {
                     $trow = array();
                     foreach ($row as $j => $value) {
                         if (!empty($value)) {
                             $trow[$j - 1] = $value;
                         }
                     }
                     $row = $trow;
                 }
                 $idcat = 0;
                 for ($j = 0; $j < 3; $j++) {
                     if (isset($categories['category' . $j]) && !empty($row[$categories['category' . $j]['id']])) {
                         if ($cname = strip_tags(trim($row[$categories['category' . $j]['id']]))) {
                             $ch = md5($idcat . '|' . $cname);
                             if (isset($catn[$ch])) {
                                 $idcat = $catn[$ch];
                             } elseif ($_idcat = A::$DB->getOne("SELECT id FROM " . SECTION . "_categories WHERE idker={$idcat} AND name=?", $cname)) {
                                 $idcat = $catn[$ch] = $_idcat;
                             } else {
                                 if (!isset($catr[$idcat])) {
                                     $catr[$idcat] = A::$DB->getRowById($idcat, SECTION . "_categories");
                                 }
                                 $category = array();
                                 $category['name'] = $cname;
                                 $category['urlname'] = getURLName($cname);
                                 $category['idker'] = $idcat;
                                 $category['level'] = isset($catr[$idcat]['level']) ? $catr[$idcat]['level'] + 1 : 0;
                                 $category['sort'] = A::$DB->getOne("SELECT MAX(sort) FROM " . SECTION . "_categories WHERE idker={$idcat}") + 1;
                                 $idcat = $catn[$ch] = A::$DB->Insert(SECTION . "_categories", $category);
                             }
                         }
                     }
                 }
                 if ($idcat == 0 && empty($row[$fields['art']['id']])) {
                     continue;
                 }
                 $data = array();
                 $data['date'] = time();
                 if ($idcat > 0) {
                     $data['idcat'] = $idcat;
                     if (!isset($cats[$idcat])) {
                         $cats[$idcat] = 1;
                     } else {
                         $cats[$idcat]++;
                     }
                 }
                 $data['idcat1'] = 0;
                 $data['idcat2'] = 0;
                 foreach ($fields as $field => $frow) {
                     if (!isset($_REQUEST['iempty']) || !empty($row[$frow['id']])) {
                         switch ($frow['type']) {
                             default:
                                 $data[$field] = !empty($row[$frow['id']]) ? trim($row[$frow['id']]) : "";
                                 break;
                             case 'int':
                                 $data[$field] = !empty($row[$frow['id']]) ? (int) $row[$frow['id']] : 0;
                                 break;
                             case 'float':
                                 $data[$field] = !empty($row[$frow['id']]) ? (double) str_replace(',', '.', $row[$frow['id']]) : 0;
                                 break;
                             case 'select':
                                 if (!empty($row[$frow['id']])) {
                                     if (isset($frow['vars'])) {
                                         $row[$frow['id']] = trim($row[$frow['id']]);
                                         $key = array_search($row[$frow['id']], $frow['vars']);
                                         if (empty($key) && !empty($row[$frow['id']])) {
                                             $key = addToList($frow['idvar'], $row[$frow['id']]);
                                             $fields[$field]['vars'][$key] = $frow['vars'][$key] = $row[$frow['id']];
                                         }
                                         if (!empty($key)) {
                                             $data[$field] = $key;
                                         }
                                     }
                                 }
                                 break;
                             case 'mselect':
                                 if (!empty($row[$frow['id']])) {
                                     if (isset($frow['vars'])) {
                                         $row[$frow['id']] = explode(',', $row[$frow['id']]);
                                         $data[$field] = array();
                                         foreach ($row[$frow['id']] as $value) {
                                             $value = trim($value);
                                             $key = array_search($value, $frow['vars']);
                                             if (empty($key) && !empty($value)) {
                                                 $key = addToList($frow['idvar'], $value);
                                                 $fields[$field]['vars'][$key] = $frow['vars'][$key] = $value;
                                             }
                                             if (!empty($key)) {
                                                 $data[$field][] = sprintf("%04d", $key);
                                             }
                                         }
                                         $data[$field] = implode(",", $data[$field]);
                                     }
                                 }
                                 break;
                             case 'bool':
                                 $data[$field] = !empty($row[$frow['id']]) && $row[$frow['id']] != 'N' ? "Y" : "N";
                                 break;
                         }
                     }
                 }
                 if (isset($data['name'])) {
                     $data['name'] = strip_tags(trim($data['name']));
                 }
                 if (!empty(A::$OPTIONS['idrule'])) {
                     $_data = $data;
                     prepareValues(SECTION, $_data);
                     $litems = array();
                     $idrule = A::$OPTIONS['idrule'];
                     $idrule = explode("+", $idrule);
                     foreach ($idrule as $fname) {
                         if (!empty($_data[$fname])) {
                             $litems[] = getURLName($_data[$fname]);
                         }
                     }
                     $data['urlname'] = implode(!empty($GLOBALS['A_URL_SEPARATOR']) ? $GLOBALS['A_URL_SEPARATOR'] : "_", $litems);
                 } elseif (!empty($data['art'])) {
                     $data['urlname'] = getURLName($data['art']);
                 }
                 if (empty($data['urlname'])) {
                     $data['urlname'] = getURLName($data['name']);
                 }
                 if (!empty($data['content']) && empty($data['description'])) {
                     $data['description'] = truncate($data['content'], A::$OPTIONS['anonslen']);
                 }
                 if (!empty($data['art'])) {
                     $grow = A::$DB->getRow("SELECT id,mprices FROM " . SECTION . "_catalog WHERE art=? LIMIT 0,1", $data['art']);
                     if (A::$OPTIONS['usecats']) {
                         if (!empty($arts[$data['art']]) && !empty($data['idcat'])) {
                             if ($arts[$data['art']] < 3) {
                                 $data['idcat' . $arts[$data['art']]] = $data['idcat'];
                                 unset($data['idcat']);
                             }
                             $arts[$data['art']]++;
                         } else {
                             $arts[$data['art']] = 1;
                         }
                     }
                 } else {
                     $grow = A::$DB->getRow("SELECT id,mprices FROM " . SECTION . "_catalog WHERE idcat=? AND name=? LIMIT 0,1", array($data['idcat'], $data['name']));
                 }
                 if ($grow) {
                     $id = $grow['id'];
                     $mprices = !empty($grow['mprices']) ? unserialize($grow['mprices']) : array();
                 } else {
                     $id = 0;
                 }
                 if ($id) {
                     if (isset($fields['mprice']) && !empty($data['mprice'])) {
                         $inm = false;
                         foreach ($mprices as $mp) {
                             if ($mp['name'] == trim($data['mprice'])) {
                                 $inm = true;
                                 break;
                             }
                         }
                         if (!$inm) {
                             $mprices[] = array('name' => $data['mprice'], 'price' => !empty($data['price']) ? $data['price'] : '');
                         }
                         $data['mprices'] = serialize($mprices);
                         unset($data['price']);
                         $cats[$idcat]--;
                         $curgoods--;
                     }
                     if (isset($data['mprice'])) {
                         unset($data['mprice']);
                     }
                     A::$DB->Update(SECTION . "_catalog", $data, "id={$id}");
                     $images = A::$DB->getAssoc("SELECT sort,id,path FROM " . DOMAIN . "_images\r\r\n\t\t\tWHERE idsec=" . SECTION_ID . " AND iditem={$id}");
                     $images = array_values($images);
                     $files = A::$DB->getAssoc("SELECT sort,id,path FROM " . DOMAIN . "_files\r\r\n\t\t\tWHERE idsec=" . SECTION_ID . " AND iditem={$id}");
                     $files = array_values($files);
                     $curgoods++;
                 } elseif (!empty($data['idcat'])) {
                     if (isset($fields['mprice']) && !empty($data['mprice'])) {
                         $mprices = array(array('name' => $data['mprice'], 'price' => !empty($data['price']) ? $data['price'] : ''));
                         $data['mprices'] = serialize($mprices);
                     }
                     if (isset($data['mprice'])) {
                         unset($data['mprice']);
                     }
                     if (empty($data['name'])) {
                         continue;
                     }
                     $data['sort'] = $gsort++;
                     $id = A::$DB->Insert(SECTION . "_catalog", $data);
                     $images = array();
                     $files = array();
                     $curgoods++;
                 } else {
                     continue;
                 }
                 foreach ($cfiles as $field => $frow) {
                     if (!empty($row[$frow['id']])) {
                         switch ($frow['type']) {
                             case 'image':
                                 $row[$frow['id']] = preg_replace("/[^a-zA-Zа-яА-Я0-9-_.]/iu", "", $row[$frow['id']]);
                                 $path0 = A::$AUTH->isSuperAdmin() ? "ifiles/" . $row[$frow['id']] : "";
                                 $path1 = "files/" . DOMAIN . "/" . A::$OPTIONS['imgpath'] . "/" . $row[$frow['id']];
                                 $path2 = "files/" . DOMAIN . "/reg_images/" . $row[$frow['id']];
                                 $path = is_file($path0) ? $path0 : (is_file($path1) ? $path1 : (is_file($path2) ? $path2 : ""));
                                 if ($path) {
                                     preg_match("/^idimg([0-9]+)\$/i", $field, $mathes);
                                     $sort = $mathes[1];
                                     if (!isset($images[$sort]) || $images[$sort]['path'] != $path) {
                                         $image = array();
                                         $image['path'] = $path;
                                         $image['name'] = basename($row[$frow['id']]);
                                         $image['mime'] = getMimeByFile($row[$frow['id']]);
                                         $image['caption'] = !empty($data['name']) ? $data['name'] : "";
                                         $it = Image_Transform::factory('GD');
                                         $it->load($path);
                                         $image['width'] = $it->img_x;
                                         $image['height'] = $it->img_y;
                                         $image['idsec'] = SECTION_ID;
                                         $image['iditem'] = $id;
                                         $image['sort'] = $sort;
                                         if (isset($images[$sort])) {
                                             A::$DB->Update(DOMAIN . "_images", $image, "id=" . $images[$sort]['id']);
                                         } else {
                                             A::$DB->Insert(DOMAIN . "_images", $image);
                                         }
                                     }
                                 }
                                 break;
                             case 'file':
                                 $row[$frow['id']] = preg_replace("/[^a-zA-Zа-яА-Я0-9-_.]/iu", "", $row[$frow['id']]);
                                 $path0 = A::$AUTH->isSuperAdmin() ? "ifiles/" . $row[$frow['id']] : "";
                                 $path1 = "files/" . DOMAIN . "/" . A::$OPTIONS['filepath'] . "/" . $row[$frow['id']];
                                 $path2 = "files/" . DOMAIN . "/reg_files/" . $row[$frow['id']];
                                 $path = is_file($path0) ? $path0 : (is_file($path1) ? $path1 : (is_file($path2) ? $path2 : ""));
                                 if ($path) {
                                     preg_match("/^idfile([0-9]+)\$/i", $field, $mathes);
                                     $sort = $mathes[1];
                                     if (!isset($files[$sort]) || $files[$sort]['path'] != $path) {
                                         $file = array();
                                         $file['path'] = $path;
                                         $file['name'] = basename($row[$frow['id']]);
                                         $file['mime'] = getMimeByFile($row[$frow['id']]);
                                         $file['caption'] = !empty($data['name']) ? $data['name'] : "";
                                         $file['idsec'] = SECTION_ID;
                                         $file['iditem'] = $id;
                                         $file['sort'] = $sort;
                                         $file['size'] = filesize($path);
                                         $file['dwnl'] = 0;
                                         if (isset($files[$sort])) {
                                             A::$DB->Update(DOMAIN . "_files", $file, "id=" . $files[$sort]['id']);
                                         } else {
                                             A::$DB->Insert(DOMAIN . "_files", $file);
                                         }
                                     }
                                 }
                                 break;
                         }
                     }
                 }
             }
             if ($prevgoods > 0 && $prevgoods != $curgoods) {
                 $this->updateCItems();
             } else {
                 A::$DB->Update(SECTION . "_categories", array('citems' => 0));
                 foreach ($cats as $id => $count) {
                     A::$DB->Update(SECTION . "_categories", array('citems' => $count), "id={$id}");
                 }
                 $this->updateCItems(0, true);
             }
             A::$CACHE->resetSection(SECTION);
             delDir("files/" . DOMAIN . "/tmp");
             return true;
         }
     }
     return false;
 }
    delFromList('VKisses', 'Member', 'ID');
}
if ($_POST['FriendList_me_del']) {
    delFromList('FriendList', 'Profile', 'ID');
}
if ($_POST['ProfilesTrack_me_del']) {
    delFromList('ProfilesTrack', 'Profile', 'Member');
}
if ($_POST['FriendList__del']) {
    delFromList('FriendList', 'ID', 'Profile', true);
}
if ($_POST['HotList_me_add']) {
    addToList('HotList', 'ID', 'Profile');
}
if ($_POST['BlockList_me_add']) {
    addToList('BlockList', 'ID', 'Profile');
}
if ($_POST['FriendList_me_add']) {
    approveFriendInvites();
}
switch ($_GET['show']) {
    case 'hot':
        if ($_GET['list'] != 'me') {
            $ret .= PageCompListMembers('i', 'HotList', 'ID', 'Profile');
        }
        if ($_GET['list'] != 'i') {
            $ret .= PageCompListMembers('me', 'HotList', 'Profile', 'ID');
        }
        break;
    case 'friends_inv':
        if ($_GET['list'] != 'me') {
Exemplo n.º 4
0
function addToList($id)
{
    global $osmsites, $list;
    $element = $osmsites[$id];
    switch ($element['type']) {
        case 'way':
            foreach ($element['nodes'] as $nodeid) {
                $id = 'node#' . $nodeid;
                $list[$id] = true;
            }
            break;
        case 'relation':
            foreach ($element['members'] as $member) {
                $id = $member['type'] . '#' . $member['id'];
                $list[$id] = true;
                addToList($id);
                // rekurzív, reméljük nincs körkörös hivatkozás
            }
            break;
    }
}
Exemplo n.º 5
0
 function Import()
 {
     require_once "Structures/DataGrid.php";
     require_once "Structures/DataGrid/DataSource/Excel.php";
     require_once "Structures/DataGrid/DataSource/CSV.php";
     require_once 'Image/Transform.php';
     A::$REGFILES = getSectionByModule('pages');
     mk_dir("files/" . DOMAIN . "/tmp");
     clearDir("files/" . DOMAIN . "/tmp");
     if (isset($_FILES['file']['tmp_name']) && file_exists($_FILES['file']['tmp_name'])) {
         $path_parts = pathinfo($_FILES['file']['name']);
         $ext = preg_replace("/[^a-z0-9]+/i", "", mb_strtolower($path_parts['extension']));
         if ($ext == 'xls' || $ext == 'csv') {
             if ($ext == 'csv') {
                 $sourcefile = $_FILES['file']['tmp_name'];
                 $content = @file_get_contents($sourcefile);
                 if ($content && !mb_check_encoding($content, 'UTF-8')) {
                     file_put_contents($sourcefile, mb_convert_encoding($content, 'UTF-8', 'Windows-1251'));
                 }
             } else {
                 $sourcefile = $_FILES['file']['tmp_name'];
             }
             if ($ext == 'xls') {
                 $datasource = new Structures_DataGrid_DataSource_Excel();
                 $datasource->bind($sourcefile);
             } elseif ($ext == 'csv') {
                 $datasource = new Structures_DataGrid_DataSource_CSV();
                 $datasource->bind($sourcefile, array('delimiter' => ';', 'enclosure' => '"'));
             } else {
                 return false;
             }
             $datagrid = new Structures_DataGrid();
             $datagrid->bindDataSource($datasource);
             if (isset($_REQUEST['clear'])) {
                 A::$DB->execute("TRUNCATE " . STRUCTURE);
             }
             $sort = A::$DB->getOne("SELECT MAX(sort) FROM " . STRUCTURE) + 1;
             $list = array();
             foreach ($datagrid->recordSet as $row) {
                 if (empty($row)) {
                     continue;
                 }
                 if ($ext == 'xls') {
                     $trow = array();
                     foreach ($row as $j => $value) {
                         if (!empty($value)) {
                             $trow[$j - 1] = $value;
                         }
                     }
                     $row = $trow;
                 }
                 $data = array();
                 if (!empty($row[0])) {
                     $data['name_' . LANG] = trim($row[0]);
                 } else {
                     continue;
                 }
                 $j = 1;
                 A::$DB->query("SELECT * FROM " . DOMAIN . "_fields WHERE item='" . STRUCTURE . "' ORDER BY sort");
                 while ($frow = A::$DB->fetchRow()) {
                     switch ($frow['type']) {
                         default:
                             $data[$frow['field']] = !empty($row[$j]) ? trim($row[$j]) : "";
                             break;
                         case 'int':
                             $data[$frow['field']] = !empty($row[$j]) ? (int) $row[$j] : 0;
                             break;
                         case 'float':
                             $data[$frow['field']] = !empty($row[$j]) ? (double) $row[$j] : 0;
                             break;
                         case 'select':
                             if (!empty($row[$j])) {
                                 if (!isset($list[$frow['property']])) {
                                     $list[$frow['property']] = loadList($frow['property']);
                                 }
                                 $row[$j] = trim($row[$j]);
                                 $key = array_search($row[$j], $list[$frow['property']]);
                                 if (empty($key) && !empty($row[$j])) {
                                     $key = addToList($frow['property'], $row[$j]);
                                     $list[$frow['property']][$key] = $row[$j];
                                 }
                                 if (!empty($key)) {
                                     $data[$frow['field']] = $key;
                                 }
                             }
                             break;
                         case 'mselect':
                             if (!empty($row[$j])) {
                                 if (!isset($list[$frow['property']])) {
                                     $list[$frow['property']] = loadList($frow['property']);
                                 }
                                 $row[$j] = explode(',', $row[$j]);
                                 $data[$frow['field']] = array();
                                 foreach ($row[$j] as $value) {
                                     $value = trim($value);
                                     $key = array_search($value, $list[$frow['property']]);
                                     if (empty($key) && !empty($value)) {
                                         $key = addToList($frow['idvar'], $value);
                                         $list[$frow['property']][$key] = $value;
                                     }
                                     if (!empty($key)) {
                                         $data[$frow['field']][] = sprintf("%04d", $key);
                                     }
                                 }
                                 $data[$frow['field']] = implode(",", $data[$frow['field']]);
                             }
                             break;
                         case 'bool':
                             $data[$frow['field']] = !empty($row[$j]) && $row[$j] != 'N' ? "Y" : "N";
                             break;
                         case 'image':
                             $row[$j] = preg_replace("/[^a-zA-Zа-яА-Я0-9-_.]/iu", "", $row[$j]);
                             if (is_file($path = "ifiles/" . $row[$j])) {
                                 $data[$frow['field']] = RegisterImage($path, $data['name_' . LANG]);
                             }
                             break;
                         case 'file':
                             $row[$j] = preg_replace("/[^a-zA-Zа-яА-Я0-9-_.]/iu", "", $row[$j]);
                             if (is_file($path = "ifiles/" . $row[$j])) {
                                 $data[$frow['field']] = RegisterFile($path, $data['name_' . LANG]);
                             }
                             break;
                     }
                     $j++;
                 }
                 A::$DB->free();
                 $data['sort'] = $sort++;
                 A::$DB->Insert(STRUCTURE, $data);
             }
             return true;
         }
     }
     return false;
 }