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; }
/** * Gets the only class instance * * @return dbg */ public static function get_instance() { if (!isset(self::$_instance)) { $c = __CLASS__; self::$_instance = new $c(); } return self::$_instance; }
public function cache_it($tocacho) { try { $this->gen_filename(); $this->tocacho = $tocacho; $this->save_data(); } catch (Exception $e) { dbg::write($e->getMessage); } }
/** * Gets hook handler class instance * * @param array $argv * @return AbstractHandler */ public static function &get_handler(array $argv) { $handler_name = self::hook_name_to_handler_class(isset($argv[1]) ? $argv[1] : ''); dbg::get_instance()->write('handler name: ' . $handler_name); if (class_exists($handler_name)) { unset($argv[0]); unset($argv[1]); $out = new $handler_name(array_values($argv)); } else { $out = null; } return $out; }
/** * Prepares commands list * * @return bool */ public function prepare() { $conf = SVNHooksConfig::get_instance(); $ex_str = sprintf("%s info %s -r %s 2>&1", $conf->svnlook, $this->repos, $this->rev); exec($ex_str, $out, $code); dbg::get_instance()->write('PostCommitHandler::prepare exec result: ' . $code); dbg::get_instance()->write('PostCommitHandler::prepare exec output: ' . var_export($out, true)); if ($code) { return false; } $this->revision_wrapper = new SVNRevisionWrapper($this->rev, $out); dbg::get_instance()->write('PostCommitHandler::prepare SVNRevisionWrapper: ' . var_export($this->revision_wrapper, true)); $this->commands[] = new CommandActiveUser($this->revision_wrapper->author); if (!$this->parse_comment_into_commands()) { return false; } return count($this->commands) > 1; }
/** * Форма фхода в админку * @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) { }
require_once 'classes/class.FSConfig.php'; require_once 'classes/class.SVNHooksConfig.php'; require_once 'classes/flyspray/class.FlySprayCommand.php'; require_once 'classes/class.SVNRevisionWrapper.php'; require_once 'classes/class.dbg.php'; require_once 'classes/class.SVNHooksHandlerFactory.php'; require_once 'classes/handlers/class.AbstractHandler.php'; require_once 'classes/handlers/class.PostCommitHandler.php'; require_once 'classes/flyspray/class.CommandAddVote.php'; require_once 'classes/flyspray/class.CommandAddUserToGroup.php'; require_once 'classes/flyspray/class.CommandCloseTask.php'; require_once 'classes/flyspray/class.CommandEditTask.php'; require_once 'classes/flyspray/class.CommandAssignToMe.php'; require_once 'classes/flyspray/class.FlySprayResponse.php'; require_once 'classes/flyspray/class.CommandActiveUser.php'; require_once 'classes/flyspray/class.CommandAddComment.php'; require_once 'classes/flyspray/class.CommandAddToAssignees.php'; require_once 'classes/flyspray/class.CommandAddNotification.php'; require_once 'classes/flyspray/class.CommandRemoveNotification.php'; if (!isset($argv)) { $argv = array(); } dbg::get_instance()->write('argv: ' . var_export($argv, true)); $handler = SVNHooksHandlerFactory::get_handler($argv); dbg::get_instance()->write('handler: ' . var_export($handler, true)); if (!is_null($handler)) { if ($handler->prepare()) { $handler->send(); } }
/** * Подготовить сортировку для запроса */ 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(); }
/** * @return string */ protected static function get_div_css() { if (self::$html_div_container_css !== null) { return self::$html_div_container_css; } $html = "width:100%;padding:1px;margin-top:1px;font-family:Roboto,sans-serif;font-size:13px;" . "box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;" . "background-color:#fff;"; return self::$html_div_container_css = $html; }
<?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'); }
* @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>'; } }
/** * Некий аналог XPath * * @param array $args Результат работы регулярного выражния /((\.|\w+|)(\/|\[[^\]]+\]))/ * @return mixed Значение результата поиска, или FALSE если указан неверный путь * @see this::_parse_path() */ private function _parse_XPath($args, $_data = FALSE) { if (!$_data) { $_data = $this->local_data; } $nodes = $args[1]; $params = $args[2]; $data = $_data; foreach ($nodes as $key => $name) { if ($name == '/') { $data = $this->root_data; } elseif ($name == '.') { } elseif ($name and $params[$key] == '') { $data = $this->_parse_path($name, $data, FALSE); } elseif ($name and ($params[$key] != '/' or $params[$key] != '') and preg_match('/^\\[((?:\\$|\\@|\\#)\\w+)\\]$/', $params[$key], $matches)) { $key = $this->_parse_path($matches[1]); $data = $this->_parse_path($name, $data, FALSE); $data = $this->_get_value($data, $key); } elseif ($name and ($params[$key] != '/' or $params[$key] != '') and preg_match('/^\\[(\\d+)\\]$/', $params[$key], $matches)) { $data = $this->_parse_path($name, $data, FALSE); $data = $this->_get_value($data, $matches[1]); } elseif ($name and ($params[$key] != '/' or $params[$key] != '') and $matches = $this->_parse_XPath_get_conditions($params[$key])) { if ($data = $this->_get_value($data, $name)) { if (isset($data[0])) { $x = $data; $data = array(); foreach ($x as $y) { if ($z = $this->_parse_XPath_check_conditions($matches, $y)) { $data[] = $z; } } } else { $data = $this->_parse_XPath_check_conditions($matches, $data); } } } else { dbg::show('Не определённый узел указателя "' . $name . '"!'); } } return $data; }
/** * 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; }
/** * Send commands to flyspray * * @param string $url * @param string $cookie_file * @param string $data JSON encoded array of commands * @throws Exception */ private function transfer($url, $cookie_file, $data) { try { dbg::get_instance()->write("Commands to transfer:\r\n" . $data); $result = $this->send_request($url, $cookie_file, "commands={$data}"); dbg::get_instance()->write("transfer result:\r\n" . $result); } catch (Exception $exc) { dbg::get_instance()->write("AbstractHandler::transfer threw Exception"); throw $exc; } }
<?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'); }