public function createsl($rec) { extract($rec); $excel = file_get_contents($this->getDir() . $template); if ($fileext == "xml") { // усли шаблон xml файл // заменяем в xml файле данные попадающие под шаблон _имя_ на переменную имя из $rec preg_match_all('/_([0-9a-z]+)_/', $excel, $matchesarray); for ($i = 0; $i < count($matchesarray[0]); $i++) { $excel = str_replace($matchesarray[0][$i], ${$matchesarray[1][$i]}, $excel); } } elseif ($fileext == "xls") { // а шаблон может быть и xls файлом, if (fileserver::savefile("{$filename}.txt", $rec)) { $url = "http://baza3.mpp/?level=getdata&getdata[act]=checksl&slid={$number}"; try { $barcode = new QR_Code(-1, QR_ErrorCorrectLevel::H); $barcode->addData($url); $barcode->make(); $imgbarcode = new QR_CodeImage($barcode, 150, 150, 10); $imgbarcode->draw(); $imgbarcode->store("{$filename}.jpg"); $imgbarcode->finish(); @chmod("{$filename}.jpg", 0777); } catch (Exception $ex) { console::getInstance()->out($ex->getMessage()); console::getInstance()->out($ex->getTraceAsString()); } /*$barcode = new BarcodeQR(); $barcode->url($url); $barcode->draw(150, "{$filename}.png"); */ } else { $out = "Не удалось создать файл txt"; return false; } // а сам xls запишитеся ниже } else { // вернем ошибку или в будущем как-то обработаем файл return false; } // сохранить if (fileserver::savefile($filename, $excel)) { Output::assign('sllink', fileserver::sharefilelink($filename)); Output::assign('slid', $lanch_id); $out = $this->fetch('partylink.tpl') . ($last ? '<script>reload_table();</script>' : ''); } else { $out = "Не удалось записать файл"; $out = false; } // вернуть ссылку на файл return $out; }