function convert_class_to_filename($class) { return './classes/class_' . str_replace('_', '/', $class) . '.php'; } function __autoload($class) { @(include_once convert_class_to_filename($class)); } include_once './db_connect.php'; include_once './func.php'; //подключаемся к базе $dbh = mysql_connect(host, user, pswd) or die("Не могу соединиться с MySQL."); mysql_select_db(SCAD) or die("Не могу подключиться к базе."); mysql_query("SET NAMES utf8"); //обновляем группы для подбора стали $groups_for_steel = new TMemberGroupSteel21(); $s = $groups_for_steel->set_to_scad_spr(); $body_hex = bin2hex($s); $sql = "UPDATE " . document_bin . " SET body = 0x{$body_hex} WHERE number = " . D_member_group_for_steel; mysql_query($sql); //обновляем комбинации //$combinations = new TCombination(); //$s = $combinations->set_to_scad_spr(); //$body_hex = bin2hex($s); //$sql = "UPDATE " . document_bin . " SET body = 0x$body_hex WHERE id = " . D_combinations; //mysql_query($sql); define('START_OFFSET', 8); //собираем документ $today = date("d.m.Y"); header("Content-Disposition: attachment; filename={$today}.spr"); header("Content-Type: application/octet-stream");
$isFinalDoc = TRUE; } } // Добавляем документ No.0 // Байты между указателем на адрес описания документов и первым записанным документом $document[0] = new TDoc(0, START_OFFSET + 4, $minDocOffset - START_OFFSET - 4); // Читаем документы в массив foreach ($document as &$object) { // Помещаем указатель в начало документа fseek($f, $object->byte_offset); // Читаем документ $object->body = fread($f, $object->byte_count); } //разбираем группы для подбора стали if (isset($document[D_member_group_for_steel])) { $member_groups_for_steel = new TMemberGroupSteel21(); $member_groups_for_steel->get_from_scad_spr($document[D_member_group_for_steel]->body); echo D_member_group_for_steel . ' - группы элементов для подбора;<br/>'; } //разбираем комбинации // if (isset($document[D_combinations])) { // $combinations = new TCombination(); // $combinations->get_from_scad_spr($document[D_combinations]->body); // echo D_combinations.' - комбинации;<br/>'; // } // Сортируем массив по byte_offset usort($document, 'compareDocByOffset'); // Ищем промежутки между документами for ($i = 0; $i < count($document) - 1; $i++) { $pos = $document[$i]->byte_offset + $document[$i]->byte_count; $count = $document[$i + 1]->byte_offset - $pos;