public function generate($xml_file) { if (!file_exists($xml_file)) { throw new Exception("XML-file '{$xml_file}' NOT exosts."); } $xml = new SimpleXMLElement(file_get_contents($xml_file)); // Create a new PHPWord Object $objPHPWord = new PHPWord(); // Every element you want to append to the word document is placed in a section. So you need a section: $section = $objPHPWord->createSection(); foreach ($xml->body->p as $p) { $section->addText((string) $p); dbg::write((string) $p); } header('Content-Type: application/vnd.ms-word'); header('Content-Disposition: attachment;filename="' . (string) $xml->body['title'] . '.doc"'); header('Cache-Control: max-age=0'); $objWriter = PHPWord_IOFactory::createWriter($objPHPWord, 'Word2007'); $objWriter->save('php://output'); exit; }
public function cache_it($tocacho) { try { $this->gen_filename(); $this->tocacho = $tocacho; $this->save_data(); } catch (Exception $e) { dbg::write($e->getMessage); } }
/** * Форма фхода в админку * @access protected */ public function admin() { $args = request::get(array('user', 'secret')); $data = array('LC' => LC::get()); try { if (!empty($args)) { authenticate::login(); } } catch (Exception $e) { dbg::write($e->getMessage(), LOG_PATH . 'adm_access.log'); $data['errors'] = $e->getMessage(); } if (!authenticate::is_logged()) { $tmpl = new tmpl($this->pwd() . 'login.html'); response::send($tmpl->parse($data), 'html'); } else { response::redirect('/xxx/'); } }
/** * Удалить существующий файл из хранилища * @param string $real_name Имя удаляемого файла */ public static function remove_file($real_name, $storage_path = null) { try { if (empty($real_name)) { throw new Exception('The file name not present.'); } if (!$storage_path) { $storage_path = FILE_STORAGE_PATH; } $file = $storage_path . $real_name; if (file_exists($file)) { if (!@unlink($file)) { throw new Exception('Error while unlink "' . $file . '"'); } } return true; } catch (Exception $e) { dbg::write("Error while removing file \"{$file}\": " . $e->getMessage()); return false; } }
<?php /** * The user interface initialization code * * @author Litvinenko S. Anthon <*****@*****.**> * @version 2.0 * @access public * @package CFsCMS2(PE) */ try { // Call user interface $ui = user_interface::get_instance(request::get('ui', UI_DEFAULT)); if (($content = $ui->call(request::get('cll'), request::get())) === FALSE) { response::header('404'); } else { response::send($content, 'html'); } } catch (Exception $e) { dbg::write($e->getMessage(), LOG_PATH . 'ui_errors.log'); //response::header('404'); //9* 28102010 $out = user_interface::get_instance('action_page'); $out->set_args(array('action_msg' => $e->getMessage())); return $out->render(); }
<?php // NOTE: Инициализация базовой части CMS define('AUTH_MODE', 'public'); define('AUTH_DI', 'user'); include_once 'base.php'; $args = request::get(array('user', 'secret')); try { if (!empty($args)) { authenticate::login(); } } catch (Exception $e) { dbg::write($e->getMessage(), LOG_PATH . 'access.log'); $data['errors'] = $e->getMessage(); } try { if (authenticate::is_logged() && request::get('logout') == 'yes') { authenticate::logout(); } } catch (Exception $e) { }
/** * Parse tmpl according with THEME INSTANCE OR default options * @access public * @param string $tmpl_name array() $data to parse out * @return parsed template tmpl2 */ public function parse_tmpl($template_file_name, $data) { if ($this->UI_LANG) { $data = array_merge($data, $this->UI_LANG); } if ($tmpl_path = $this->get_resource_path($template_file_name, 'absolute')) { $tmpl = new tmpl($tmpl_path); $html = $tmpl->parse($data); return $html; } else { $dbgs = array_shift(debug_backtrace()); dbg::write("TEMPLATE WAS NOT FOUND at user_interface::parse_tmpl() \nCall from:..... " . $dbgs['file'] . "\nline:.......... " . $dbgs['line'] . "\ntemplate: {$template_file_name}\npath1: {$tmpl_path} \npath2: {$tmpl_path2}"); } return false; }
* @author Litvinenko S. Anthon <*****@*****.**> * @access public * @package SBIN DIESEL */ try { $uri = empty($_SERVER['REDIRECT_URL']) ? '/' : $_SERVER['REDIRECT_URL']; $diStrc = data_interface::get_instance(SITE_DI); $page = $diStrc->get_page_by_uri($uri); define(PAGE_URI, $page['uri']); define(SRCH_URI, str_replace($page['uri'], "", $uri)); define(PAGE_ID, $page['id']); if (!empty($page['redirect'])) { response::redirect($page['redirect']); } else { $uiStrc = user_interface::get_instance(SITE_UI); $uiStrc->set_args(request::get()); $uiStrc->process_page($page); } } catch (Exception $e) { dbg::write('Error: ' . $e->getMessage()); //response::header('404'); //9* 28102010 try { $out = user_interface::get_instance('action_page'); $out->set_args(array('action_msg' => $e->getMessage())); return $out->render(); } catch (Exception $e) { dbg::write('Error: ' . $e->getMessage()); echo '<center>WWW ENGINE IS NOT PRESENTED</center>'; } }
/** * Подготовить сортировку для запроса */ private function _prepare_order() { if (!empty($this->di->__order)) { $x = array(); foreach ($this->di->__order as $rec) { if ($rec['di'] === null) { $x[] = "`{$rec['field']}` {$rec['dir']}"; } else { if ($rec['di']->field_exists($rec['field'])) { $table = $rec['di']->get_alias(); $x[] = "`{$table}`.`{$rec['field']}` {$rec['dir']}"; } else { if ($rec['di']->get_field_name_by_alias($rec['field'])) { $x[] = "`{$rec['field']}` {$rec['dir']}"; } else { // Раз поля такого нет то ищем в алиасах джойнеых таблиц если они есть if (count($this->_dis) > 1) { foreach ($this->_dis as $key => $value) { if ($value->field_exists($rec['field'])) { $table = $value->get_alias(); $x[] = "`{$table}`.`{$rec['field']}` {$rec['dir']}"; } elseif ($value->get_field_name_by_alias($rec['field'])) { $x[] = "`{$rec['field']}` {$rec['dir']}"; } } } } } } } if (count($x) > 0) { $this->_order = "ORDER BY " . join(', ', $x); } else { dbg::write('Warning! Some uniterpreted fields used in ORDER BY at DI: ' . $this->di->title); } } }
public function perform_init($type_id, $path_di, $path_dump) { $type = $this->types_map[$type_id]; if ($type_id == 4) { $type = 2; } $dh = dir($path_di); while (($i = $dh->read()) !== FALSE) { if (preg_match('/^(\\w+)\\.di\\.php$/', $i, $match)) { if ($iObj = data_interface::get_instance($match[1])) { if ($this->dump_kernel_to_instance_cfg == false) { if (preg_match('/^cpy_.+/', $match[1], $match2)) { continue; } } try { $iObj->init_dump2($type, $path_dump); } catch (Exception $e) { dbg::write($match[1] . ' ' . $e->getMessage()); } } } } $dh->close(); }
<?php /** * The data interface initialization code * * @author Litvinenko S. Anthon <*****@*****.**> * @version 2.0 * @access public * @package SBIN Diesel */ try { // NOTE: If defined authentication data interface and user not logged in /* 9* старый вариант не рубил отдачу файлов по сслке /files/?id=6 например в случае если юзер не залогинен и вот потому дополнительно условие если аутх мое публик то на pub_ не будем руибить доступ ибо это публик по дефолту if (defined('AUTH_DI') && !authenticate::is_logged()) */ if (defined('AUTH_DI') && !authenticate::is_logged() && AUTH_MODE != 'public') { // Then send error response::send('Session closed. Authorization needed.', 'error'); } $di = data_interface::get_instance(request::get('di')); // If return FALSE then access denied if (!$di->call(request::get('cll'), request::get())) { response::send('Access denied.', 'error'); } } catch (Exception $e) { dbg::write("UID: " . UID . "\nREQUEST_URI: {$_SERVER['REQUEST_URI']}\n" . $e->getMessage() . "\n" . $e->getTraceAsString(), LOG_PATH . 'di_errors.log'); response::send('Error while process request.', 'error'); }
<?php /** * The user interface initialization code * * @author Litvinenko S. Anthon <*****@*****.**> * @version 2.0 * @access public * @package CFsCMS2(PE) */ try { // NOTE: If defined authentication data interface and user not logged in if (defined('AUTH_DI') && !authenticate::is_logged()) { // Then redicrect to login form response::redirect('login/'); } // Call user interface $ui = user_interface::get_instance(request::get('ui', UI_DEFAULT)); if (($content = $ui->call(request::get('cll', UI_CLL_DEFAULT), request::get())) === FALSE) { response::header('404'); } else { response::send($content, 'html'); } } catch (Exception $e) { dbg::write($e->getMessage() . "\n" . $e->getTraceAsString(), LOG_PATH . 'ui_errors.log'); response::header('404'); }