Ejemplo n.º 1
0
function section_list($message = '')
{
    pagetop(gTxt('sections'), $message);
    global $url_mode, $txpac, $wlink;
    $out[] = tr(tdcs(strong(gTxt('section_head')) . popHelp('section_category'), 3));
    $out[] = tr(tdcs(form(fInput('text', 'name', '', 'edit', '', '', 10) . fInput('submit', '', gTxt('Create'), 'smallerbox') . eInput('section') . sInput('section_create')), 3));
    $pageslist = safe_column("name", "txp_page", "1");
    $styleslist = safe_column("name", "txp_css", "1");
    $rs = safe_rows("*", "txp_section", "name!='' order by name");
    if ($rs) {
        foreach ($rs as $a) {
            extract($a);
            if ($name == 'default') {
                continue;
            }
            if ($url_mode) {
                $wlink = !check_sections($name) ? sp . wLink('section', 'missing_section_file', 'name', $name) : '';
            }
            $deletelink = dLink('section', 'section_delete', 'name', $name, '', 'type', 'section');
            $form = startTable('edit') . stackRows(fLabelCell(gTxt('section_name') . ':') . fInputCell('name', $name, 1, 20), fLabelCell(gTxt('uses_page') . ':') . td(selectInput('page', $pageslist, $page) . popHelp('section_uses_page'), '', 'noline'), fLabelCell(gTxt('uses_style') . ':') . td(selectInput('css', $styleslist, $css) . popHelp('section_uses_css'), '', 'noline'), fLabelCell(gTxt('selected_by_default') . '?') . td(yesnoradio('is_default', $is_default) . popHelp('section_is_default'), '', 'noline'), fLabelCell(gTxt('on_front_page') . '?') . td(yesnoradio('on_frontpage', $on_frontpage) . popHelp('section_on_frontpage'), '', 'noline'), fLabelCell(gTxt('syndicate') . '?') . td(yesnoradio('in_rss', $in_rss) . popHelp('section_syndicate'), '', 'noline'), fLabelCell(gTxt('include_in_search') . '?') . td(yesnoradio('searchable', $searchable) . popHelp('section_searchable'), '', 'noline'), tda(fInput('submit', '', gTxt('save_button'), 'smallerbox'), ' colspan="2" style="border:0"')) . endTable() . eInput('section') . sInput('section_save') . hInput('old_name', $name);
            $form = form($form);
            $out[] = tr(td($name . $wlink) . td($form) . td($deletelink));
        }
    }
    echo startTable('list') . join('', $out) . endTable();
}
Ejemplo n.º 2
0
function sec_section_list($message = '')
{
    pagetop(gTxt('sections'), $message);
    global $wlink;
    $pageslist = safe_column("name", "txp_page", "1=1");
    $styleslist = safe_column("name", "txp_css", "1=1");
    $out[] = tr(tdcs(strong(gTxt('section_head')) . popHelp('section_category'), 3));
    $out[] = tr(tdcs(form(fInput('text', 'name', '', 'edit', '', '', 10) . fInput('submit', '', gTxt('Create'), 'smallerbox') . eInput('section') . sInput('section_create')), 3));
    $defrow = safe_row("page, css", "txp_section", "name like 'default'");
    $out[] = form(tr(td(gTxt('default')) . td(startTable('edit', 'left', '') . tr(fLabelCell(gTxt('uses_page') . ':') . td(selectInput('page', $pageslist, $defrow['page']) . popHelp('section_uses_page'), '', 'noline')) . tr(fLabelCell(gTxt('uses_style') . ':') . td(selectInput('css', $styleslist, $defrow['css']) . popHelp('section_uses_css'), '', 'noline')) . tr(tda(fInput('submit', '', gTxt('save_button'), 'smallerbox'), ' colspan="2" style="border:0"')) . endTable()) . td()) . eInput('section') . sInput('section_save') . hInput('name', 'default'));
    $rs = safe_rows_start("*", "txp_section", "name!='' order by name");
    if ($rs) {
        while ($a = nextRow($rs)) {
            extract($a);
            if ($name == 'default') {
                continue;
            }
            $deletelink = dLink('section', 'section_delete', 'name', $name, '', 'type', 'section');
            $form = startTable('edit') . stackRows(fLabelCell(gTxt('section_name') . ':') . fInputCell('name', $name, 1, 20), fLabelCell(gTxt('section_longtitle') . ':') . fInputCell('title', $title, 1, 20), fLabelCell(gTxt('uses_page') . ':') . td(selectInput('page', $pageslist, $page) . popHelp('section_uses_page'), '', 'noline'), fLabelCell(gTxt('uses_style') . ':') . td(selectInput('css', $styleslist, $css) . popHelp('section_uses_css'), '', 'noline'), fLabelCell(gTxt('selected_by_default') . '?') . td(yesnoradio('is_default', $is_default) . popHelp('section_is_default'), '', 'noline'), fLabelCell(gTxt('on_front_page') . '?') . td(yesnoradio('on_frontpage', $on_frontpage) . popHelp('section_on_frontpage'), '', 'noline'), fLabelCell(gTxt('syndicate') . '?') . td(yesnoradio('in_rss', $in_rss) . popHelp('section_syndicate'), '', 'noline'), fLabelCell(gTxt('include_in_search') . '?') . td(yesnoradio('searchable', $searchable) . popHelp('section_searchable'), '', 'noline'), tda(fInput('submit', '', gTxt('save_button'), 'smallerbox'), ' colspan="2" style="border:0"')) . endTable() . eInput('section') . sInput('section_save') . hInput('old_name', $name);
            $form = form($form);
            $out[] = tr(td($name) . td($form) . td($deletelink));
        }
    }
    echo startTable('list') . join('', $out) . endTable();
}
Ejemplo n.º 3
0
function getDbInfo()
{
    $temp_txpath = dirname(__FILE__);
    $temp_doc_root = $_SERVER['DOCUMENT_ROOT'];
    echo '<form action="setup.php" method="post">', '<table id="setup" cellpadding="0" cellspacing="0" border="0">', tr(tda(hed('Welcome to Textpattern', 3) . graf('Inevitably, we need a few details.', ' style="margin-bottom:3em"') . hed('MySQL', 3) . graf('Note that the database you specify must exist; 
			  		Textpattern won&#8217;t create it for you.'), ' width="400" height="50" colspan="4", align="left"')), tr(fLabelCell('MySQL login') . fInputCell('duser', '', 1) . fLabelCell('MySQL password') . fInputCell('dpass', '', 2)), tr(fLabelCell('MySQL server') . fInputCell('dhost', '', 3) . fLabelCell('MySQL database') . fInputCell('ddb', '', 4)), tr(fLabelCell('Table prefix') . fInputCell('dprefix', '', 5) . tdcs(small('(Use ONLY for multiple installations in one database)'), 2)), tr(tdcs('&nbsp;', 4)), tr(tdcs(hed('Site Paths', 3) . graf('Please confirm the following paths to your site root and to the Textpattern directory.'), 4)), tr(fLabelCell('Full path to server\'s web root') . tdcs(fInput('text', 'doc_root', $temp_doc_root, 'edit', '', '', 40) . popHelp('doc_root'), 3)), tr(fLabelCell('Full path to Textpattern') . tdcs(fInput('text', 'txpath', $temp_txpath, 'edit', '', '', 40) . popHelp('full_path'), 3));
    echo tr(td() . td(fInput('submit', 'Submit', 'Next', 'publish')) . td() . td());
    echo endTable(), sInput('printConfig'), '</form>';
}
Ejemplo n.º 4
0
function getDbInfo()
{
    $lang = isPost('lang');
    $GLOBALS['textarray'] = setup_load_lang($lang);
    @(include './config.php');
    if (!empty($txpcfg['db'])) {
        exit(graf(gTxt('already_installed')));
    }
    $temp_txpath = dirname(__FILE__);
    if (@$_SERVER['SCRIPT_NAME'] && (@$_SERVER['SERVER_NAME'] || @$_SERVER['HTTP_HOST'])) {
        $guess_siteurl = @$_SERVER['SERVER_NAME'] ? $_SERVER['SERVER_NAME'] : $_SERVER['HTTP_HOST'];
        $guess_siteurl .= rtrim(dirname(dirname($_SERVER['SCRIPT_NAME'])), '/');
    } else {
        $guess_siteurl = 'mysite.com';
    }
    echo '<form action="setup.php" method="post">', '<table id="setup" cellpadding="0" cellspacing="0" border="0">', tr(tda(hed(gTxt('welcome_to_textpattern'), 3) . graf(gTxt('need_details'), ' style="margin-bottom:3em"') . hed('MySQL', 3) . graf(gTxt('db_must_exist')), ' width="400" height="50" colspan="4" align="left"')), tr(fLabelCell(gTxt('mysql_login')) . fInputCell('duser', '', 1) . fLabelCell(gTxt('mysql_password')) . fInputCell('dpass', '', 2)), tr(fLabelCell(gTxt('mysql_server')) . fInputCell('dhost', '', 3) . fLabelCell(gTxt('mysql_database')) . fInputCell('ddb', '', 4)), tr(fLabelCell(gTxt('table_prefix')) . fInputCell('dprefix', '', 5) . tdcs(small(gTxt('prefix_warning')), 2)), tr(tdcs('&nbsp;', 4)), tr(tdcs(hed(gTxt('site_path'), 3) . graf(gTxt('confirm_site_path')), 4)), tr(fLabelCell(gTxt('full_path_to_txp')) . tdcs(fInput('text', 'txpath', $temp_txpath, 'edit', '', '', 40) . popHelp('full_path'), 3)), tr(tdcs('&nbsp;', 4)), tr(tdcs(hed(gTxt('site_url'), 3) . graf(gTxt('please_enter_url')), 4)), tr(fLabelCell('http://') . tdcs(fInput('text', 'siteurl', $guess_siteurl, 'edit', '', '', 40) . popHelp('site_url'), 3));
    echo tr(td() . td(fInput('submit', 'Submit', gTxt('next'), 'publish')) . td() . td());
    echo endTable(), hInput('lang', $lang), sInput('printConfig'), '</form>';
}
Ejemplo n.º 5
0
function getDbInfo()
{
    $GLOBALS['textarray'] = setup_load_lang(ps('lang'));
    @(include txpath . '/config.php');
    if (!empty($txpcfg['db'])) {
        exit(graf(gTxt('already_installed', array('{txpath}' => txpath))));
    }
    if (@$_SERVER['SCRIPT_NAME'] && (@$_SERVER['SERVER_NAME'] || @$_SERVER['HTTP_HOST'])) {
        $guess_siteurl = @$_SERVER['HTTP_HOST'] ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'];
        $guess_siteurl .= $GLOBALS['rel_siteurl'];
    } else {
        $guess_siteurl = 'mysite.com';
    }
    echo '<form action="' . $GLOBALS['rel_siteurl'] . '/textpattern/setup/index.php" method="post">', '<table id="setup" cellpadding="0" cellspacing="0" border="0">', tr(tda(hed(gTxt('welcome_to_textpattern'), 3) . graf(gTxt('need_details'), ' style="margin-bottom:3em"') . hed('MySQL', 3) . graf(gTxt('db_must_exist')), ' width="400" height="50" colspan="4" align="left"')), tr(fLabelCell(gTxt('mysql_login')) . fInputCell('duser', '', 1) . fLabelCell(gTxt('mysql_password')) . fInputCell('dpass', '', 2)), tr(fLabelCell(gTxt('mysql_server')) . fInputCell('dhost', 'localhost', 3) . fLabelCell(gTxt('mysql_database')) . fInputCell('ddb', '', 4)), tr(fLabelCell(gTxt('table_prefix')) . fInputCell('dprefix', '', 5) . tdcs(small(gTxt('prefix_warning')), 2)), tr(tdcs('&nbsp;', 4)), tr(tdcs(hed(gTxt('site_url'), 3) . graf(gTxt('please_enter_url')), 4)), tr(fLabelCell('http://') . tdcs(fInput('text', 'siteurl', $guess_siteurl, 'edit', '', '', 40) . popHelp('siteurl'), 3));
    if (!is_callable('mail')) {
        echo tr(tdcs(gTxt('warn_mail_unavailable'), 3, null, '" style="color:red;text-align:center'));
    }
    echo tr(td() . td(fInput('submit', 'Submit', gTxt('next'), 'publish')) . td() . td());
    echo endTable(), hInput('lang', LANG), sInput('printConfig'), '</form>';
}
Ejemplo n.º 6
0
function image_list($message = '')
{
    global $txpcfg, $extensions, $path_from_root, $img_dir;
    $pfr = $path_from_root;
    extract($txpcfg);
    extract(get_prefs());
    pagetop(gTxt('image'), $message);
    echo pageby_form('image', $article_list_pageby);
    echo startTable('list'), tr(tda(upload_form(gTxt('upload_file'), gTxt('upload'), 'image_insert'), ' colspan="4" style="border:0"')), tr(hCell(ucfirst(gTxt('name'))) . hCell(gTxt('image_category')) . hCell(gTxt('tags')) . hCell(gTxt('author')) . hCell(gTxt('thumbnail')) . hCell());
    $page = gps('page');
    $total = getCount('txp_image', "1");
    $limit = 15;
    $numPages = ceil($total / $limit);
    $page = !$page ? 1 : $page;
    $offset = ($page - 1) * $limit;
    $nav[] = $page > 1 ? PrevNextLink("image", $page - 1, gTxt('prev'), 'prev') : '';
    $nav[] = sp . small($page . '/' . $numPages) . sp;
    $nav[] = $page != $numPages ? PrevNextLink("image", $page + 1, gTxt('next'), 'next') : '';
    $rs = safe_rows("*", "txp_image", "1 order by category,name limit {$offset},{$limit}");
    if ($rs) {
        foreach ($rs as $a) {
            extract($a);
            $thumbnail = $thumbnail ? '<img src="' . $pfr . $img_dir . '/' . $id . 't' . $ext . '" />' : gTxt('no');
            $elink = eLink('image', 'image_edit', 'id', $id, $name);
            $txtilelink = '<a target="_blank" href="?event=tag' . a . 'name=image' . a . 'id=' . $id . a . 'ext=' . $ext . a . 'alt=' . $alt . a . 'h=' . $h . a . 'w=' . $w . a . 'type=textile" onclick="window.open(this.href, \'popupwindow\', \'width=400,height=400,scrollbars,resizable\'); return false;">Textile</a>';
            $txplink = '<a target="_blank" href="?event=tag' . a . 'name=image' . a . 'id=' . $id . a . 'type=textpattern" onclick="window.open(this.href, \'popupwindow\', \'width=400,height=400,scrollbars,resizable\'); return false;">Textpattern</a>';
            $xhtmlink = '<a target="_blank" href="?event=tag' . a . 'name=image' . a . 'id=' . $id . a . 'ext=' . $ext . a . 'h=' . $h . a . 'w=' . $w . a . 'type=xhtml" onclick="window.open(this.href, \'popupwindow\', \'width=400,height=400,scrollbars,resizable\'); return false;">XHTML</a>';
            $dlink = dLink('image', 'image_delete', 'id', $id);
            echo tr(td($elink) . td($category) . td($txtilelink . ' / ' . $txplink . ' / ' . $xhtmlink) . td($author) . td($thumbnail) . td($dlink, 10));
        }
        echo tr(tdcs(graf(join('', $nav)), 4));
    }
    echo endTable();
    $imgdir = $doc_root . $path_from_root . $img_dir;
    if (!is_dir($imgdir) or !is_writeable($imgdir)) {
        echo graf(str_replace("{imgdir}", $imgdir, gTxt('img_dir_not_writeable')), ' style="text-align:center;color:red"');
    }
}
Ejemplo n.º 7
0
function discuss_list($message = '')
{
    global $timeoffset;
    pagetop(gTxt('list_discussions'), $message);
    extract(doSlash(gpsa(array('page', 'crit'))));
    extract(get_prefs());
    $total = safe_count('txp_discuss', "1");
    $limit = $comment_list_pageby;
    $numPages = ceil($total / $limit);
    $page = !$page ? 1 : $page;
    $offset = ($page - 1) * $limit;
    $nav[] = $page > 1 ? PrevNextLink("discuss", $page - 1, gTxt('prev'), 'prev') : '';
    $nav[] = sp . small($page . '/' . $numPages) . sp;
    $nav[] = $page != $numPages ? PrevNextLink("discuss", $page + 1, gTxt('next'), 'next') : '';
    $criteria = $crit ? "message like '%{$crit}%'" : '1';
    $rs = safe_rows("*, unix_timestamp(posted) as uPosted", "txp_discuss", "{$criteria} order by posted desc limit {$offset},{$limit}");
    echo pageby_form('discuss', $comment_list_pageby);
    if ($rs) {
        echo '<form action="index.php" method="post" onsubmit="return verify(\'' . gTxt('are_you_sure') . '\')">', startTable('list'), assHead('date', 'name', 'message', 'parent', '');
        foreach ($rs as $a) {
            extract($a);
            $dmessage = $message;
            $name = !$visible ? '<span style="color:red">' . $name . '</span>' : $name;
            $date = "" . date("M d, g:ia", $uPosted + $timeoffset) . "";
            $editlink = eLink('discuss', 'discuss_edit', 'discussid', $discussid, $date);
            $cbox = fInput('checkbox', 'selected[]', $discussid);
            $tq = fetch('Title', 'textpattern', 'ID', $parentid);
            $parent = !$tq ? gTxt('article_deleted') : $tq;
            echo assRow(array($editlink => 100, $name => 100, $dmessage => 250, $parent => 100, $cbox => 20));
        }
        echo tr(tda(discuss_multiedit_form(), ' colspan="5" style="text-align:right;border:0px"'));
        echo endTable() . '</form>';
        echo startTable('edit'), tr(tda(graf('<a href="index.php?event=discuss' . a . 'step=ipban_list">' . gTxt('list_banned_ips') . '</a>'), ' valign="middle"') . td(form(fInput('text', 'crit', '', 'edit') . fInput('submit', 'search', gTxt('search'), 'smallbox') . eInput("discuss") . sInput("list"))) . tdcs(graf(join('', $nav)), 2)), endTable();
    } else {
        echo graf(gTxt('no_comments_recorded'), ' align="center"');
    }
}
function rss_admin_editlink($event, $step)
{
    global $rss_ae_cookie;
    include txpath . '/include/txp_prefs.php';
    if (!isset($rss_ae_cookie)) {
        $rss_ae_cookie = "rss_article_edit";
        $rs = safe_insert('txp_prefs', "name='rss_ae_cookie', val='{$rss_ae_cookie}', prefs_id='1'");
    }
    if (gps("add")) {
        safe_update("txp_prefs", "val = '" . addslashes(ps('rss_ae_cookie')) . "'", "name = 'rss_ae_cookie' and prefs_id ='1'");
        setcookie($rss_ae_cookie, $rss_ae_cookie, time() + 31536000, "/");
        header("Location: index.php?event=editlink");
    } else {
        if (gps("rem")) {
            safe_update("txp_prefs", "val = '" . addslashes(ps('rss_ae_cookie')) . "'", "name = 'rss_ae_cookie' and prefs_id ='1'");
            setcookie($rss_ae_cookie, $rss_ae_cookie, time() - 3600, "/");
            header("Location: index.php?event=editlink");
        }
    }
    pagetop("Edit Link");
    $aeset = isset($_COOKIE[$rss_ae_cookie]) ? "" : " not";
    $tdaStyle = ' style="text-align:right;vertical-align:middle"';
    echo form(startTable("list") . tr(tdcs(hed("Add/Remove Public Site Article Edit Link", 1), 2)) . tr(tda(graf('Cookie ' . $rss_ae_cookie . ' is' . $aeset . ' set.', ' align="center"'), ' colspan="2"')) . tr(tda(gTxt('Cookie Name:'), ' style="text-align:right;vertical-align:middle"') . tda(text_input("rss_ae_cookie", $rss_ae_cookie, '20'), ' ')) . tr(tda(graf(fInput("submit", "add", gTxt("Add Edit Link"), "publish") . fInput("submit", "rem", gTxt("Remove Edit Link"), "publish") . eInput("editlink"), ' align="center"'), ' colspan="2"')) . endTable());
}
Ejemplo n.º 9
0
function list_languages($message = '')
{
    global $prefs;
    require_once txpath . '/lib/IXRClass.php';
    pagetop(gTxt('update_languages'), $message);
    $client = new IXR_Client('http://rpc.textpattern.com');
    #$client->debug = true;
    echo startTable('list'), tr(tdcs(hed(gTxt('update_languages'), 1), 3)), tr(tdcs(sLink('prefs', 'prefs_list', gTxt('site_prefs')) . sp . sLink('prefs', 'advanced_prefs', gTxt('advanced_preferences')), '3'));
    if (!$client->query('tups.listLanguages', $prefs['blog_uid'])) {
        $files = get_lang_files();
        if (is_array($files) && !empty($files)) {
            foreach ($files as $file) {
                if ($fp = @fopen(txpath . '/lang/' . $file, 'r')) {
                    $firstline = fgets($fp, 4069);
                    fclose($fp);
                    if (strpos($firstline, '#@version') !== false) {
                        # Looks like: "#@version id;unixtimestamp"
                        @(list($fversion, $ftime) = explode(';', trim(substr($firstline, strpos($firstline, ' ', 1)))));
                        $note = "({$fversion} " . date("d. F Y", $ftime) . ")";
                    } else {
                        $note = "(outdated)";
                    }
                } else {
                    $note = '';
                }
                $code = substr($file, 0, 5);
                echo tr(tda(eLink('prefs', 'get_language', 'lang_code', $code, $code) . sp, ' style="text-align:right;vertical-align:middle"') . tda(eLink('prefs', 'get_language', 'lang_code', $code, gTxt('install'))) . tda($note));
            }
        }
        echo endTable();
        echo tag(gTxt('error') . ': could not connect to RPC server to check for updated languages. Please, try it again later.<br /> 
			If problem connecting to the RPC server persists, you can go to <a href="http://rpc.textpattern.com/lang/">http://rpc.textpattern.com/lang/</a>, download the
			desired language file and place it in the /lang/ directory of your textpattern install. Textpattern will try do the install using that file.', 'p', ' colspan="3" style="color:red;width:50%;margin: auto"');
    } else {
        $response = $client->getResponse();
        if (is_array($response)) {
            foreach ($response as $language) {
                # I'm affraid we need a value here for the language itself, not for each one of the rows
                $db_lastmod = safe_field('UNIX_TIMESTAMP(lastmod)', 'txp_lang', "lang='{$language['language']}' ORDER BY lastmod DESC");
                $updating = $db_lastmod ? 1 : 0;
                $remote_mod = gmmktime($language['lastmodified']->hour, $language['lastmodified']->minute, $language['lastmodified']->second, $language['lastmodified']->month, $language['lastmodified']->day, $language['lastmodified']->year);
                $updated = $updating && $db_lastmod >= $remote_mod ? 1 : 0;
                if ($updated) {
                    echo tr(tda(gTxt($language['language']) . sp, ' style="text-align:right;vertical-align:middle"') . tda(gTxt('updated')));
                } else {
                    echo tr(tda(gTxt($language['language']) . sp, $updating ? ' style="text-align:right;vertical-align:middle;color:red;"' : ' style="text-align:right;vertical-align:middle;"') . td(eLink('prefs', 'get_language', 'lang_code', $language['language'], $updating ? gTxt('update') : gTxt('install'), 'updating', "{$updating}")));
                }
            }
        }
        echo endTable();
    }
}
 /**
  * Render options page
  * @param  string $event the event being called
  * @param  string $step  the step being called
  */
 public function render_prefs($event, $step)
 {
     if ($step === 'update') {
         $this->update_prefs();
     }
     pageTop(gTxt('Multiple Image Upload'));
     // todo: show preflight/sanity errors if any
     // Generate Preferences Table
     $out = hed(gTxt('Multiple Image Upload - Preferences'), 1);
     $out .= startTable($this->prefix('preferences'), 'center', 5);
     foreach (self::$preferences as $key => $pref) {
         $out .= $this->render_pref($key, $pref);
     }
     // render save button
     $out .= tr(tdcs(eInput('plugin_prefs.' . self::$slug) . sInput('update') . fInput('submit', 'save', gTxt('save_button'), 'publish'), 3, '', 'nolin'));
     $out .= endtable();
     echo form($out);
 }
Ejemplo n.º 11
0
function tag_link_feed_link()
{
    global $step, $endform, $name;
    $invars = gpsa(array('label', 'category', 'limit', 'wraptag'));
    extract($invars);
    $label = !$label ? 'XML' : $label;
    $out = form(startTable('list') . tr(tdcs(hed('Link to XML Feed of Links', 3), 2)) . tagRow('label', fInput('text', 'label', $label, 'edit', '', '', 25)) . tagRow('wraptag', fInput('text', 'wraptag', $wraptag, 'edit', '', '', 2)) . tagRow('category', link_category_pop($category)) . tagRow('limit', fInput('text', 'limit', $limit, 'edit', '', '', 2)) . $endform);
    $out .= $step == 'build' ? tdb(tb($name, $invars)) : '';
    return $out;
}
Ejemplo n.º 12
0
function list_languages($message = '')
{
    global $prefs, $locale, $txpcfg, $textarray;
    require_once txpath . '/lib/IXRClass.php';
    // Select and save active language
    if (!$message && ps('step') == 'list_languages' && ps('language')) {
        $locale = doSlash(getlocale(ps('language')));
        safe_update("txp_prefs", "val='" . doSlash(ps('language')) . "'", "name='language'");
        safe_update("txp_prefs", "val='" . $locale . "'", "name='locale'");
        $textarray = load_lang(doSlash(ps('language')));
        $locale = setlocale(LC_ALL, $locale);
        $message = gTxt('preferences_saved');
    }
    $active_lang = safe_field('val', 'txp_prefs', "name='language'");
    $lang_form = tda(form(gTxt('active_language') . '&nbsp;&nbsp;' . languages('language', $active_lang) . '&nbsp;&nbsp;' . fInput('submit', 'Submit', gTxt('save_button'), '') . eInput('prefs') . sInput('list_languages'), 'display:inline;'), ' style="text-align:center" colspan="3"');
    $client = new IXR_Client(RPC_SERVER);
    #$client->debug = true;
    $available_lang = array();
    $rpc_connect = false;
    $show_files = false;
    # Get items from RPC
    @set_time_limit(90);
    if (gps('force') != 'file' && $client->query('tups.listLanguages', $prefs['blog_uid'])) {
        $rpc_connect = true;
        $response = $client->getResponse();
        foreach ($response as $language) {
            $available_lang[$language['language']]['rpc_lastmod'] = gmmktime($language['lastmodified']->hour, $language['lastmodified']->minute, $language['lastmodified']->second, $language['lastmodified']->month, $language['lastmodified']->day, $language['lastmodified']->year);
        }
    } elseif (gps('force') != 'file') {
        $msg = gTxt('rpc_connect_error') . "<!--" . $client->getErrorCode() . ' ' . $client->getErrorMessage() . "-->";
    }
    # Get items from Filesystem
    $files = get_lang_files();
    if (gps('force') == 'file' || !$rpc_connect) {
        $show_files = true;
    }
    if ($show_files && is_array($files) && !empty($files)) {
        foreach ($files as $file) {
            if ($fp = @fopen(txpath . DS . 'lang' . DS . $file, 'r')) {
                $name = str_replace('.txt', '', $file);
                $firstline = fgets($fp, 4069);
                fclose($fp);
                if (strpos($firstline, '#@version') !== false) {
                    @(list($fversion, $ftime) = explode(';', trim(substr($firstline, strpos($firstline, ' ', 1)))));
                } else {
                    $fversion = $ftime = NULL;
                }
                $available_lang[$name]['file_note'] = isset($fversion) ? $fversion : 0;
                $available_lang[$name]['file_lastmod'] = isset($ftime) ? $ftime : 0;
            }
        }
    }
    # Get installed items from the database
    # I'm affraid we need a value here for the language itself, not for each one of the rows
    $rows = safe_rows('lang, UNIX_TIMESTAMP(MAX(lastmod)) as lastmod', 'txp_lang', "1 GROUP BY lang ORDER BY lastmod DESC");
    foreach ($rows as $language) {
        $available_lang[$language['lang']]['db_lastmod'] = $language['lastmod'];
    }
    $list = '';
    # Show the language table
    foreach ($available_lang as $langname => $langdat) {
        $file_updated = isset($langdat['db_lastmod']) && @$langdat['file_lastmod'] > $langdat['db_lastmod'];
        $rpc_updated = @$langdat['rpc_lastmod'] > @$langdat['db_lastmod'];
        $rpc_install = tda(strong(eLink('prefs', 'get_language', 'lang_code', $langname, isset($langdat['db_lastmod']) ? gTxt('update') : gTxt('install'), 'updating', isset($langdat['db_lastmod']))) . br . safe_strftime('%d %b %Y %X', @$langdat['rpc_lastmod']), isset($langdat['db_lastmod']) ? ' style="color:red;text-align:center;background-color:#FFFFCC;"' : ' style="color:#667;vertical-align:middle;text-align:center"');
        $list .= tr(tda(gTxt($langname) . tag(isset($langdat['db_lastmod']) ? br . '&nbsp;' . safe_strftime('%d %b %Y %X', $langdat['db_lastmod']) : '', 'span', ' style="color:#aaa;font-style:italic"'), isset($langdat['db_lastmod']) && $rpc_updated ? ' nowrap="nowrap" style="color:red;background-color:#FFFFCC;"' : ' nowrap="nowrap" style="vertical-align:middle"') . n . ($rpc_updated ? $rpc_install : tda(isset($langdat['rpc_lastmod']) ? gTxt('updated') : '-', ' style="vertical-align:middle;text-align:center"')) . n . ($show_files ? tda(tag(isset($langdat['file_lastmod']) ? eLink('prefs', 'get_language', 'lang_code', $langname, $file_updated ? gTxt('update') : gTxt('install'), 'force', 'file') . br . '&nbsp;' . safe_strftime($prefs['archive_dateformat'], $langdat['file_lastmod']) : ' &nbsp; ', 'span', $file_updated ? ' style="color:#667;"' : ' style="color:#aaa;font-style:italic"'), ' class="langfile" style="text-align:center;vertical-align:middle"') . n : '')) . n . n;
    }
    // Output Table + Content
    pagetop(gTxt('update_languages'), $message);
    if (isset($msg) && $msg) {
        echo tag($msg, 'p', ' style="text-align:center;color:red;width:50%;margin: 2em auto"');
    }
    echo startTable('list'), tr(tdcs(hed(gTxt('manage_languages'), 1), 3)), tr(tdcs(sLink('prefs', 'prefs_list', gTxt('site_prefs'), 'navlink') . sp . sLink('prefs', 'advanced_prefs', gTxt('advanced_preferences'), 'navlink') . sp . sLink('prefs', 'list_languages', gTxt('manage_languages'), 'navlink-active'), '3')), tr(tda('&nbsp;', ' colspan="3" style="font-size:0.25em"')), tr($lang_form), tr(tda('&nbsp;', ' colspan="3" style="font-size:0.25em"')), tr(tda(gTxt('language')) . tda(gTxt('from_server')) . ($show_files ? tda(gTxt('from_file')) : ''), ' style="font-weight:bold"');
    echo $list;
    if (!$show_files) {
        $linktext = gTxt('from_file') . ' (' . gTxt('experts_only') . ')';
        echo tr(tda('&nbsp;', ' colspan="3" style="font-size:0.25em"')) . tr(tda(strong(eLink('prefs', 'list_languages', 'force', 'file', $linktext)), ' colspan="3" style="text-align:center"'));
    } elseif (gps('force') == 'file') {
        echo tr(tda('&nbsp;', ' colspan="3" style="font-size:0.25em"')) . tr(tda(sLink('prefs', 'list_languages', strong(gTxt('from_server'))), ' colspan="3" style="text-align:center"'));
    }
    echo endTable();
    $install_langfile = gTxt('install_langfile', array('{url}' => strong('<a href="' . RPC_SERVER . '/lang/">' . RPC_SERVER . '/lang/</a>')));
    if ($install_langfile == 'install_langfile') {
        $install_langfile = 'To install new languages from file you can download them from <b><a href="' . RPC_SERVER . '/lang/">' . RPC_SERVER . '/lang/</a></b> and place them inside your ./textpattern/lang/ directory.';
    }
    echo tag($install_langfile, 'p', ' style="text-align:center;width:50%;margin: 2em auto"');
}
Ejemplo n.º 13
0
function start_import()
{
    global $vars;
    extract(psa($vars));
    $insert_into_section = $Section;
    $insert_with_status = $type;
    $default_comment_invite = $comments_invite;
    include_once txpath . '/include/import/import_' . $import_tool . '.php';
    $ini_time = ini_get('max_execution_time');
    @ini_set('max_execution_time', 300 + intval($ini_time));
    switch ($import_tool) {
        case 'mtdb':
            $out = doImportMTDB($importdblogin, $importdb, $importdbpass, $importdbhost, $blog_id, $insert_into_section, $insert_with_status, $default_comment_invite);
            rebuild_tree('root', 1, 'article');
            break;
        case 'mt':
            $file = check_import_file();
            if (!empty($file)) {
                $out = doImportMT($file, $insert_into_section, $insert_with_status, $comments_invite);
                //Rebuilding category tree
                rebuild_tree('root', 1, 'article');
            } else {
                $out = 'Import file not found';
            }
            break;
        case 'b2':
            $out = doImportB2($importdblogin, $importdb, $importdbpass, $importdbhost, $insert_into_section, $insert_with_status, $default_comment_invite);
            break;
        case 'wp':
            $out = doImportWP($importdblogin, $importdb, $importdbpass, $importdbhost, $wpdbprefix, $insert_into_section, $insert_with_status, $default_comment_invite);
            rebuild_tree('root', 1, 'article');
            break;
        case 'blogger':
            $file = check_import_file();
            if (!empty($file)) {
                $out = doImportBLOGGER($file, $insert_into_section, $insert_with_status, $comments_invite);
            } else {
                $out = gTxt('import_file_not_found');
            }
            break;
    }
    $out = tag('max_execution_time = ' . ini_get('max_execution_time'), 'p', ' style="color:red;"') . $out;
    pagetop(gTxt('txp_import'));
    $content = startTable('list');
    $content .= tr(tdcs(hed(gTxt('txp_import'), 3), 2));
    $content .= tr(td($out));
    $content .= endTable();
    echo $content;
}
Ejemplo n.º 14
0
 function getDbInfo()
 {
     $lang = $this->vars['lang'] = ps('lang');
     $GLOBALS['textarray'] = $this->_load_lang();
     @(include txpath . '/config.php');
     # this should be on the top most method of the controller!
     if (!empty($txpcfg['db'])) {
         $this->setup_error(gTxt('already_installed', array('{txpath}' => txpath)));
     }
     $temp_txpath = txpath;
     if (@$_SERVER['SCRIPT_NAME'] && (@$_SERVER['SERVER_NAME'] || @$_SERVER['HTTP_HOST'])) {
         $guess_siteurl = @$_SERVER['HTTP_HOST'] ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'];
         $guess_siteurl .= $this->rel_siteurl;
     } else {
         $guess_siteurl = 'mysite.com';
     }
     #$this->_step_view = '<form action="'.$this->rel_siteurl.'/textpattern/setup/index.php" method="post">'.
     $this->_step_view = '<form action="' . $this->rel_siteurl . '/textpattern/setup/install.php" method="post">' . '<table id="setup" cellpadding="0" cellspacing="0" border="0">' . tr(tda(hed(gTxt('welcome_to_textpattern'), 3) . graf(gTxt('need_details'), ' style="margin-bottom:3em"') . hed(gTxt('database'), 3) . graf(gTxt('db_must_exist')), ' width="400" height="50" colspan="4" align="left"')) . tr(fLabelCell(gTxt('setup_db_login')) . fInputCell('duser', '', 1) . fLabelCell(gTxt('setup_db_password')) . fInputCell('dpass', '', 2)) . tr(fLabelCell(gTxt('setup_db_server')) . fInputCell('dhost', 'localhost', 3) . fLabelCell(gTxt('setup_db_database')) . fInputCell('ddb', '', 4)) . tr(fLabelCell(gTxt('table_prefix')) . fInputCell('dprefix', '', 5) . tdcs(small(gTxt('prefix_warning')), 2)) . tr(fLabelCell(gTxt('database_engines')) . td($this->_availableDBDrivers()) . tdcs('&nbsp;', 2)) . tr(tdcs('&nbsp;', 4)) . tr(tdcs(hed(gTxt('site_path'), 3) . graf(gTxt('confirm_site_path')), 4)) . tr(fLabelCell(gTxt('full_path_to_txp')) . tdcs(fInput('text', 'txpath', $temp_txpath, 'edit', '', '', 40) . popHelp('full_path'), 3)) . tr(tdcs('&nbsp;', 4)) . tr(tdcs(hed(gTxt('site_url'), 3) . graf(gTxt('please_enter_url')), 4)) . tr(fLabelCell('http://') . tdcs(fInput('text', 'siteurl', $guess_siteurl, 'edit', '', '', 40) . popHelp('siteurl'), 3));
     if (!is_callable('mail')) {
         $this->_step_view .= tr(tdcs(gTxt('warn_mail_unavailable'), 3, null, '" style="color:red;text-align:center'));
     }
     $this->_step_view .= tr(td() . td(fInput('submit', 'Submit', gTxt('next'), 'publish')) . td() . td());
     $this->_step_view .= endTable() . hInput('lang', $lang) . sInput('printConfig') . '</form>';
 }
function rss_db_bk($event, $step)
{
    global $prefs, $rss_dbbk_path, $rss_dbbk_dump, $rss_dbbk_mysql, $rss_dbbk_lock, $rss_dbbk_txplog, $rss_dbbk_debug, $DB, $file_base_path;
    if (!isset($rss_dbbk_lock)) {
        $rss_dbbk_lock = "1";
        $rs = safe_insert('txp_prefs', "name='rss_dbbk_lock', val='{$rss_dbbk_lock}', prefs_id='1'");
    }
    if (!isset($rss_dbbk_txplog)) {
        $rss_dbbk_txplog = "1";
        $rs = safe_insert('txp_prefs', "name='rss_dbbk_txplog', val='{$rss_dbbk_txplog}', prefs_id='1'");
    }
    if (!isset($rss_dbbk_debug)) {
        $rss_dbbk_debug = "0";
        $rs = safe_insert('txp_prefs', "name='rss_dbbk_debug', val='{$rss_dbbk_debug}', prefs_id='1'");
    }
    if (!isset($rss_dbbk_path)) {
        $rss_dbbk_path = $file_base_path;
        $rs = safe_insert('txp_prefs', "name='rss_dbbk_path', val='" . addslashes($rss_dbbk_path) . "', prefs_id='1'");
    }
    if (!isset($rss_dbbk_dump)) {
        $rss_dbbk_dump = "mysqldump";
        $rs = safe_insert('txp_prefs', "name='rss_dbbk_dump', val='" . addslashes($rss_dbbk_dump) . "', prefs_id='1'");
    }
    if (!isset($rss_dbbk_mysql)) {
        $rss_dbbk_mysql = "mysql";
        $rs = safe_insert('txp_prefs', "name='rss_dbbk_mysql', val='" . addslashes($rss_dbbk_mysql) . "', prefs_id='1'");
    }
    include txpath . '/include/txp_prefs.php';
    $bkpath = $rss_dbbk_path;
    $iswin = preg_match('/Win/', php_uname());
    $mysql_hup = ' -h' . $DB->host . ' -u' . $DB->user . ' -p' . escapeshellcmd($DB->pass);
    $txplogps = ps('rss_dbbk_txplog');
    if (ps("save")) {
        pagetop("DB Manager", "Preferences Saved");
        safe_update("txp_prefs", "val = '" . addslashes(ps('rss_dbbk_path')) . "'", "name = 'rss_dbbk_path' and prefs_id ='1'");
        safe_update("txp_prefs", "val = '" . addslashes(ps('rss_dbbk_dump')) . "'", "name = 'rss_dbbk_dump' and prefs_id ='1'");
        safe_update("txp_prefs", "val = '" . addslashes(ps('rss_dbbk_mysql')) . "'", "name = 'rss_dbbk_mysql' and prefs_id ='1'");
        safe_update("txp_prefs", "val = '" . ps('rss_dbbk_lock') . "'", "name = 'rss_dbbk_lock' and prefs_id ='1'");
        if (isset($txplogps)) {
            safe_update("txp_prefs", "val = '" . ps('rss_dbbk_txplog') . "'", "name = 'rss_dbbk_txplog' and prefs_id ='1'");
        }
        safe_update("txp_prefs", "val = '" . ps('rss_dbbk_debug') . "'", "name = 'rss_dbbk_debug' and prefs_id ='1'");
        header("Location: index.php?event=rss_db_bk");
    } else {
        if (gps("bk")) {
            $bk_table = gps("bk_table") ? " --tables " . gps("bk_table") . " " : "";
            $tabpath = gps("bk_table") ? "-" . gps("bk_table") : "";
            $gzip = gps("gzip");
            $filename = time() . '-' . $DB->db . $tabpath;
            $backup_path = $bkpath . '/' . $filename . '.sql';
            $lock = $rss_dbbk_lock ? "" : " --skip-lock-tables --skip-add-locks ";
            echo $txplogps;
            $nolog = $rss_dbbk_txplog ? "" : " --ignore-table=" . $DB->db . ".txp_log ";
            $nolog = isset($bk_table) && gps("bk_table") == "txp_log" ? "" : $nolog;
            if ($gzip) {
                $backup_path .= '.gz';
                $backup_cmd = $rss_dbbk_dump . $mysql_hup . ' -Q --add-drop-table ' . $lock . $nolog . $DB->db . $bk_table . ' | gzip > ' . $backup_path;
            } else {
                $backup_cmd = $rss_dbbk_dump . $mysql_hup . ' -Q --add-drop-table ' . $lock . $nolog . $DB->db . $bk_table . ' > ' . $backup_path;
            }
            $bkdebug = $rss_dbbk_debug ? $backup_cmd : '';
            $error = "";
            if (function_exists('passthru')) {
                passthru($backup_cmd, $error);
            } else {
                $dumpIt = popen($backup_cmd, 'r');
                pclose($dumpIt);
            }
            if (!is_writable($bkpath)) {
                pagetop("DB Manager", "BACKUP FAILED: folder is not writable");
            } elseif ($error) {
                unlink($backup_path);
                pagetop("DB Manager", "BACKUP FAILED.  ERROR NO: " . $error);
            } else {
                if (!is_file($backup_path)) {
                    pagetop("DB Manager", "BACKUP FAILED.  ERROR NO: " . $error);
                } else {
                    if (filesize($backup_path) == 0) {
                        unlink($backup_path);
                        pagetop("DB Manager", "BACKUP FAILED.  ERROR NO: " . $error);
                    } else {
                        pagetop("DB Manager", "Backed Up: " . $DB->db . " to " . $filename);
                    }
                }
            }
        } else {
            if (gps("download")) {
                $fn = gps("download");
                $file_path = $bkpath . '/' . $fn;
                header("Pragma: public");
                header("Expires: 0");
                header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
                header("Content-Type: application/force-download");
                header("Content-Type: application/octet-stream");
                header("Content-Type: application/download");
                if (substr($fn, -2) == "gz") {
                    header("Content-Type: application/zip");
                }
                header("Content-Disposition: attachment; filename=" . basename($file_path) . ";");
                header("Content-Transfer-Encoding: binary");
                header("Content-Length: " . filesize($file_path));
                @readfile($file_path);
            } else {
                if (gps("restore")) {
                    if (stristr(gps("restore"), '.gz')) {
                        $backup_cmd = 'gunzip < ' . $bkpath . '/' . gps("restore") . ' | ' . $rss_dbbk_mysql . $mysql_hup . ' ' . $DB->db;
                    } else {
                        $backup_cmd = $rss_dbbk_mysql . $mysql_hup . ' ' . $DB->db . ' < ' . $bkpath . '/' . gps("restore");
                    }
                    $bkdebug = $rss_dbbk_debug ? $backup_cmd : '';
                    $error = "";
                    if (function_exists('passthru')) {
                        passthru($backup_cmd, $error);
                    } else {
                        $dumpIt = popen($backup_cmd, 'r');
                        pclose($dumpIt);
                    }
                    if ($error) {
                        pagetop("DB Manager", "FAILED TO RESTORE: " . $error);
                    } else {
                        pagetop("DB Manager", "Restored: " . gps("restore") . " to " . $DB->db);
                    }
                } else {
                    if (gps("delete")) {
                        if (is_file($bkpath . '/' . gps("delete"))) {
                            if (!unlink($bkpath . '/' . gps("delete"))) {
                                pagetop("DB Manager", "Unable to Delete: " . gps("delete"));
                            } else {
                                pagetop("DB Manager", "Deleted: " . gps("delete"));
                            }
                        } else {
                            pagetop("DB Manager", "Unable to Delete: " . gps("delete"));
                        }
                    } else {
                        pagetop("DB Backup");
                    }
                }
            }
        }
    }
    $gzp = !$iswin ? " | " . href('gzipped file', "index.php?event=rss_db_bk&amp;bk={$DB->db}&amp;gzip=1") : "";
    $sqlversion = getRow("SELECT VERSION() AS version");
    $sqlv = explode("-", $sqlversion['version']);
    $allownologs = (double) $sqlv[0] >= (double) "4.1.9" ? tda(gTxt('Include txp_log:'), ' style="text-align:right;vertical-align:middle"') . tda(yesnoRadio("rss_dbbk_txplog", $rss_dbbk_txplog), ' style="text-align:left;vertical-align:middle"') : '';
    if (isset($bkdebug) && $bkdebug) {
        echo '<p align="center">' . $bkdebug . '</p>';
    }
    echo startTable('list') . form(tr(tda(gTxt('Lock Tables:'), ' style="text-align:right;vertical-align:middle"') . tda(yesnoRadio("rss_dbbk_lock", $rss_dbbk_lock), ' style="text-align:left;vertical-align:middle"') . $allownologs . tda(gTxt('Debug Mode:'), ' style="text-align:right;vertical-align:middle"') . tda(yesnoRadio("rss_dbbk_debug", $rss_dbbk_debug), ' style="text-align:left;vertical-align:middle"') . tda(fInput("submit", "save", gTxt("save_button"), "publish") . eInput("rss_db_bk") . sInput('saveprefs'), " colspan=\"2\" class=\"noline\"")) . tr(tda(gTxt('Backup Path:'), ' style="text-align:right;vertical-align:middle"') . tda(text_input("rss_dbbk_path", $rss_dbbk_path, '50'), ' colspan="15"')) . tr(tda(gTxt('mysqldump Path:'), ' style="text-align:right;vertical-align:middle"') . tda(text_input("rss_dbbk_dump", $rss_dbbk_dump, '50'), ' colspan="15"')) . tr(tda(gTxt('mysql Path:'), ' style="text-align:right;vertical-align:middle"') . tda(text_input("rss_dbbk_mysql", $rss_dbbk_mysql, '50'), ' colspan="15"'))) . endTable() . startTable("list") . tr(tda(hed('Create a new backup of the ' . $DB->db . ' database' . br . href('.sql file', "index.php?event=rss_db_bk&amp;bk={$DB->db}") . $gzp, 3), ' colspan="7" style="text-align:center;"')) . tr(tdcs(hed("Previous Backup Files", 1), 7)) . tr(hcell("No.") . hcell("Backup File Name") . hcell("Backup Date/Time") . hcell("Backup File Size") . hcell("") . hcell("") . hcell(""));
    $totalsize = 0;
    $no = 0;
    if (!is_folder_empty($bkpath)) {
        if ($handle = opendir($bkpath)) {
            $database_files = array();
            while (false !== ($file = readdir($handle))) {
                if ($file != '.' && $file != '..' && (substr($file, -4) == ".sql" || substr($file, -7) == ".sql.gz")) {
                    $database_files[] = $file;
                }
            }
            closedir($handle);
            for ($i = sizeof($database_files) - 1; $i > -1; $i--) {
                $no++;
                $style = $no % 2 == 0 ? ' style="background-color: #eee;"' : '';
                $database_text = substr($database_files[$i], 11);
                $date_text = strftime("%A, %B %d, %Y [%H:%M:%S]", substr($database_files[$i], 0, 10));
                $size_text = filesize($bkpath . '/' . $database_files[$i]);
                $totalsize += $size_text;
                echo tr(td($no) . td($database_text) . td($date_text) . td(prettyFileSize($size_text)) . '<td><a href="index.php?event=rss_db_bk&amp;download=' . $database_files[$i] . '">Download</a></td>' . '<td><a href="index.php?event=rss_db_bk&amp;restore=' . $database_files[$i] . '"  onclick="return verify(\'' . gTxt('are_you_sure') . '\')">Restore</a></td>' . '<td><a href="index.php?event=rss_db_bk&amp;delete=' . $database_files[$i] . '"  onclick="return verify(\'' . gTxt('are_you_sure') . '\')">Delete</a></td>', $style);
            }
            echo tr(tag($no . " Backup File(s)", "th", ' colspan="3"') . tag(prettyFileSize($totalsize), "th", ' colspan="4"'));
        } else {
            echo tr(tda(hed('You have no database backups' . br . 'Create a new backup of the ' . $DB->db . ' database' . br . href('.sql file', "index.php?event=rss_db_bk&amp;bk={$DB->db}") . $gzp, 3), ' colspan="7" style="text-align:center;"'));
        }
    } else {
        echo tr(tda(hed('You have no database backups' . br . 'Create a new backup of the ' . $DB->db . ' database' . br . href('.sql file', "index.php?event=rss_db_bk&amp;bk={$DB->db}") . $gzp, 3), ' colspan="7" style="text-align:center;"'));
    }
    echo endTable();
}
function jmc_event_manager($event, $step)
{
    // Declare global variable arrays
    global $vars_events, $vars_venues, $vars_categories;
    $vars_events = array("ID", "CategoryID", "sDateTime", "fDateTime", "name", "AuthorID", "LastMod", "LastModID", "VenueID", "Price", "OtherBands", "OtherBands_html", "OtherInfo", "OtherInfo_html", "comments_count");
    $vars_venues = array("ID", "CategoryID", "imageID", "name", "address1", "address2", "suburb", "state", "country", "postcode", "phone", "url", "email", "OtherInfo", "OtherInfo_html", "comments_count");
    $vars_categories = array("ID", "name", "OtherInfo", "OtherInfo_html");
    // Create the top menu arrays
    $top_menu = array();
    $top_menu['main'] = tr(tdcs("", 4)) . tr(td("<a href=\"?event=jmc_event_manager\" class=\"navlink\">Event Manager</a>") . td("<a href=\"?event=jmc_event_manager&#38;step=venue_manager\" class=\"navlink\">Venue Manager</a>") . td("<a href=\"?event=jmc_event_manager&#38;step=category_manager\" class=\"navlink\">Category Manager</a>") . td("<a href=\"?event=jmc_event_manager&#38;step=feed_manager\" class=\"navlink\">RSS Feed</a>"));
    $top_menu['events'] = tr(td("<a href=\"?event=jmc_event_manager&#38;step=event_add\" class=\"navlink\">Add Event</a>") . td("<a href=\"?event=jmc_event_manager\" class=\"navlink\">Upcoming Events</a>") . td("<a href=\"?event=jmc_event_manager&#38;step=event_past\" class=\"navlink\">Past Events</a>") . td(""));
    $top_menu['venues'] = tr(td("") . td("<a href=\"?event=jmc_event_manager&#38;step=venue_add\" class=\"navlink\">Add Venue</a>") . td("<a href=\"?event=jmc_event_manager&#38;step=venue_manager\" class=\"navlink\">Venue Listing</a>") . td(""));
    $top_menu['categories'] = tr(td("") . td("<a href=\"?event=jmc_event_manager&#38;step=category_add\" class=\"navlink\">Add Category</a>") . td("<a href=\"?event=jmc_event_manager&#38;step=category_manager\" class=\"navlink\">Category Listing</a>") . td(""));
    $top_menu['rss_feeds'] = tr(tdcs("This feature is yet to be implemented. Sorry guys :(", 4));
    /*
    The Mega Switch
    */
    $content['title'] = "Event Manager";
    $content['menus'] = $top_menu['main'];
    $content['subtitle'] = "Events";
    $content['content'] = "";
    $step_details = split("_", $step);
    switch ($step_details[0]) {
        /* _-_-_-_-_-_-_-_-_-_-_-_-_-_-_ */
        /* 		VENUE       MANAGER		 */
        /* -_-_-_-_-_-_-_-_-_-_-_-_-_-_- */
        case "venue":
            $content['title'] = "Venue Manager";
            $content['menus'] .= $top_menu['venues'];
            $content['subtitle'] = "Venues";
            switch ($step_details[1]) {
                case "manager":
                    $content['content'] = jmc_event_manager_venues();
                    break;
                case "add":
                    $content['subtitle'] = "New Venue";
                    $content['content'] = jmc_event_manager_venue_form($step);
                    break;
                case "post":
                    $content['subtitle'] = "New Venue";
                    $content['content'] = jmc_event_manager_venue_post();
                    break;
                case "edit":
                    $content['subtitle'] = "Edit Venue";
                    $content['content'] = jmc_event_manager_venue_form($step, true);
                    break;
                case "save":
                    $content['subtitle'] = "Edit Venue";
                    $content['content'] = jmc_event_manager_venue_save();
                    break;
                case "multiedit":
                    $content['content'] = jmc_event_manager_multiedit("txp_jmc_event_venue");
                    break;
                default:
                    $content['content'] = jmc_event_manager_venues();
                    break;
            }
            break;
            /* _-_-_-_-_-_-_-_-_-_-_-_-_-_-_ */
            /* 		CATEGORY   MANAGER		 */
            /* -_-_-_-_-_-_-_-_-_-_-_-_-_-_- */
        /* _-_-_-_-_-_-_-_-_-_-_-_-_-_-_ */
        /* 		CATEGORY   MANAGER		 */
        /* -_-_-_-_-_-_-_-_-_-_-_-_-_-_- */
        case "category":
            $content['title'] = "Category Manager";
            $content['menus'] .= $top_menu['categories'];
            $content['subtitle'] = "Categories";
            switch ($step_details[1]) {
                case "manager":
                    $content['content'] = jmc_event_manager_categories();
                    break;
                case "add":
                    $content['subtitle'] = "New Category";
                    $content['content'] = jmc_event_manager_category_form($step);
                    break;
                case "post":
                    $content['subtitle'] = "New Category";
                    $content['content'] = jmc_event_manager_category_post();
                case "edit":
                    $content['subtitle'] = "Edit Category";
                    $content['content'] = jmc_event_manager_category_form($step, true);
                    break;
                case "save":
                    $content['subtitle'] = "Edit Category";
                    $content['content'] = jmc_event_manager_category_save();
                    break;
                case "multiedit":
                    $content['content'] = jmc_event_manager_multiedit("txp_jmc_event_category");
                    break;
                default:
                    $content['content'] = jmc_event_manager_categories();
                    break;
            }
            break;
            /* _-_-_-_-_-_-_-_-_-_-_-_-_-_-_ */
            /* 		EVENT       MANAGER		 */
            /* -_-_-_-_-_-_-_-_-_-_-_-_-_-_- */
        /* _-_-_-_-_-_-_-_-_-_-_-_-_-_-_ */
        /* 		EVENT       MANAGER		 */
        /* -_-_-_-_-_-_-_-_-_-_-_-_-_-_- */
        case "event":
            $content['title'] = "Event Manager";
            $content['menus'] .= $top_menu['events'];
            $content['subtitle'] = "Events";
            switch ($step_details[1]) {
                case "manager":
                    $content['content'] = jmc_event_manager_events();
                    break;
                case "past":
                    $content['subtitle'] = "Past Events";
                    $content['content'] = jmc_event_manager_events($step);
                    break;
                case "add":
                    $content['subtitle'] = "New Event";
                    $content['content'] = jmc_event_manager_event_new();
                    break;
                case "post":
                    $content['subtitle'] = "New Event";
                    $content['content'] = jmc_event_manager_event_post();
                case "edit":
                    $content['subtitle'] = "Edit Event";
                    $content['content'] = jmc_event_manager_event_edit();
                    break;
                case "save":
                    $content['subtitle'] = "Edit Event";
                    $content['content'] = jmc_event_manager_event_save();
                    break;
                case "multiedit":
                    $content['content'] = jmc_event_manager_multiedit("txp_jmc_event_event");
                    break;
                default:
                    $content['content'] = jmc_event_manager_events();
                    break;
            }
            break;
        default:
            $content['title'] = "Event Manager";
            $content['menus'] .= $top_menu['events'];
            $content['subtitle'] = "Events";
            $content['content'] = jmc_event_manager_events();
            break;
    }
    // Output the top for debugging - will stay UNTIL full release
    pagetop("Textpattern", "Event: {$event}; Step: {$step}.");
    // Hug everything in a nice little DIV!
    print_r("<div style=\"margin-top:3em; margin: auto; width: 600px; text-align: center\">\r\n");
    print_r(tag($content['title'], "h2") . startTable('list') . $content['menus'] . endTable() . tag($content['subtitle'], "h3") . $content['content']);
    print_r("</div>\r\n");
}
Ejemplo n.º 17
0
/**
 * Get Yab Shop prefs or language and display it
 *
 * @param string Table without prefix
 * @return string
 */
function yab_shop_display_prefs($table = 'yab_shop_prefs')
{
    // choose step and event
    if ($table == 'yab_shop_lang') {
        $heading = hed(yab_shop_admin_lang('shop_lang'), 1, ' class="txp-heading"');
        $submit = sInput('yab_shop_lang_save') . eInput('yab_shop_language');
    } else {
        $heading = hed(yab_shop_admin_lang('shop_prefs'), 1, ' class="txp-heading"');
        $submit = sInput('yab_shop_prefs_save') . eInput('yab_shop_prefs') . hInput('prefs_id', '1');
    }
    $out = '<div id="page-prefs" class="txp-container">' . '<form method="post" action="index.php" class="prefs-form basic">' . startTable('', '', 'txp-list') . '<tbody>';
    // does exists the choosen language?
    $lang_count = safe_count('yab_shop_lang', "lang='" . doSlash(LANG) . "'");
    if ($lang_count) {
        $lang_code = LANG;
    } else {
        // fallback language
        $lang_code = 'en-gb';
    }
    // do table dependend query
    if ($table == 'yab_shop_lang') {
        $rs = safe_rows_start('*', 'yab_shop_lang', "lang = '" . doSlash($lang_code) . "' AND event = 'lang_public' ORDER BY event DESC, position ");
    } else {
        $rs = safe_rows_start('*', 'yab_shop_prefs', "type = 1 AND prefs_id = 1 ORDER BY event DESC, position ");
    }
    // now make a html table from the database table
    $cur_evt = '';
    while ($a = nextRow($rs)) {
        if ($a['event'] != $cur_evt) {
            $cur_evt = $a['event'];
            $out .= n . tr(n . tdcs(hed(yab_shop_admin_lang($a['event']), 3, ' class="' . $a['event'] . '-prefs"'), 2), ' class="pref-heading"');
        }
        if ($a['html'] != 'yesnoradio') {
            $label = '<label for="' . $a['name'] . '">' . yab_shop_admin_lang($a['name']) . '</label>';
        } else {
            $label = yab_shop_admin_lang($a['name']);
        }
        if ($a['html'] == 'text_input') {
            // choose different text_input sizes for these fields
            $look_for = array('checkout_section_name', 'checkout_thanks_site', 'back_to_shop_link', 'custom_field_price_name', 'custom_field_property_1_name', 'custom_field_property_2_name', 'custom_field_property_3_name', 'custom_field_shipping_name', 'admin_mail', 'paypal_business_mail', 'paypal_live_or_sandbox', 'paypal_certificate_id', 'paypal_certificates_path', 'paypal_public_certificate_name', 'paypal_my_public_certificate_name', 'paypal_my_private_key_name', 'google_live_or_sandbox', 'google_merchant_id', 'google_merchant_key');
            if (in_array($a['name'], $look_for)) {
                $size = 25;
            } elseif ($table == 'yab_shop_lang') {
                $size = 40;
            } else {
                $size = 4;
            }
            $out_tr = td(yab_shop_pref_func('yab_shop_text_input', $a['name'], $a['val'], $size), '', 'pref-value');
        } elseif ($a['html'] == 'text_area') {
            if ($table == 'yab_shop_lang') {
                $size = 37;
            } else {
                $size = 17;
            }
            $out_tr = td(yab_shop_pref_func('yab_shop_text_area', $a['name'], $a['val'], $size), '', 'pref-value');
        } else {
            if (is_callable($a['html'])) {
                $out_tr = td(yab_shop_pref_func($a['html'], $a['name'], $a['val']), '', 'pref-value');
            } else {
                $out .= n . td($a['val']);
            }
        }
        $out .= n . tr(n . tda($label, ' class="pref-label"') . n . $out_tr);
    }
    $out .= n . '</tbody>' . n . endTable() . graf(fInput('submit', 'Submit', gTxt('save_button'), 'publish') . $submit) . n . n . '</form></div>';
    return $heading . $out;
}
Ejemplo n.º 18
0
            if ($prefname == 'lastmod') {
                safe_update("txp_prefs", "val=now()", "name='lastmod'");
            } else {
                if ($prefname == 'siteurl') {
                    $post[$prefname] = str_replace("http://", '', $post[$prefname]);
                }
                safe_update("txp_prefs", "val = '" . $post[$prefname] . "'", "name = '{$prefname}' and prefs_id ='1'");
            }
        }
    }
    $message = gTxt('preferences_saved');
}
extract(get_prefs());
$message = isset($message) ? $message : "";
echo pagetop(gTxt('edit_preferences'), $message), '<form action="index.php" method="post">', startTable('list'), tr(tdcs(hed(gTxt('site_prefs'), 1), 3)), pCell('sitename', $sitename, 'input', 20), pCell('siteurl', $siteurl, 'input', 20), pCell('path_from_root', $path_from_root, 'input', 20), pCell('site_slogan', $site_slogan, 'input', 20), pCell('language', $language, 'languages'), pCell('timeoffset', $timeoffset, 'timeoffset'), pCell('dateformat', $dateformat, 'dateformats'), pCell('archive_dateformat', $archive_dateformat, 'dateformats'), pCell('url_mode', $url_mode, 'urlmodes'), pCell('send_lastmod', $send_lastmod, 'radio'), pCell('ping_weblogsdotcom', $ping_weblogsdotcom, 'radio'), pCell('logging', $logging, 'logging'), pCell('record_mentions', $record_mentions, 'radio'), pCell('use_textile', $use_textile, 'text'), pCell('use_categories', $use_categories, 'radio'), pCell('use_sections', $use_sections, 'radio');
echo tr(tdcs(hed(gTxt('comments'), 1), 3)), pCell('use_comments', $use_comments, 'radio');
if ($use_comments) {
    echo pCell('comments_moderate', $comments_moderate, 'radio'), pCell('comments_on_default', $comments_on_default, 'radio'), pCell('comments_default_invite', $comments_default_invite, 'input', 15), pCell('comments_dateformat', $comments_dateformat, 'dateformats'), pCell('comments_mode', $comments_mode, 'commentmode'), pCell('comments_sendmail', $comments_sendmail, 'radio'), pCell('comments_disallow_images', $comments_disallow_images, 'radio'), pCell('comments_disabled_after', $comments_disabled_after, 'weeks');
}
echo tr(tda(fInput('submit', 'Submit', gTxt('save_button'), 'publish'), ' colspan="3" class="noline"')), endTable(), sInput('save'), eInput('prefs'), hInput('prefs_id', "1"), hInput('lastmod', "now()"), '</form>';
//-------------------------------------------------------------
function pCell($item, $var, $format, $size = "", $nohelp = "")
{
    $var = stripslashes($var);
    $out = tda(gTxt($item), ' style="text-align:right;vertical-align:middle"');
    switch ($format) {
        case "radio":
            $in = yesnoradio($item, $var);
            break;
        case "input":
            $in = text_input($item, $var, $size);
Ejemplo n.º 19
0
function advanced_prefs($message = '')
{
    echo pagetop(gTxt('advanced_preferences'), $message) . n . '<h1 class="txp-heading">' . gTxt('tab_preferences') . '</h1>' . n . '<div id="prefs_container" class="txp-container">' . n . n . '<form method="post" class="prefs-form advanced" action="index.php">' . n . '<p class="nav-tertiary">' . sLink('prefs', 'prefs_list', gTxt('site_prefs'), 'navlink') . sLink('prefs', 'advanced_prefs', gTxt('advanced_preferences'), 'navlink-active') . sLink('prefs', 'list_languages', gTxt('manage_languages'), 'navlink') . n . '</p>' . n . n . startTable('', '', 'txp-list') . '<tbody>';
    $rs = safe_rows_start('*', 'txp_prefs', "type = 1 and prefs_id = 1 order by event, position");
    $cur_evt = '';
    while ($a = nextRow($rs)) {
        $headingPopHelp = strpos($a['name'], 'custom_') !== false;
        if ($a['event'] != $cur_evt) {
            $cur_evt = $a['event'];
            echo n . n . tr(tdcs(hed(gTxt($a['event']) . ($headingPopHelp ? n . popHelp($a['name']) : ''), 3, ' class="' . $a['event'] . '-prefs"'), 2), ' class="pref-heading"');
        }
        $label = !in_array($a['html'], array('yesnoradio', 'is_dst')) ? '<label for="' . $a['name'] . '">' . gTxt($a['name']) . '</label>' : gTxt($a['name']);
        $out = tda($label . ($headingPopHelp ? '' : n . popHelp($a['name'])), ' class="pref-label"');
        if ($a['html'] == 'text_input') {
            $look_for = array('expire_logs_after', 'max_url_len', 'time_offset', 'rss_how_many', 'logs_expire');
            $size = in_array($a['name'], $look_for) ? INPUT_XSMALL : INPUT_REGULAR;
            $out .= td(pref_func('text_input', $a['name'], $a['val'], $size), '', 'pref-value');
        } else {
            $out .= td(pref_func($a['html'], $a['name'], $a['val']), '', 'pref-value');
        }
        echo n . n . tr($out, " id='prefs-{$a['name']}' class='{$a['event']}-prefs'");
    }
    echo n . '</tbody>' . n . endTable() . graf(fInput('submit', 'Submit', gTxt('save'), 'publish') . n . sInput('advanced_prefs_save') . n . eInput('prefs') . n . hInput('prefs_id', '1') . n . tInput()) . n . n . '</form>' . n . '</div>';
}
Ejemplo n.º 20
0
function image_edit()
{
    pagetop(gTxt('categories'));
    $name = gps('name');
    extract(safe_row("*", "txp_category", "name='{$name}' and type='image'"));
    $out = tr(fLabelCell(gTxt('image_category_name') . ':') . fInputCell('name', $name, 1, 20)) . tr(fLabelCell('parent') . td(parent_pop($parent, 'image'))) . tr(tdcs(fInput('submit', '', gTxt('save_button'), 'smallerbox'), 2));
    $out .= eInput('category') . sInput('image_save') . hInput('old_name', $name);
    echo form(startTable('edit') . $out . endTable());
}
Ejemplo n.º 21
0
function cat_event_category_edit($evname)
{
    pagetop(gTxt('categories'));
    $id = assert_int(gps('id'));
    $parent = doSlash(gps('parent'));
    $row = safe_row("*", "txp_category", "id={$id}");
    if ($row) {
        extract($row);
        $out = stackRows(fLabelCell($evname . '_category_name') . fInputCell('name', $name, 1, 20), fLabelCell('parent') . td(cat_parent_pop($parent, $evname, $id)), fLabelCell($evname . '_category_title') . fInputCell('title', $title, 1, 30), pluggable_ui('category_ui', 'extend_detail_form', '', $row), hInput('id', $id), tdcs(fInput('submit', '', gTxt('save_button'), 'smallerbox'), 2));
    }
    $out .= eInput('category') . sInput('cat_' . $evname . '_save') . hInput('old_name', $name);
    echo '<div id="category_container" class="txp-container txp-edit">' . form(startTable('edit', '', 'edit-pane') . $out . endTable(), '', '', 'post', 'edit-form') . '</div>';
}
Ejemplo n.º 22
0
 function edit_view()
 {
     $id = assert_int(gps('id'));
     $type = ps('type');
     $row = safe_row('*', 'txp_category', "id = {$id}");
     if ($row) {
         extract($row);
         echo form(n . startTable('edit') . stackRows(n . tdcs(n . hed(gTxt($type . '_category'), 1), 2), fLabelCell('name') . fInputCell('name', $name, 1, 20), fLabelCell('parent') . n . td($this->cat_parent_pop('parent', $type, $id, $parent)), fLabelCell('title') . fInputCell('title', $title, 1, 30), n . tdcs(fInput('submit', '', gTxt('save_button'), 'smallerbox'), 2)) . endTable() . n . eInput('category') . n . sInput('edit') . n . hInput('id', $id) . n . hInput('old_name', $name) . n . hInput('type', $type));
     }
 }
Ejemplo n.º 23
0
function file_list($message = '')
{
    global $txpcfg, $extensions, $file_base_path;
    extract($txpcfg);
    extract(get_prefs());
    pagetop(gTxt('file'), $message);
    $page = gps('page');
    $total = getCount('txp_file', "1=1");
    $limit = max(@$file_list_pageby, 25);
    $numPages = ceil($total / $limit);
    $page = !$page ? 1 : $page;
    $offset = ($page - 1) * $limit;
    $sort = gps('sort');
    $dir = gps('dir');
    $sort = $sort ? $sort : 'filename';
    $dir = $dir ? $dir : 'desc';
    if ($dir == "desc") {
        $dir = "asc";
    } else {
        $dir = "desc";
    }
    $existing_files = get_filenames();
    echo startTable('list'), tr(tda(file_upload_form(gTxt('upload_file'), 'upload', 'file_insert'), ' colspan="4" style="border:0"')), count($existing_files) > 0 ? tr(tda(form(graf(gTxt('existing_file') . sp . selectInput('filename', $existing_files, "", 1) . sp . fInput('submit', '', gTxt('Create'), 'smallerbox') . sp . eInput('file') . sInput('file_create'))), ' colspan="4" style="border:0"')) : '', tr(column_head('Id', 'id', 'file', 1, $dir) . column_head('file_name', 'filename', 'file', 1, $dir) . td(gTxt('status')) . td(gTxt('tags')) . column_head('file_category', 'category', 'file', 1, $dir) . column_head('description', 'description', 'file', 1, $dir) . column_head('downloads', 'downloads', 'file', 1, $dir) . td());
    $nav[] = $page > 1 ? PrevNextLink("file", $page - 1, gTxt('prev'), 'prev') : '';
    $nav[] = sp . small($page . '/' . $numPages) . sp;
    $nav[] = $page != $numPages ? PrevNextLink("file", $page + 1, gTxt('next'), 'next') : '';
    $rs = safe_rows_start("*", "txp_file", "1=1 order by {$sort} {$dir} limit {$offset}, {$limit}");
    if ($rs) {
        while ($a = nextRow($rs)) {
            extract($a);
            // does the downloads column exist?
            if (!isset($downloads)) {
                // nope, add it
                safe_alter("txp_file", "ADD downloads INT DEFAULT '0' NOT NULL");
                $downloads = 0;
            } else {
                if (empty($downloads)) {
                    $downloads = '0';
                }
            }
            $elink = eLink('file', 'file_edit', 'id', $id, $filename);
            $dlink = dLink('file', 'file_delete', 'id', $id);
            //Add tags helper
            $txtilelink = '<a target="_blank" href="?event=tag' . a . 'name=file' . a . 'id=' . $id . a . 'description=' . urlencode($description) . a . 'filename=' . urlencode($filename) . a . 'type=textile" onclick="window.open(this.href, \'popupwindow\', \'width=400,height=400,scrollbars,resizable\'); return false;">Textile</a>';
            $txplink = '<a target="_blank" href="?event=tag' . a . 'name=file' . a . 'id=' . $id . a . 'description=' . urlencode($description) . a . 'filename=' . urlencode($filename) . a . 'type=textpattern" onclick="window.open(this.href, \'popupwindow\', \'width=400,height=400,scrollbars,resizable\'); return false;">Textpattern</a>';
            $xhtmlink = '<a target="_blank" href="?event=tag' . a . 'name=file' . a . 'id=' . $id . a . 'description=' . urlencode($description) . a . 'filename=' . urlencode($filename) . a . 'type=xhtml" onclick="window.open(this.href, \'popupwindow\', \'width=400,height=400,scrollbars,resizable\'); return false;">XHTML</a>';
            $file_exists = file_exists(build_file_path($file_base_path, $filename));
            $missing = '<span style="color:';
            $missing .= $file_exists ? 'green' : 'red';
            $missing .= '">';
            $missing .= $file_exists ? gTxt('file_status_ok') : gTxt('file_status_missing');
            $missing .= '</span>';
            $downloadlink = $file_exists ? make_download_link($id, $filename, $id) : $id;
            echo tr(td($downloadlink) . td($elink) . td($missing) . td($txtilelink . ' / ' . $txplink . ' / ' . $xhtmlink) . td($category, 90) . td($description, 150) . td($downloads == '0' ? " 0" : $downloads, 20) . td($dlink, 10));
        }
        echo tr(tdcs(graf(join('', $nav)), 4));
    }
    echo endTable();
    echo pageby_form('file', $file_list_pageby);
    if (!is_dir($file_base_path) or !is_writeable($file_base_path)) {
        echo graf(str_replace("{filedir}", $file_base_path, gTxt('file_dir_not_writeable')), ' style="text-align:center;color:red"');
    }
}
Ejemplo n.º 24
0
function tag_file_download_link()
{
    global $step, $endform, $name;
    $invars = gpsa(array('filename', 'id'));
    extract($invars);
    $out = form(startTable('list') . tr(tdcs(hed(gTxt('tag_file_download_link'), 3), 2)) . tagRow('id', fInput('text', 'id', $id, 'edit', '', '', 4)) . tagRow('filename', fInput('text', 'filename', $filename, 'edit', '', '', 15)) . $endform);
    $out .= tdb(tb('file_download_link', $invars, gTxt('text_or_tag')));
    return $out;
}
Ejemplo n.º 25
0
function tag_file_download_description()
{
    global $step, $endform, $tag_name;
    $atts = gpsa(array('class', 'escape', 'wraptag'));
    extract($atts);
    $out = form(startTable('tagbuilder') . tr(tdcs(hed(gTxt('tag_' . $tag_name), 3), 2)) . tagRow('escape', escape_pop($escape)) . tagRow('wraptag', input_tag('wraptag', $wraptag)) . tagRow('class', fInput('text', 'class', $class, 'edit', '', '', 25)) . $endform);
    if ($step == 'build') {
        $out .= tdb(tb($tag_name, $atts));
    }
    return $out;
}
Ejemplo n.º 26
0
 function render_article_table()
 {
     $event = $this->parent->event;
     #
     #	Pager calculations...
     #
     extract(get_prefs());
     #	Need to do this to keep the articles/page count in sync.
     extract(gpsa(array('page')));
     $total = MLPArticles::get_total();
     $limit = max(@$article_list_pageby, 15);
     list($page, $offset, $numPages) = pager($total, $limit, $page);
     #
     #	User permissions...
     #
     $can_delete = has_privs('article.delete');
     $can_clone = has_privs('l10n.clone');
     #
     #	Init language related vars...
     #
     $langs = MLPLanguageHandler::get_site_langs();
     $full_lang_count = count($langs);
     $default_lang = MLPLanguageHandler::get_site_default_lang();
     #
     #	Render the filter/search form...
     #
     $o[] = $this->_render_filter_form($page);
     #
     #	Start the table...
     #
     $o[] = startTable('l10n_articles_table', '', '', '5px');
     $o[] = '<caption><strong>' . gTxt('l10n-renditions') . '</strong></caption>';
     $rendition_counts = $this->get_rendition_counts();
     #
     #	Setup the colgroup/thead...
     #
     $colgroup[] = n . t . '<col id="id" />';
     $thead[] = tag(gTxt('articles'), 'th', ' class="id"');
     foreach ($langs as $lang) {
         $colgroup[] = n . t . '<col id="' . $lang . '" />';
         $name = MLPLanguageHandler::get_native_name_of_lang($lang);
         $clone_all_link = '';
         if (@$rendition_counts[$lang] < $total) {
             $clone_all_link = '<a href="' . $this->parent->url(array('page' => $page, 'step' => 'start_clone_all_from', 'target_lang' => $lang), true) . '" class="clone_all-link" title="' . gTxt('l10n-clone_all_from', array('{lang}' => $name)) . '"><img src="txp_img/l10n_clone_all.png" /></a>';
         }
         #
         #	Default language markup -- if needed.
         #
         if ($lang === $default_lang) {
             $name .= br . gTxt('default');
         } else {
             $name .= ' ' . $clone_all_link;
         }
         $thead[] = hCell($name);
         $counts[$lang] = 0;
     }
     $o[] = n . tag(join('', $colgroup), 'colgroup');
     $o[] = n . tr(join('', $thead));
     $counts['article'] = 0;
     #	Initialise the article count.
     $w = '';
     #	Var for td width -- set empty to skip its inclusion / other val overrides css.
     $body = array();
     #
     #	Process the articles table...
     #
     #	Use values from the pager to grab the right sections of the table.
     #
     $articles = MLPArticles::get_articles('1=1', 'ID DESC', $offset, $limit);
     if (count($articles)) {
         while ($article = nextRow($articles)) {
             $num_visible = 0;
             # 	Holds a count of visible (=Sticky/Live) translations of this article.
             $trclass = '';
             #	Class for the row (=article)
             $cells = array();
             #	List of table cells (=translations) in this row
             $sections = array();
             #	Holds a list of the unique sections used by translations in this article.
             #
             #	Pull out the article (NB: Not translation!)...
             #
             extract($article);
             $members = unserialize($members);
             $n_translations_expected = count($members);
             #
             #	Pull the translations for this article from the master translations table
             # (that is, from the textpattern table)...
             #
             $translations = safe_rows('*', 'textpattern', L10N_COL_GROUP . "={$ID}");
             $n_translations = count($translations);
             $n_valid_translations = 0;
             #
             #	Index the translations for later use...
             #
             $index = array();
             $tr_statuses = array();
             $tr_sections = array();
             $tr_authors = array();
             for ($i = 0; $i < $n_translations; $i++) {
                 $lang = $translations[$i][L10N_COL_LANG];
                 if (in_array($lang, $langs)) {
                     $n_valid_translations++;
                     $index[$lang] = $i;
                     #
                     #	Record the sections/status/authors for possible filtering...
                     #
                     $tr_sections[$lang] = $translations[$i]['Section'];
                     $tr_statuses[$lang] = $translations[$i]['Status'];
                     $tr_authors[$lang] = $translations[$i]['AuthorID'];
                 } else {
                     continue;
                 }
                 #
                 #	Check that the translation is recorded in the article members!
                 #
                 if (!array_key_exists($lang, $members)) {
                     $this->parent->message = gTxt('l10n-missing_rendition', array('{id}' => $ID));
                     $members[$lang] = (int) $translations[$i]['ID'];
                     MLPArticles::_update_article($ID, $names, $members);
                     $n_valid_translations++;
                 } else {
                     $master_id = (int) $translations[$i]['ID'];
                     $rend_id = (int) $members[$lang];
                     if ($master_id != $members[$lang]) {
                         //echo br , "Found incorrect rendition ID $rend_id in article table. Replacing with ID $master_id.";
                         $members[$lang] = $master_id;
                         MLPArticles::_update_article($ID, $names, $members);
                         $n_valid_translations++;
                     }
                 }
             }
             #
             #	Are all expected translations present?
             #
             $all_translations_present = $n_valid_translations === $full_lang_count;
             #
             #	Apply filters...
             #
             $res = $this->_apply_filter('match_section', $tr_sections, $tr_sections);
             $res = $this->_apply_filter('match_author', $tr_authors, $res);
             $res = $this->_apply_filter('match_status', $tr_statuses, $res);
             if (empty($res)) {
                 continue;
             }
             #
             #	This article has at least one translation that passes the filter so increment the article count...
             #
             $counts['article'] += 1;
             #
             #	Compose the leading (article) cell...
             #
             if ($can_delete) {
                 $delete_art_link = '<a href="' . $this->parent->url(array('page' => $page, 'step' => 'delete_article', 'article' => $ID), true) . '" title="' . gTxt('delete') . ' ' . gTxt('article') . '" class="clone-link" onclick="return verify(\'' . doSlash(gTxt('confirm_delete_popup')) . '\')"><img src="txp_img/l10n_delete.png" /></a>';
             } else {
                 $delete_art_link = '';
             }
             $cells[] = td($delete_art_link . $ID . br . htmlspecialchars($names), '', 'id');
             #
             #	Compose the rest of the row - one cell per translation...
             #
             foreach ($langs as $lang) {
                 if (!array_key_exists($lang, $members)) {
                     if ($lang === $default_lang) {
                         $cells[] = td(gTxt('default') . gTxt('l10n-missing'), $w, 'warning');
                     } else {
                         $cells[] = td('', $w, 'empty');
                     }
                 } else {
                     #
                     #	Ok, there is a translation for this language so...
                     #
                     $tdclass = '';
                     $msg = '';
                     $id = $members[$lang];
                     #
                     #	Get the details for this translation
                     #
                     $i = $index[$lang];
                     $details = $translations[$i];
                     $author = $details['AuthorID'];
                     $status_no = $details['Status'];
                     if ($status_no >= 4) {
                         $num_visible++;
                     }
                     $tdclass .= 'status_' . $status_no;
                     $status = !empty($status_no) ? $this->statuses[$status_no] : '';
                     if (empty($details['Title'])) {
                         $title = '<em>' . eLink('article', 'edit', 'ID', $id, gTxt('untitled')) . '</em>';
                     } else {
                         $title = eLink('article', 'edit', 'ID', $id, $details['Title']);
                     }
                     #
                     #	Check for consistency with the group data...
                     #	Deprecated?
                     if ($details[L10N_COL_LANG] != $lang) {
                         $tdclass .= 'warning';
                         $msg = br . strong(gTxt('l10n-warn_lang_mismatch')) . br . "Art[{$lang}] : tsl[{$details[L10N_COL_LANG]}]";
                     }
                     #
                     #	Grab the section and check for consistency across the row...
                     #
                     $section = $details['Section'];
                     $sections[$section] = $ID;
                     #
                     #	Make a clone link if possible...
                     #
                     if (!$can_clone or $all_translations_present) {
                         $clone_link = '';
                     } else {
                         $clone_link = '<a href="' . $this->parent->url(array('page' => $page, 'step' => 'start_clone', 'rendition' => $id, 'article' => $ID), true) . '" class="clone-link" title="' . gTxt('l10n-clone') . '"><img src="txp_img/l10n_clone.png" /></a>';
                     }
                     #
                     #	Make the delete link...
                     #
                     if ($can_delete) {
                         $delete_trans_link = '<a href="' . $this->parent->url(array('page' => $page, 'step' => 'delete_rendition', 'rendition' => $id), true) . '" title="' . gTxt('delete') . '" class="delete-link" onclick="return verify(\'' . doSlash(gTxt('confirm_delete_popup')) . '\')"><img src="txp_img/l10n_delete.png" /></a>';
                     } else {
                         $delete_trans_link = '';
                     }
                     $content = $delete_trans_link . strong($title) . br . small($section . ' &#8212; ' . $author) . $msg . $clone_link;
                     $cells[] = td($content, $w, trim($tdclass));
                     $counts[$lang] += 1;
                 }
             }
             #
             #	Tag articles which are fully visible or have warnings...
             #
             if (count($sections) != 1) {
                 $trclass .= ' warning';
                 $cells[0] = td($ID . br . gTxt('l10n-warn_section_mismatch'), $w, 'id');
             } else {
                 if ($num_visible == $full_lang_count) {
                     $trclass .= ' fully_visible';
                 }
             }
             $trclass .= 0 == ($counts['article'] & 0x1) ? '' : ' odd';
             $trclass = trim($trclass);
             if (!empty($trclass)) {
                 $trclass = ' class="' . $trclass . '"';
             }
             $css_id = ' id="article_' . $ID . '"';
             $body[] = n . tr(n . join('', $cells), $css_id . $trclass);
         }
     }
     #
     #	Show the counts for the page...
     #
     $show_legend = '1' == $this->pref('l10n-show_legends') ? true : false;
     if ($show_legend) {
         $cells = array();
         $cells[] = td($counts['article'], '', 'id count');
         foreach ($langs as $lang) {
             $cells[] = td($counts[$lang], '', 'count');
         }
         $body[] = n . tr(n . join('', $cells));
         #
         #	Show the table legend...
         #
         $cells = array();
         $l[] = $this->add_legend_item('status_1', $this->statuses[1]);
         $l[] = $this->add_legend_item('status_2', $this->statuses[2] . '/' . gTxt('none'));
         $l[] = $this->add_legend_item('status_3', $this->statuses[3]);
         $l[] = $this->add_legend_item('status_4', $this->statuses[4]);
         $l[] = $this->add_legend_item('status_5', $this->statuses[5]);
         $l[] = br . br;
         $l[] = $this->add_legend_item('fully_visible', gTxt('l10n-legend_fully_visible'));
         $l[] = $this->add_legend_item('warning', gTxt('l10n-legend_warning'));
         if ($can_delete or $can_clone) {
             $l[] = br . br;
         }
         if ($can_delete) {
             $l[] = t . tag('<img src="txp_img/l10n_delete.png" />', 'dt') . n;
             $l[] = t . tag(gTxt('delete'), 'dd') . n;
         }
         if ($can_clone) {
             $l[] = t . tag('<img src="txp_img/l10n_clone.png" />', 'dt') . n;
             $l[] = t . tag(gTxt('l10n-clone'), 'dd') . n;
         }
         $l = tag(n . join('', $l), 'dl');
         $cells[] = tdcs($l, $full_lang_count + 1, '', 'legend');
         $body[] = n . tr(n . join('', $cells));
     }
     $o[] = tag(join('', $body), 'tbody');
     $o[] = endTable();
     $o[] = n . nav_form($event, $page, $numPages, '', '', '', '');
     $o[] = n . pageby_form($event, max(@$article_list_pageby, 15));
     echo join('', $o);
 }
Ejemplo n.º 27
0
function css_edit_form()
{
    global $step;
    $name = gps('name');
    $default_name = safe_field('css', 'txp_section', "name = 'default'");
    $name = (!$name or $step == 'css_delete') ? $default_name : $name;
    if (gps('copy') && trim(preg_replace('/[<>&"\']/', '', gps('newname')))) {
        $name = gps('newname');
    }
    $css = base64_decode(fetch("css", 'txp_css', 'name', $name));
    $css = parseCSS($css);
    $css = $step == 'add_dec' ? add_declaration($css) : $css;
    $css = $step == 'del_dec' ? delete_declaration($css) : $css;
    $css = $step == 'add_sel' ? addSel($css) : $css;
    $right = hed(gTxt('all_stylesheets'), 2) . css_list($name, $default_name);
    $left = graf(gTxt('you_are_editing_css') . br . strong($name)) . graf(eLink('css', 'css_edit_raw', 'name', $name, gTxt('edit_raw_css'))) . graf(sLink('css', 'pour', gTxt('bulkload_existing_css')));
    $out[] = startTable('css-edit', '', '', 3);
    $out[] = tr(td(strong(gTxt('css_selector'))) . td(strong(gTxt('css_property_value'))));
    $i = -1;
    foreach ($css as $selector => $propvals) {
        $out[] = n . '<tr>' . n . td(fInput('text', ++$i, $selector, 'css') . ' ' . aLink('css', 'add_dec', 'selector', $selector, 'name', $name), '', 'selector', 's' . $i);
        if (is_array($propvals)) {
            $out[] = n . t . '<td class="selector2">';
            $ii = -1;
            foreach ($propvals as $property => $value) {
                $out[] = fInput('text', $i . '-' . ++$ii . 'p', $property, 'css') . ' ' . fInput('text', $i . '-' . $ii . 'v', ltrim($value), 'css') . ' ' . dLink('css', 'del_dec', 'declaration', $i . '-' . $ii, '', 'name', $name, 1) . br;
            }
            $out[] = '</td>' . n . '</tr>';
        }
    }
    $out[] = tr(tdcs(fInput('submit', '', gTxt('save'), 'publish'), 2)) . endTable() . eInput('css') . sInput('css_save_posted') . hInput('name', $name);
    echo startTable('edit') . tr(tdtl($left) . td(form(graf(gTxt('add_new_selector') . ': ' . sp . fInput('text', 'selector', '', 'css') . sp . fInput('submit', 'add_sel', gTxt('submit'), 'smallerbox') . eInput('css') . sInput('add_sel') . hInput('name', $name))) . form(join('', $out)) . form(graf(gTxt('copy_css_as') . sp . fInput('text', 'newname', '', 'edit') . sp . fInput('submit', 'copy', gTxt('copy'), 'smallerbox') . eInput('css') . sInput('css_copy') . hInput('oldname', $name) . hInput('name', $name)))) . tdtl($right)) . endTable();
}
Ejemplo n.º 28
0
function cat_event_category_edit($evname)
{
    pagetop(gTxt('categories'));
    $id = assert_int(gps('id'));
    $parent = doSlash(gps('parent'));
    $row = safe_row("*", "txp_category", "id={$id}");
    if ($row) {
        extract($row);
        $out = stackRows(fLabelCell($evname . '_category_name') . fInputCell('name', $name, 1, 20), fLabelCell('parent') . td(cat_parent_pop($parent, $evname, $id)), fLabelCell($evname . '_category_title') . fInputCell('title', $title, 1, 30), hInput('id', $id), tdcs(fInput('submit', '', gTxt('save_button'), 'smallerbox'), 2));
    }
    $out .= eInput('category') . sInput('cat_' . $evname . '_save') . hInput('old_name', $name);
    echo form(startTable('edit') . $out . endTable());
}
Ejemplo n.º 29
0
/**
 * Processes the selected import tool action.
 *
 * Basically does the importing.
 */
function start_import()
{
    global $event, $vars;
    extract(psa($vars));
    $insert_into_section = $import_section;
    $insert_with_status = $import_status;
    $default_comment_invite = $import_comments_invite;
    include_once txpath . '/include/import/import_' . $import_tool . '.php';
    $ini_time = ini_get('max_execution_time');
    @ini_set('max_execution_time', 300 + intval($ini_time));
    switch ($import_tool) {
        case 'mtdb':
            $out = doImportMTDB($importdblogin, $importdb, $importdbpass, $importdbhost, $import_blog_id, $insert_into_section, $insert_with_status, $default_comment_invite);
            rebuild_tree('root', 1, 'article');
            break;
        case 'mt':
            $file = check_import_file();
            if (!empty($file)) {
                $out = doImportMT($file, $insert_into_section, $insert_with_status, $import_comments_invite);
                // Rebuilding category tree.
                rebuild_tree('root', 1, 'article');
            } else {
                $out = 'Import file not found';
            }
            break;
        case 'b2':
            $out = doImportB2($importdblogin, $importdb, $importdbpass, $importdbhost, $insert_into_section, $insert_with_status, $default_comment_invite);
            break;
        case 'wp':
            $out = doImportWP($importdblogin, $importdb, $importdbpass, $importdbhost, $wpdbprefix, $insert_into_section, $insert_with_status, $default_comment_invite, $wpdbcharset);
            rebuild_tree('root', 1, 'article');
            break;
        case 'blogger':
            $file = check_import_file();
            if (!empty($file)) {
                $out = doImportBLOGGER($file, $insert_into_section, $insert_with_status, $import_comments_invite);
            } else {
                $out = gTxt('import_file_not_found');
            }
            break;
    }
    $out = tag('max_execution_time = ' . ini_get('max_execution_time'), 'p', ' class="highlight"') . $out;
    pagetop(gTxt('txp_import'));
    $content = '<div id="' . $event . '_container" class="txp-container">';
    $content .= startTable('', '', 'txp-list');
    $content .= tr(tdcs(hed(gTxt('txp_import'), 2), 2));
    $content .= tr(td($out));
    $content .= endTable();
    $content .= '</div>';
    echo $content;
    $rs = safe_rows_start('parentid, count(*) as thecount', 'txp_discuss', 'visible=1 group by parentid');
    if (numRows($rs) > 0) {
        while ($a = nextRow($rs)) {
            safe_update('textpattern', "comments_count=" . $a['thecount'], "ID=" . $a['parentid']);
        }
    }
}
Ejemplo n.º 30
0
function zem_event_cat_tab_edit()
{
    pagetop(gTxt('categories'));
    $id = assert_int(gps('id'));
    $parent = doSlash(gps('parent'));
    $row = safe_row('*', 'txp_category', "id = {$id}");
    if ($row) {
        extract($row);
        $out = stackRows(fLabelCell(zem_event_gTxt('category_name')) . fInputCell('name', $name, 1, 20), fLabelCell('parent') . td(zem_event_cat_parent_pop($parent, 'event', $id)), fLabelCell(zem_event_gTxt('category_title')) . fInputCell('title', $title, 1, 30), hInput('id', $id), tdcs(fInput('submit', '', gTxt('save_button'), 'smallerbox'), 2));
    }
    echo form(startTable('edit') . $out . eInput('zem_event_cats') . sInput('save') . hInput('old_name', $name) . endTable());
}