コード例 #1
0
 function TitleIndexer_mysqli($name = 'titleindex')
 {
     global $Config;
     // setup mysql config
     if (!empty($Config['config_mysql']) and file_exists('config/mysql.' . $Config['config_mysql'] . '.php')) {
         $conf = _load_php_vars('config/mysql.' . $Config['config_mysql'] . '.php');
         $this->host = !empty($conf['host']) ? $conf['host'] : 'localhost';
         $this->db = !empty($conf['dbname']) ? $conf['dbname'] : 'moniwiki';
         $this->user = !empty($conf['user']) ? $conf['user'] : '******';
         $this->passwd = !empty($conf['passwd']) ? $conf['passwd'] : '';
     } else {
         $host = !empty($Config['mysql_host']) ? $Config['mysql_host'] : 'localhost';
         $this->host = $host;
         $this->db = !empty($Config['mysql_dbname']) ? $Config['mysql_dbname'] : 'moniwiki';
         $this->user = !empty($Config['mysql_user']) ? $Config['mysql_user'] : '******';
         $this->passwd = !empty($Config['mysql_passwd']) ? $Config['mysql_passwd'] : '';
     }
     // set default pages_limit
     $this->pages_limit = isset($Config['pages_limit']) ? $Config['pages_limit'] : $this->pages_limit;
     $this->charset = strtolower($Config['charset']);
     register_shutdown_function(array(&$this, 'close'));
 }
コード例 #2
0
ファイル: bbs.php プロジェクト: ahastudio/moniwiki
function do_bbs($formatter, $options = array())
{
    global $DBInfo;
    $err = '';
    $args = array();
    if ($options['mode'] == 'rss') {
        #$formatter->send_header("Content-Type: text/xml",$options);
        header("Content-Type: application/xml");
        print macro_BBS($formatter, '', $options);
        return;
    }
    # load a config file
    $bname = $formatter->page->name;
    $conf0 = array();
    if (file_exists('config/bbs.' . $bname . '.php')) {
        $confname = 'bbs.' . $bname . '.php';
        $conf0 = _load_php_vars('config/bbs.default.php');
    } else {
        $confname = 'bbs.default.php';
    }
    $conf = _load_php_vars('config/' . $confname);
    $conf = array_merge($conf0, $conf);
    # check valid IP
    $check_ip = true;
    if ($conf['allowed_ip'] and in_array($options['mode'], array('edit', 'delete', 'new'))) {
        include_once 'lib/checkip.php';
        if (!check_ip($conf['allowed_ip'], $_SERVER['REMOTE_ADDR'])) {
            $options['title'] = sprintf(_("Your IP address is not allowed to %s at this BBS"), $options["mode"]);
            $check_ip = false;
        }
    }
    $check_pass = false;
    $MyBBS = macro_BBS($formatter, '', array('new' => 1));
    if ($options['id'] != 'Anonymous' and $options['mode'] == 'edit' and $options['no']) {
        $body = $MyBBS->getPage($options['no']);
        if ($body != null) {
            include_once 'lib/metadata.php';
            list($metas, $dummy) = _get_metadata($body);
            if ($metas['Name'] == $options['id']) {
                # XXX
                $check_pass = true;
            }
        }
    }
    # password check
    while ($options['no'] and ($options['mode'] == 'delete' or $options['mode'] == 'edit') and $_SERVER['REQUEST_METHOD'] == "POST") {
        # check admin(WikiMaster) password
        if (!$check_pass) {
            if ($DBInfo->admin_passwd) {
                $check_pass = $DBInfo->admin_passwd == crypt($options['pass'], $DBInfo->admin_passwd);
            } else {
                $check_pass = false;
            }
        }
        # check admin(BBSMaster) password
        if (!$check_pass and $conf['admin_passwd']) {
            $check_pass = $conf['admin_passwd'] == crypt($options['pass'], $conf['admin_passwd']);
        }
        while ($check_ip and $check_pass and $options['mode'] == 'delete') {
            if (($p = strpos($options['no'], ' ')) !== false) {
                $nids = explode(" ", $options['no']);
            } else {
                $nids = array($options['no']);
            }
            for ($i = 0, $sz = sizeof($nids); $i < $sz; $i++) {
                if ($MyBBS->hasPage($nids[$i])) {
                    $MyBBS->deletePage($nids[$i]);
                } else {
                    $MyBBS->deleteIndex($nids[$i]);
                }
            }
            $query = $options['p'] ? '&p=' . $options['p'] : '';
            $myrefresh = '';
            if ($DBInfo->use_save_refresh) {
                $sec = $DBInfo->use_save_refresh - 1;
                $lnk = $formatter->link_url($formatter->page->urlname, '?' . ($query ? $query : 'action=show'));
                $myrefresh = 'Refresh: ' . $sec . '; url=' . qualifiedURL($lnk);
            }
            $options['msg'] = _("Successfully deleted.");
            $header = array("Expires: " . gmdate("D, d M Y H:i:s", 0) . " GMT");
            if ($myrefresh) {
                $header[] = $myrefresh;
            }
            $formatter->send_header($header, $options);
            $formatter->send_title("", "", $options);
            $formatter->send_footer("", $options);
            return;
        }
        break;
    }
    while ($options['mode'] == 'comment' and $options['savetext'] and $_SERVER['REQUEST_METHOD'] == "POST") {
        $query = 'no=' . $options['no'] . ($options['p'] ? '&p=' . $options['p'] : '');
        $myrefresh = '';
        if ($DBInfo->use_save_refresh) {
            $sec = $DBInfo->use_save_refresh - 1;
            $lnk = $formatter->link_url($formatter->page->urlname, '?' . $query);
            $myrefresh = 'Refresh: ' . $sec . '; url=' . qualifiedURL($lnk);
        }
        $header = array("Expires: " . gmdate("D, d M Y H:i:s", 0) . " GMT");
        if ($myrefresh) {
            $header[] = $myrefresh;
        }
        $p = new WikiPage($options['page'] . ':' . $options['no'], $options);
        $formatter->page = $p;
        $options['page'] = $options['page'] . ':' . $options['no'];
        $options['minor'] = 1;
        # do not log
        $formatter->send_header($header, $options);
        $options['action_mode'] = 'ajax';
        $options['call'] = 1;
        $ret = $formatter->ajax_repl('comment', $options);
        if ($ret == false) {
            $options['msg'] = _("Fail to post comment.");
        }
        unset($options['action_mode']);
        $formatter->send_title("", "", $options);
        $formatter->send_footer("", $options);
        return;
        break;
    }
    if ($options['mode'] == 'delete') {
        $msg = sprintf(_("The article %s will be deleted."), $options['no']);
        $url = $formatter->link_url($formatter->page->urlname, '');
        $header = array("Expires: " . gmdate("D, d M Y H:i:s", 0) . " GMT");
        $formatter->send_header($header, $options);
        $formatter->send_title("", "", $options);
        print <<<EOF
<div class='deleteDialog'>
<form method='post' action='{$url}' >
<strong>{$msg}</strong>
<table border='0' width='20%'>
<tbody>
<tr><th>Password:</th><td><input type='password' style="width:200px" name='pass' /></td></tr>
</tbody>
</table>
<input type='hidden' name='no' value='{$options['no']}' />
<input type='hidden' name='p' value='{$options['p']}' />
<input type='hidden' name='action' value='bbs' />
<input type='hidden' name='mode' value='delete' />
</form>
</div>
EOF;
        $formatter->send_footer("", $options);
        return;
    } else {
        if ($options['mode'] == 'edit') {
            $button_preview = $options['button_preview'];
            while ($_SERVER['REQUEST_METHOD'] == "POST") {
                $savetext = $options['savetext'];
                $datestamp = $options['datestamp'];
                $subject = $options['subject'];
                # strip some tags from the subject
                $subject = preg_replace("%</?(marquee|embed|object|script|form|frame|iframe|img|a|)[^>]*>%", '', $subject);
                $args['subject'] = _stripslashes($subject);
                if ($options['id'] == 'Anonymous') {
                    $name = $options['name'];
                    $name = strip_tags($name);
                    $pass = $options['pass'];
                    $home = $options['homepage'];
                    # check a homepage address
                    if (!empty($home)) {
                        if (!preg_match('/^((ftp|http|news):\\/\\/)[a-z0-9][a-z0-9_\\-]+\\.[a-z0-9\\-\\.]+.*/', $home)) {
                            $options['msg'] = _("Invalid HomePage address.");
                            break;
                        } else {
                            if (!eregi("^(ftp|http|news):\\/\\/", $home)) {
                                $home = "http://" . $home;
                            }
                        }
                    }
                    # check email address
                    $email = $options['email'];
                    $args['name'] = _stripslashes($name);
                    $args['pass'] = _stripslashes($pass);
                    $args['home'] = _stripslashes($home);
                    $args['email'] = _stripslashes($email);
                    if (!$name) {
                        $options['msg'] = _("No Name error.");
                        break;
                    }
                } else {
                    $args['name'] = $options['id'];
                }
                $args['no'] = $options['no'] ? $options['no'] : 0;
                if ($options['no'] and !$check_pass) {
                    break;
                }
                # edit mode
                if (!$check_ip) {
                    break;
                }
                # not allowed IPs
                if (!$args['subject'] or !$savetext) {
                    $options['msg'] = _("No Subject error.");
                    break;
                }
                if ($button_preview) {
                    break;
                }
                $savetext = preg_replace("/\r\n|\r/", "\n", $savetext);
                if ($savetext and $DBInfo->spam_filter) {
                    $text = $savetext;
                    $fts = preg_split('/(\\||,)/', $DBInfo->spam_filter);
                    foreach ($fts as $ft) {
                        $text = $formatter->filter_repl($ft, $text, $options);
                    }
                    if ($text != $savetext) {
                        $options['msg'] = _("Sorry, can not save page because some messages are blocked in this wiki.");
                        break;
                    }
                }
                $savetext = rtrim($savetext) . "\n";
                $args['text'] = _stripslashes($savetext);
                $MyBBS = macro_BBS($formatter, '', array('new' => 1));
                $myrefresh = '';
                if ($DBInfo->use_save_refresh) {
                    $sec = $DBInfo->use_save_refresh - 1;
                    $lnk = $formatter->link_url($formatter->page->urlname, "?action=show");
                    $myrefresh = 'Refresh: ' . $sec . '; url=' . qualifiedURL($lnk);
                }
                $header = array("Expires: " . gmdate("D, d M Y H:i:s", 0) . " GMT");
                $options['msg'] = _("New post added successfully");
                if ($myrefresh) {
                    $header[] = $myrefresh;
                }
                $formatter->send_header($header, $options);
                $formatter->send_title("", "", $options);
                if ($MyBBS->use_attach) {
                    # XXX
                    $args['call'] = 1;
                    $lists = array();
                    $lists = $formatter->macro_repl('Attachments', '', $args);
                    unset($args['call']);
                    if (!empty($lists)) {
                        $args['attach'] = $lists;
                    }
                }
                $MyBBS->savePage($args);
                $formatter->send_footer("", $options);
                return;
            }
            #print _bbs_edit_form();
            #print macro_BBSForm($formatter);
            $formatter->send_header("", $options);
            $formatter->send_title("", "", $options);
            if ($options['savetext']) {
                $formatter->_raw_body = $options['savetext'];
                if ($options['no']) {
                    $hidden = "<input type='hidden' name='no' value='{$options['no']}' />\n" . "<input type='hidden' name='p' value='{$options['p']}' />";
                }
            } else {
                if ($options['no']) {
                    $MyBBS = macro_BBS($formatter, '', array('new' => 1));
                    $nid = $options['no'];
                    if ($nid and $MyBBS->hasPage($nid)) {
                        $fields = array('Name', 'Subject', 'Date', 'Email', 'HomePage', 'IP', 'Keywords');
                        include_once 'lib/metadata.php';
                        $body = $MyBBS->getPage($nid);
                        $boundary = strtoupper(md5("COMMENT"));
                        # XXX
                        list($body, $comments) = explode('----' . $boundary . "\n", $body, 2);
                        # XXX
                        if ($body != null) {
                            list($metas, $nbody) = _get_metadata($body);
                            if ($nbody) {
                                $body = $nbody;
                            }
                            $args['name'] = $metas['Name'];
                            $args['subject'] = $metas['Subject'];
                            $args['home'] = $metas['HomePage'];
                            $args['email'] = $metas['Email'];
                            $args['text'] = $body;
                            $formatter->_raw_body = $body;
                            $hidden = "<input type='hidden' name='no' value='{$nid}' />\n" . "<input type='hidden' name='p' value='{$options['p']}' />";
                        }
                    }
                } else {
                    $formatter->_raw_body = "";
                }
            }
            if ($options['id'] == 'Anonymous') {
                $formatter->_extra_form = <<<EOF
<div>
<table border='0' width='100%'>
<col width='10%' /><col width='10%' /><col width='10%' /><col width='70%' />
<tbody>
<tr><th>Subject:</th><td colspan='3'><input type='text' style="width:80%" name='subject' value='{$args['subject']}' /></td></tr>
<tr><th>Name:</th><td><input type='text' name='name' value='{$args['name']}' /></td>
    <th>Password:</th><td><input type='password' name='pass' /></td></tr>
<tr><th>Email:</th><td colspan='3'><input type='text' style="width:50%" name='email' value='{$args['email']}' /></td></tr>
<tr><th>HomePage:</th><td colspan='3'><input type='text'style="width:50%" name='homepage' value='{$args['home']}' /></td></tr>
</tbody>
</table>
{$hidden}
</div>
EOF;
            } else {
                if (!$check_pass and !empty($options['no']) and $options['mode'] == 'edit') {
                    $pass_form = "<tr><th>Password:</th><td><input type='password' name='pass' /></td></tr>";
                }
                $formatter->_extra_form = <<<EOF
<div>
<table border='0' width='100%'>
<col width='20%' /><col width='80%' />
<tbody>
<tr><th>Subject:</th><td><input type='text' style="width:80%" name='subject' value='{$args['subject']}' /></td></tr>
{$pass_form}
</tbody>
</table>
{$hidden}
</div>
EOF;
            }
            $formatter->_mtime = 0;
            $options['simple'] = 2;
            $options['nocategories'] = 1;
            $options['minor'] = 1;
            # do not show a minor checkbox
            print macro_EditText($formatter, $value, $options);
            $formatter->_raw_body = null;
            $formatter->_extra_form = null;
        } else {
            $formatter->send_header("", $options);
            $formatter->send_title("", "", $options);
            print macro_BBS($formatter, 'no=' . $options['no']);
        }
    }
    $formatter->send_footer("", $options);
    return;
}
コード例 #3
0
ファイル: wikifarm.base.php プロジェクト: ahastudio/moniwiki
    static function setup($host, $conf = array())
    {
        // setup Virtual directory and name
        if ($conf['wikifarm_hostrule'] && $conf['wikifarm_farm_dir'] && false !== ($trans = self::is_valid_farmname($conf['wikifarm_hostrule'], $host))) {
            $farm_dir = self::format_string($trans, $conf['wikifarm_farm_dir']);
            // check already saved config file
            if (file_exists($farm_dir . '/config.php')) {
                $vars = _load_php_vars($farm_dir . '/config.php', $conf);
                if (!empty($vars['text_dir'])) {
                    return $vars;
                }
            }
        } else {
            return false;
        }
        // create directory structure automatically.
        if ($conf['wikifarm_autocreate'] && !is_dir($farm_dir)) {
            $ret = self::create_dirs($farm_dir, $conf);
            if (is_string($ret)) {
                return $ret;
            }
        }
        // Assing dirs for wikifarm host
        $text_dir = $farm_dir . '/text';
        $cache_dir = $farm_dir . '/cache';
        // Fill wikifarm sitename if it is defined.
        if (!empty($conf['wikifarm_sitename'])) {
            $sitename = self::format_string($trans, $conf['wikifarm_sitename']);
        }
        // Set the editlog file
        $editlog_name = self::get_editlog($farm_dir);
        if (is_dir($farm_dir)) {
            // Assing config variables
            $vars = array();
            $vars['farm_dir'] = $farm_dir;
            $vars['text_dir'] = $text_dir;
            $vars['cache_dir'] = $cache_dir;
            $vars['sitename'] = $sitename;
            $vars['editlog_name'] = $editlog_name;
            $date = date('Y-m-d h:i:s');
            $lines = array();
            $lines[] = '<' . '?php' . "\n";
            $lines[] = <<<HEADER
// This is a config.php file for this wiki farm
// {$date} by monisetup.php

HEADER;
            foreach ($vars as $k => $v) {
                if ($k != 'farm_dir') {
                    $v = str_replace($farm_dir, '$farm_dir', $v);
                }
                $lines[] = '$' . $k . '="' . $v . '"' . ";\n";
            }
            // write config.php
            $fp = fopen($farm_dir . '/config.php', 'w');
            if (is_resource($fp)) {
                fwrite($fp, implode('', $lines));
                fclose($fp);
            }
            return $vars;
        } else {
            // No farm_dir for wikifarm host
            return "The directories for this Wiki is not created yet.<br />\n" . "Make sure there is no typo in the URL and ask the administrator";
        }
        return false;
    }
コード例 #4
0
ファイル: wiki.php プロジェクト: sedrion/moniwiki
 function include_theme($theme, $file = 'default', $params = array())
 {
     $theme = trim($theme, '.-_');
     $theme = preg_replace(array('/\\/+/', '/\\.+/'), array('/', ''), $theme);
     if (preg_match('/_tpl$/', $theme)) {
         $type = 'tpl';
     } else {
         $type = 'php';
     }
     $theme_dir = 'theme/' . $theme;
     if (file_exists($theme_dir . "/theme.php")) {
         $this->_vars['_theme'] = _load_php_vars($theme_dir . "/theme.php", $params);
     }
     $theme_path = $theme_dir . '/' . $file . '.' . $type;
     if (!file_exists($theme_path)) {
         trigger_error(sprintf(_("File '%s' does not exist."), $file), E_USER_NOTICE);
         return '';
     }
     switch ($type) {
         case 'tpl':
             $params['path'] = $theme_path;
             $out = $this->processor_repl('tpl_', '', $params);
             break;
         case 'php':
             global $Config;
             $TPL_VAR =& $this->_vars;
             if (isset($TPL_VAR['_theme']) and is_array($TPL_VAR['_theme']) and $TPL_VAR['_theme']['compat']) {
                 extract($TPL_VAR);
             }
             if ($params['print']) {
                 $out = (include $theme_path);
             } else {
                 ob_start();
                 include $theme_path;
                 $out = ob_get_contents();
                 ob_end_clean();
             }
             break;
         default:
             break;
     }
     return $out;
 }
コード例 #5
0
ファイル: html2pdf.php プロジェクト: ahastudio/moniwiki
function do_html2pdf($formatter, $options)
{
    global $DBInfo, $Config;
    $conf = _load_php_vars("config/html2pdf.php");
    $libdir = !empty($conf['tcpdf_dir']) ? $conf['tcpdf_dir'] : 'tcpdf';
    $k_path_install = 'lib/' . $libdir . '/';
    # required for config/tcpdf.php
    @(require_once 'config/tcpdf.php');
    @(require_once 'lib/' . $libdir . '/config/lang/eng.php');
    @(require_once 'lib/' . $libdir . '/tcpdf.php');
    if (!class_exists('TCPDF')) {
        $options['title'] = _("The TCPDF class not found!");
        return do_invalid($formatter, $options);
    }
    if (!class_exists('XTCPDF')) {
        class XTCPDF extends TCPDF
        {
            var $toc = array();
            var $fontalias = array();
            function setFontAlias($alias)
            {
                $this->fontalias = array();
                foreach ($alias as $k => $v) {
                    array_push($this->fontlist, $k);
                }
                $this->fontalias = $alias;
            }
            function AddFont($family, $style = '', $fontfile = '')
            {
                $family = trim($family);
                if (!empty($family) and array_key_exists($family, $this->fontalias)) {
                    $family = strtolower($family);
                    $fontfile = $family;
                    $name = $this->fontalias[$family];
                    $fontfile = $this->fontalias[$family] . '.php';
                    $fontdata = parent::AddFont($family, $style, $fontfile);
                    $key = $fontdata['fontkey'];
                    if ($this->fonts[$key]['type'] == 'core') {
                        $this->fonts[$key]['name'] = $this->CoreFonts[$name];
                    }
                    return $fontdata;
                }
                return parent::AddFont($family, $style, $fontfile);
            }
            function getHtmlDomArray($html)
            {
                $html = preg_replace('@<title>.*</title>@', '', $html);
                $html = preg_replace('@<head>.*</head>@s', '', $html);
                $html = preg_replace('@&quot;@', '"', $html);
                #$html = preg_replace('@>\s+<@',"><",$html);
                $html = preg_replace('@>\\n@', ">", $html);
                $html = preg_replace('@/\\*<\\!\\[CDATA\\[.*\\]\\]>\\*/\\n?@Us', '', $html);
                $html = preg_replace('@<pre[^>]*>@', '<pre style="background-color:black;color:white">', $html);
                $dom =& parent::getHtmlDomArray($html);
                $sz = count($dom);
                for ($i = 0; $i < $sz; $i++) {
                    $tag =& $dom[$i];
                    if (!empty($tag['opening']) and $tag['value'] == 'table') {
                        #$tag['attribute']['border']=1;
                        #$tag['attribute']['bgcolor']=array(200,200,200);
                        #$tag['bgcolor']=array(200,200,200);
                        #} else if (!empty($tag['opening']) and $tag['value']=='pre') {
                        #    $tag['bgcolor']=array(0,0,0);
                        #    $tag['fgcolor']=array(255,255,255);
                        #    $tag['fontname']='courier';
                        #} else if (!empty($tag['opening']) and $tag['value']=='div') {
                        #    $tag['bgcolor']=array(100,100,100);
                    }
                }
                #print "<pre>";
                #print_r($dom);
                #print "</pre>";
                return $dom;
            }
            function closeHTMLTagHandler(&$dom, $key, $cell = false)
            {
                $tag = $dom[$key];
                switch ($tag['value']) {
                    case 'h1':
                    case 'h2':
                    case 'h3':
                    case 'h4':
                    case 'h5':
                    case 'h6':
                        $i = $key;
                        $txt = '';
                        while ($dom[--$i]['value'] != $tag['value'] and $i > 0) {
                            if (!isset($dom[$i]['opening'])) {
                                $txt = $dom[$i]['value'] . $txt;
                            }
                        }
                        $num = key($this->toc);
                        $dep = count(explode('.', $num));
                        $this->Bookmark($num . ' ' . $this->toc[$num], $dep, $this->y);
                        next($this->toc);
                }
                parent::closeHTMLTagHandler($dom, $key, $cell);
            }
        }
    }
    // define the share directory to create img
    define('X_PATH_SHARE_IMG', $DBInfo->cache_public_dir . '/html2pdf/');
    if (!file_exists(X_PATH_SHARE_IMG)) {
        _mkdir_p(X_PATH_SHARE_IMG, 0777);
    }
    // XXX
    $formatter->nonexists = 'always';
    $formatter->section_edit = 0;
    $formatter->perma_icon = '';
    ob_start();
    $formatter->send_header();
    $formatter->send_page('', array('fixpath' => 1));
    print '</body></html>';
    $html = ob_get_contents();
    ob_end_clean();
    # begin
    $pdf = new XTCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, $DBInfo->charset);
    include_once 'function/toc.php';
    $toc = function_toc($formatter);
    $pdf->toc = $toc;
    $pdf->setFontAlias(array('monospace' => 'courier'));
    #$pdf->setLIsymbol(chr(42));
    #$pdf->setLIsymbol('a');
    // set default header data
    // $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
    $pdf->SetHeaderData($DBInfo->logo_img, 20, $formatter->page->name);
    $pdf->SetTitle($formatter->page->name);
    # $pdf->SetAuthor('Your name');
    $pdf->SetCreator('TCPDF/MoniWiki');
    $pdf->SetSubject($formatter->page->name);
    if (!empty($formatter->pi['#keywords'])) {
        $pdf->SetKeywords($keywords = $formatter->pi['#keywords']);
    }
    // load default font
    $pdf->AddFont($conf['default_unifont']);
    $pdf->SetFont($conf['default_font']);
    // set header and footer fonts
    // $pdf->setHeaderFont(Array($conf['default_unifont'], '', PDF_FONT_SIZE_MAIN));
    $pdf->setHeaderFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
    $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
    //set margins
    $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
    $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
    $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
    //set auto page breaks
    $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
    //set some language-dependent strings
    $pdf->setLanguageArray($l);
    //set image scale factor
    //$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
    # initialize document
    $pdf->AliasNbPages();
    # add a page
    $pdf->AddPage();
    $pdf->Bookmark($formatter->page->name, 0, 0);
    #
    $pdf->writeHTML($html, true, 0, false, false);
    # output
    $pdf->output(date("Ymd", time()) . '.pdf', 'I');
    return;
}