Пример #1
0
function css_edit_raw()
{
    global $event, $step;
    $default_name = safe_field('css', 'txp_section', "name = 'default'");
    extract(gpsa(array('name', 'newname', 'copy', 'savenew')));
    if ($step == 'css_delete' || empty($name) && $step != 'pour' && !$savenew) {
        $name = $default_name;
    } elseif (($copy || $savenew) && trim(preg_replace('/[<>&"\']/', '', $newname))) {
        $name = $newname;
    }
    if (empty($name)) {
        $buttons = '<div class="edit-title">' . gTxt('name_for_this_style') . ': ' . fInput('text', 'newname', '', 'edit', '', '', 20) . hInput('savenew', 'savenew') . '</div>';
        $thecss = gps('css');
    } else {
        $buttons = '<div class="edit-title">' . gTxt('you_are_editing_css') . sp . strong(htmlspecialchars($name)) . '</div>';
        $thecss = fetch("css", 'txp_css', 'name', $name);
    }
    if (!empty($name)) {
        $copy = '<span class="copy-as"><label for="copy-css">' . gTxt('copy_css_as') . '</label>' . sp . fInput('text', 'newname', '', 'edit', '', '', '', '', 'copy-css') . sp . fInput('submit', 'copy', gTxt('copy'), 'smallerbox') . '</span>';
    } else {
        $copy = '';
    }
    $right = '<div id="content_switcher">' . hed(gTxt('all_stylesheets'), 2) . graf(sLink('css', 'pour', gTxt('create_new_css')), ' class="action-create smallerbox"') . css_list($name, $default_name) . '</div>';
    echo '<div id="' . $event . '_container" class="txp-container txp-edit">' . startTable('edit') . tr(td(form('<div id="main_content">' . $buttons . '<textarea id="css" class="code" name="css" cols="78" rows="32">' . htmlspecialchars($thecss) . '</textarea>' . br . fInput('submit', '', gTxt('save'), 'publish') . eInput('css') . sInput('css_save') . hInput('name', $name) . $copy . '</div>', '', '', 'post', 'edit-form', '', 'style_form'), '', 'column') . tdtl($right, ' class="column"')) . endTable() . '</div>';
}
Пример #2
0
 /**
  * database function.
  * 
  * @access public
  * @return void
  */
 public function database()
 {
     $this->output->enable_profiler(true);
     $this->load->database();
     $this->load->dbutil();
     $this->load->dbforge();
     $data['title'] = $this->system_model->get('app_name');
     $data['breadcrumbs'] = array(array('data' => anchor('/', $this->system_model->get('app_name')), 'mode' => 'unavailable'), array('data' => anchor('install', ucfirst(lang('install'))), 'mode' => 'unavailable'), array('data' => anchor('install/database', ucfirst(lang('install') . ' ' . lang('database'))), 'mode' => 'current'));
     $html = heading(ucfirst(lang('install')) . ' ' . lang('database'), 1);
     $current = $this->migration->current();
     if (is_null($current)) {
         $html .= div($this->migration->error_string(), 'alert-box error');
     } else {
         $html .= div('Klubb database version: ' . $current, 'alert-box success');
     }
     $tables = $this->db->list_tables();
     foreach ($tables as $table) {
         $fields = $this->db->list_fields($table);
         array_unshift($fields, strong('Fält:'));
         $fields = ul($fields, array('class' => 'inline-list'));
         $html .= div(heading('Tabell: ' . $table, 4) . $fields, 'radius panel');
     }
     $data['html'] = $html;
     $this->system_model->view('template', $data);
 }
Пример #3
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();
}
Пример #4
0
    function messenger($thing, $thething = '', $action = '')
    {
        // $thing[0]: message text
        // $thing[1]: message type, defaults to "success" unless empty or a different flag is set
        if ($thing === '') {
            return '';
        }
        if (!is_array($thing) || !isset($thing[1])) {
            $thing = array($thing, 0);
        }
        switch ($thing[1]) {
            case E_ERROR:
                $class = 'error';
                break;
            case E_WARNING:
                $class = 'warning';
                break;
            default:
                $class = 'success';
                break;
        }
        $html = "<span id='message' class='{$class}'>" . gTxt($thing[0]) . ($thething !== '' ? ' ' . strong($thething) : '') . ($action !== '' ? ' ' . gTxt($action) : '') . '</span>';
        // Try to inject $html into the message pane no matter when messenger()'s output is printed
        $js = addslashes($html);
        $js = <<<EOS
 \t\t\$(document).ready( function(){
\t \t\t\$("#messagepane").html("{$js}");
\t\t\t\$('#messagepane #message.error').fadeOut(800).fadeIn(800);
\t\t\t\$('#messagepane #message.warning').fadeOut(800).fadeIn(800);
\t\t} )
EOS;
        return script_js(str_replace('</', '<\\/', $js), $html);
    }
Пример #5
0
function page_edit_form($name)
{
    global $step;
    $html = safe_field('user_html', 'txp_page', "name='" . doSlash($name) . "'");
    $out[] = '<p>' . gTxt('you_are_editing_page') . sp . strong($name) . br . '<textarea id="html" class="code" name="html" cols="84" rows="36">' . htmlspecialchars($html) . '</textarea>' . br . n . fInput('submit', 'save', gTxt('save'), 'publish') . n . eInput('page') . n . sInput('page_save') . n . hInput('name', $name);
    $out[] = n . '<label for="copy-page">' . gTxt('copy_page_as') . '</label>' . sp . n . fInput('text', 'newname', '', 'edit', '', '', '', '', 'copy-page') . n . fInput('submit', 'copy', gTxt('copy'), 'smallerbox') . '</p>';
    return form(join('', $out));
}
Пример #6
0
function page_edit($message = '')
{
    global $step;
    pagetop(gTxt('edit_pages'), $message);
    extract(gpsa(array('name', 'div')));
    $name = (!$name or $step == 'page_delete') ? 'default' : $name;
    $divline = $step == "div_edit" ? graf(gTxt('you_are_editing_div') . sp . strong($div)) : '';
    echo startTable('edit') . tr(td() . td(graf(gTxt('you_are_editing_page') . sp . strong($name)) . $divline) . td()) . tr(tda(hed(gTxt('useful_tags'), 2) . graf(gTxt('page_article_hed') . br . small(taglinks('page_article')), ' class="column"') . graf(gTxt('page_article_nav_hed') . br . small(taglinks('page_article_nav')), ' class="column"') . graf(gTxt('page_nav_hed') . br . small(taglinks('page_nav')), ' class="column"') . graf(gTxt('page_xml_hed') . br . small(taglinks('page_xml')), ' class="column"') . graf(gTxt('page_misc_hed') . br . small(taglinks('page_misc')), ' class="column"') . graf(gTxt('page_file_hed') . br . small(taglinks('page_file')), ' class="column"')) . tda(page_edit_form($name), ' class="column"') . tda(hed(gTxt('all_pages'), 2) . page_list($name), ' class="column"')) . endTable();
}
Пример #7
0
function printConfig()
{
    $carry = enumPostItems('ddb', 'duser', 'dpass', 'dhost', 'dprefix', 'txprefix', 'txpath', 'doc_root', 'ftphost', 'ftplogin', 'ftpass', 'ftpath');
    $carry['txpath'] = preg_replace("/^(.*)\\/\$/", "\$1", $carry['txpath']);
    $carry['doc_root'] = preg_replace("/^(.*)\\/\$/", "\$1", $carry['doc_root']);
    $carry['ftpath'] = preg_replace("/^(.*)\\/\$/", "\$1", $carry['ftpath']);
    extract($carry);
    echo graf("Checking database connection...");
    if (!($mylink = mysql_connect($dhost, $duser, $dpass))) {
        exit(graf("Can't connect to the database with the values entered."));
    }
    echo graf('Connected.');
    if (!($mydb = mysql_select_db($ddb))) {
        exit(graf("Database " . strong($ddb) . " doesn't exist. Please create it or choose another."));
    }
    echo graf("Using database " . strong($ddb)), graf(strong('Before you proceed') . ', open <code>config.php</code> in the <code>/textpattern/</code> directory and replace its contents with the following:'), '<textarea style="width:400px;height:200px" name="config" rows="1" cols="1">', makeConfig($carry), '</textarea>', '<form action="setup.php" method="post">', fInput('submit', 'submit', 'I did it', 'smallbox'), sInput('getTxpLogin'), hInput('carry', postEncode($carry)), '</form>';
}
Пример #8
0
function page_edit_form($name)
{
    global $step;
    if ($step == 'div_edit') {
        list($html_array, $html, $start_pos, $stop_pos) = extract_div();
        $html_array = serialize($html_array);
        $outstep = 'div_save';
    } else {
        $html = safe_field('user_html', 'txp_page', "name='" . doSlash($name) . "'");
        $outstep = 'page_save';
    }
    $divline = $step == 'div_edit' ? graf(gTxt('you_are_editing_div') . sp . strong($div)) : '';
    $out[] = '<p>' . gTxt('you_are_editing_page') . sp . strong($name) . $divline . br . '<textarea id="html" class="code" name="html" cols="84" rows="36">' . htmlspecialchars($html) . '</textarea>' . br . n . fInput('submit', 'save', gTxt('save'), 'publish') . n . eInput('page') . n . sInput($outstep) . n . hInput('name', $name);
    if ($step == 'div_edit') {
        $out[] = n . hInput('html_array', $html_array) . n . hInput('start_pos', $start_pos) . n . hInput('stop_pos', $stop_pos) . n . hInput('name', $name);
    } else {
        $out[] = n . '<label for="copy-page">' . gTxt('copy_page_as') . '</label>' . sp . n . fInput('text', 'newname', '', 'edit', '', '', '', '', 'copy-page') . n . fInput('submit', 'copy', gTxt('copy'), 'smallerbox') . '</p>';
    }
    return form(join('', $out));
}
Пример #9
0
function page_edit_form($name)
{
    global $step;
    if ($name) {
        $html = safe_field('user_html', 'txp_page', "name='" . doSlash($name) . "'");
    } else {
        $html = gps('html');
    }
    if (empty($name)) {
        $buttons = '<div class="edit-title">' . gTxt('name_for_this_page') . ': ' . fInput('text', 'newname', '', '', '', '', INPUT_REGULAR) . hInput('savenew', 'savenew') . '</div>';
    } else {
        $buttons = '<div class="edit-title">' . gTxt('you_are_editing_page') . sp . strong(txpspecialchars($name)) . '</div>';
    }
    $out[] = '<div id="main_content">' . $buttons . '<textarea id="html" class="code" name="html" cols="' . INPUT_LARGE . '" rows="' . INPUT_REGULAR . '">' . txpspecialchars($html) . '</textarea>' . n . '<p>' . fInput('submit', 'save', gTxt('save'), 'publish') . n . eInput('page') . n . sInput('page_save') . n . hInput('name', $name) . '</p>';
    if (!empty($name)) {
        $out[] = n . '<p class="copy-as"><label for="copy-page">' . gTxt('copy_page_as') . '</label>' . n . fInput('text', 'newname', '', 'input-medium', '', '', INPUT_MEDIUM, '', 'copy-page') . n . fInput('submit', 'copy', gTxt('copy')) . '</p>';
    }
    $out[] = '</div>';
    return form(join('', $out), '', '', 'post', '', '', 'page_form');
}
Пример #10
0
function page_edit_form($name)
{
    global $step;
    if ($name) {
        $html = safe_field('user_html', 'txp_page', "name='" . doSlash($name) . "'");
    } else {
        $html = gps('html');
    }
    if (empty($name)) {
        $buttons = '<div class="edit-title">' . gTxt('name_for_this_page') . ': ' . fInput('text', 'newname', '', 'edit', '', '', 20) . hInput('savenew', 'savenew') . '</div>';
    } else {
        $buttons = '<div class="edit-title">' . gTxt('you_are_editing_page') . sp . strong(htmlspecialchars($name)) . '</div>';
    }
    $out[] = '<div id="main_content">' . $buttons . '<textarea id="html" class="code" name="html" cols="84" rows="36">' . htmlspecialchars($html) . '</textarea>' . br . n . fInput('submit', 'save', gTxt('save'), 'publish') . n . eInput('page') . n . sInput('page_save') . n . hInput('name', $name);
    if (!empty($name)) {
        $out[] = n . '<span class="copy-as"><label for="copy-page">' . gTxt('copy_page_as') . '</label>' . sp . n . fInput('text', 'newname', '', 'edit', '', '', '', '', 'copy-page') . n . fInput('submit', 'copy', gTxt('copy'), 'smallerbox') . '</span>';
    }
    $out[] = '</div>';
    return form(join('', $out), '', '', 'post', '', '', 'page_form');
}
Пример #11
0
function author_edit()
{
    global $step, $txp_user;
    require_privs('admin.edit');
    pagetop(gTxt('tab_site_admin'), '');
    $vars = array('user_id', 'name', 'RealName', 'email', 'privs');
    $rs = array();
    extract(gpsa($vars));
    $is_edit = $user_id && $step == 'author_edit';
    if ($is_edit) {
        $user_id = assert_int($user_id);
        $rs = safe_row('*', 'txp_users', "user_id = {$user_id}");
        extract($rs);
    }
    $caption = gTxt($is_edit ? 'edit_author' : 'add_new_author');
    echo form('<div class="txp-edit">' . n . hed($caption, 2) . n . inputLabel('login_name', $is_edit ? strong($name) : fInput('text', 'name', $name, '', '', '', INPUT_REGULAR, '', 'login_name'), $is_edit ? '' : 'login_name', $is_edit ? '' : 'add_new_author') . n . inputLabel('real_name', fInput('text', 'RealName', $RealName, '', '', '', INPUT_REGULAR, '', 'real_name'), 'real_name') . n . inputLabel('login_email', fInput('text', 'email', $email, '', '', '', INPUT_REGULAR, '', 'login_email'), 'email') . n . inputLabel('privileges', $txp_user != $name ? privs($privs) : hInput('privs', $privs) . strong(get_priv_level($privs)), $is_edit ? '' : 'privileges', 'about_privileges') . n . pluggable_ui('author_ui', 'extend_detail_form', '', $rs) . n . graf(fInput('submit', '', gTxt('save'), 'publish')) . eInput('admin') . ($user_id ? hInput('user_id', $user_id) . sInput('author_save') : sInput('author_save_new')) . '</div>', '', '', 'post', 'edit-form', '', 'user_edit');
}
Пример #12
0
function form_edit($message = '')
{
    global $event, $step, $essential_forms;
    pagetop(gTxt('edit_forms'), $message);
    extract(gpsa(array('Form', 'name', 'type')));
    $name = trim(preg_replace('/[<>&"\']/', '', $name));
    if ($step == 'form_create') {
        $inputs = fInput('submit', 'savenew', gTxt('save_new'), 'publish') . eInput("form") . sInput('form_save');
    } else {
        $name = (!$name or $step == 'form_delete') ? 'default' : $name;
        $rs = safe_row("*", "txp_form", "name='" . doSlash($name) . "'");
        extract($rs);
        $inputs = fInput('submit', 'save', gTxt('save'), 'publish') . eInput("form") . sInput('form_save') . hInput('oldname', $name);
    }
    if (!in_array($name, $essential_forms)) {
        $changename = graf(gTxt('form_name') . br . fInput('text', 'name', $name, 'edit', '', '', INPUT_REGULAR));
    } else {
        $changename = graf(gTxt('form_name') . br . tag($name, 'em') . hInput('name', $name));
    }
    // Generate the tagbuilder links
    // Format of each entry is popTagLink -> array ( gTxt string, class/ID )
    $tagbuild_items = array('article' => array('articles', 'article-tags'), 'link' => array('links', 'link-tags'), 'comment' => array('comments', 'comment-tags'), 'comment_details' => array('comment_details', 'comment-detail-tags'), 'comment_form' => array('comment_form', 'comment-form-tags'), 'search_result' => array('search_results_form', 'search-result-tags'), 'file_download' => array('file_download_tags', 'file-tags'), 'category' => array('category_tags', 'category-tags'), 'section' => array('section_tags', 'section-tags'));
    $tagbuild_links = '';
    foreach ($tagbuild_items as $tb => $item) {
        $tagbuild_links .= '<div class="' . $item[1] . '">' . hed('<a href="#' . $item[1] . '">' . gTxt($item[0]) . '</a>', 3, ' class="lever' . (get_pref('pane_form_' . $item[1] . '_visible') ? ' expanded' : '') . '"') . '<div id="' . $item[1] . '" class="toggle on" style="display:' . (get_pref('pane_form_' . $item[1] . '_visible') ? 'block' : 'none') . '">' . popTagLinks($tb) . '</div></div>';
    }
    $out = '<h1 class="txp-heading">' . gTxt('tab_forms') . sp . popHelp('forms_overview') . '</h1>' . '<div id="' . $event . '_container" class="txp-container">' . startTable('', '', 'txp-columntable') . tr(tdtl('<div id="tagbuild_links">' . hed(gTxt('tagbuilder'), 2) . $tagbuild_links . '</div>', ' class="column"') . tdtl('<form action="index.php" method="post" id="form_form">' . '<div id="main_content">' . '<div class="edit-title">' . gTxt('you_are_editing_form') . sp . strong($name ? $name : gTxt('untitled')) . '</div>' . '<textarea id="form" class="code" name="Form" cols="' . INPUT_LARGE . '" rows="' . INPUT_REGULAR . '">' . txpspecialchars($Form) . '</textarea>' . $changename . graf(gTxt('form_type') . br . formtypes($type)) . (empty($type) ? graf(gTxt('only_articles_can_be_previewed')) : '') . (empty($type) || $type == 'article' ? fInput('submit', 'form_preview', gTxt('preview')) : '') . graf($inputs) . '</div>' . n . tInput() . n . '</form>', ' class="column"') . tdtl('<div id="content_switcher">' . hed(gTxt('all_forms'), 2) . form_list($name) . '</div>', ' class="column"')) . endTable() . '</div>';
    echo $out;
}
Пример #13
0
function missing_section_file()
{
    global $txpcfg;
    pageTop('missing section placeholder');
    $name = gps('name');
    $out = array(startTable("edit"), tr(tda(graf(gTxt('section_warning_part1') . ' ' . strong($name) . ' ' . gTxt('section_warning_part2') . ' ' . $txpcfg['doc_root'] . ' ' . gTxt('section_warning_part3') . ':') . graf('<textarea cols="50" rows="7">' . file_snip($name) . '</textarea>') . graf(gTxt('section_warning_part4') . ' <code>.htaccess</code> ' . gTxt('section_warning_part5') . ' ' . $txpcfg['doc_root'] . ' ' . gTxt('section_warning_part6') . ':') . graf('<textarea cols="50" rows="4">' . htaccess_snip($name) . '</textarea>'), ' width="500px"')), endTable());
    echo join('', $out);
}
Пример #14
0
function radio_list($name, $values, $current_val = '', $hilight_val = '')
{
    // $values is an array of value => label pairs
    foreach ($values as $k => $v) {
        $id = $name . '-' . $k;
        $out[] = n . t . '<li class="status-' . $k . ' ' . $v . ($hilight_val == $k ? ' active' : '') . '">' . radio($name, $k, $current_val == $k ? 1 : 0, $id) . '<label for="' . $id . '">' . ($hilight_val == $k ? strong($v) : $v) . '</label></li>';
    }
    return '<ul class="status plain-list">' . join('', $out) . n . '</ul>';
}
Пример #15
0
function getTxpLogin()
{
    $carry = postDecode(ps('carry'));
    extract($carry);
    $GLOBALS['textarray'] = setup_load_lang($lang);
    @(include txpath . '/config.php');
    if (!isset($txpcfg) || $txpcfg['db'] != $ddb || $txpcfg['table_prefix'] != $dprefix) {
        echo graf(strong(gTxt('before_you_proceed')) . ', ' . gTxt('create_config', array('{txpath}' => txpath))), '<textarea style="width:400px;height:200px" name="config" rows="1" cols="1">', makeConfig($carry), '</textarea>', '<form action="' . $GLOBALS['rel_siteurl'] . '/textpattern/setup/index.php" method="post">', fInput('submit', 'submit', gTxt('did_it'), 'smallbox'), sInput('getTxpLogin'), hInput('carry', postEncode($carry)), '</form>';
        return;
    }
    echo '<form action="' . $GLOBALS['rel_siteurl'] . '/textpattern/setup/index.php" method="post">', startTable('edit'), tr(tda(graf(gTxt('thanks')) . graf(gTxt('about_to_create')), ' width="400" colspan="2" align="center"')), tr(fLabelCell(gTxt('your_full_name')) . fInputCell('RealName')), tr(fLabelCell(gTxt('setup_login')) . fInputCell('name')), tr(fLabelCell(gTxt('choose_password')) . fInputCell('pass')), tr(fLabelCell(gTxt('your_email')) . fInputCell('email')), tr(td() . td(fInput('submit', 'Submit', gTxt('next'), 'publish'))), endTable(), sInput('createTxp'), hInput('lang', htmlspecialchars($lang)), hInput('siteurl', htmlspecialchars($siteurl)), '</form>';
}
Пример #16
0
function load_plugins($type = 0)
{
    global $prefs, $plugins, $plugins_ver;
    if (!is_array($plugins)) {
        $plugins = array();
    }
    if (!empty($prefs['plugin_cache_dir'])) {
        $dir = rtrim($prefs['plugin_cache_dir'], '/') . '/';
        // in case it's a relative path
        if (!is_dir($dir)) {
            $dir = rtrim(realpath(txpath . '/' . $dir), '/') . '/';
        }
        $files = glob($dir . '*.php');
        if ($files) {
            natsort($files);
            foreach ($files as $f) {
                load_plugin(basename($f, '.php'));
            }
        }
    }
    $where = 'status = 1 AND type IN (' . ($type ? '1,3' : '0,1') . ')';
    $rs = safe_rows("name, code, version", "txp_plugin", $where . ' order by load_order');
    if ($rs) {
        $old_error_handler = set_error_handler("pluginErrorHandler");
        foreach ($rs as $a) {
            if (!in_array($a['name'], $plugins)) {
                $plugins[] = $a['name'];
                $plugins_ver[$a['name']] = $a['version'];
                $GLOBALS['txp_current_plugin'] = $a['name'];
                $eval_ok = eval($a['code']);
                if ($eval_ok === FALSE) {
                    echo gTxt('plugin_load_error_above') . strong($a['name']) . n . br;
                }
                unset($GLOBALS['txp_current_plugin']);
            }
        }
        restore_error_handler();
    }
}
Пример #17
0
function get_language()
{
    global $prefs, $txpcfg, $textarray;
    require_once txpath . '/lib/IXRClass.php';
    $lang_code = gps('lang_code');
    $client = new IXR_Client(RPC_SERVER);
    //		$client->debug = true;
    @set_time_limit(90);
    if (gps('force') == 'file' || !$client->query('tups.getLanguage', $prefs['blog_uid'], $lang_code)) {
        if ((gps('force') == 'file' || gps('updating') !== '1') && install_language_from_file($lang_code)) {
            if (defined('LANG')) {
                $textarray = load_lang(LANG);
            }
            return list_languages(gTxt($lang_code) . sp . gTxt('updated'));
        } else {
            $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.';
            }
            pagetop(gTxt('installing_language'));
            echo tag(gTxt('rpc_connect_error') . "<!--" . $client->getErrorCode() . ' ' . $client->getErrorMessage() . "-->", 'p', ' style="text-align:center;color:red;width:50%;margin: 2em auto"');
            echo tag($install_langfile, 'p', ' style="text-align:center;width:50%;margin: 2em auto"');
        }
    } else {
        $response = $client->getResponse();
        $lang_struct = unserialize($response);
        function install_lang_key(&$value, $key)
        {
            extract(gpsa(array('lang_code', 'updating')));
            $exists = safe_field('name', 'txp_lang', "name='" . doSlash($value['name']) . "' AND lang='" . doSlash($lang_code) . "'");
            $q = "name='" . doSlash($value['name']) . "', event='" . doSlash($value['event']) . "', data='" . doSlash($value['data']) . "', lastmod='" . doSlash(strftime('%Y%m%d%H%M%S', $value['uLastmod'])) . "'";
            if ($exists) {
                $value['ok'] = safe_update('txp_lang', $q, "lang='" . doSlash($lang_code) . "' AND name='" . doSlash($value['name']) . "'");
            } else {
                $value['ok'] = safe_insert('txp_lang', $q . ", lang='" . doSlash($lang_code) . "'");
            }
        }
        array_walk($lang_struct, 'install_lang_key');
        $size = count($lang_struct);
        $errors = 0;
        for ($i = 0; $i < $size; $i++) {
            $errors += !$lang_struct[$i]['ok'];
        }
        if (defined('LANG')) {
            $textarray = load_lang(LANG);
        }
        $msg = gTxt($lang_code) . sp . gTxt('updated');
        if ($errors > 0) {
            $msg .= sprintf(" (%s errors, %s ok)", $errors, $size - $errors);
        }
        return list_languages($msg);
    }
}
Пример #18
0
/**
 * Generates a &lt;table&gt; of every language that Textpattern supports.
 *
 * If requested with HTTP POST parameter 'force' set anything other than 'file',
 * outputs any errors in RPC server connection.
 *
 * @param string|array $message The activity message
 */
function list_languages($message = '')
{
    require_once txpath . '/lib/IXRClass.php';
    $active_lang = safe_field("val", 'txp_prefs', "name = 'language'");
    $lang_form = tag(form(tag(gTxt('active_language'), 'label', array('for' => 'language')) . languages('language', $active_lang) . eInput('lang') . sInput('save_language')), 'div', array('class' => 'txp-control-panel'));
    $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);
    // TODO: 90 seconds: seriously?
    if ($client->query('tups.listLanguages', get_pref('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 (is_array($files) && !empty($files)) {
        foreach ($files as $file) {
            if ($fp = @fopen(txpath . DS . 'lang' . DS . $file, 'r')) {
                $name = preg_replace('/\\.(txt|textpack)$/i', '', $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.
    // 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 = 1 GROUP BY lang ORDER BY lastmod DESC");
    $installed_lang = array();
    foreach ($rows as $language) {
        $available_lang[$language['lang']]['db_lastmod'] = $language['lastmod'];
        if ($language['lang'] != $active_lang) {
            $installed_lang[] = $language['lang'];
        }
    }
    $list = '';
    // Create the language table components.
    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($rpc_updated ? strong(eLink('lang', 'get_language', 'lang_code', $langname, isset($langdat['db_lastmod']) ? gTxt('update') : gTxt('install'), 'updating', isset($langdat['db_lastmod']), '')) . n . span(safe_strftime('%d %b %Y %X', @$langdat['rpc_lastmod']), array('class' => 'date modified')) : (isset($langdat['rpc_lastmod']) ? gTxt('up_to_date') : '-') . (isset($langdat['db_lastmod']) ? n . span(safe_strftime('%d %b %Y %X', $langdat['db_lastmod']), array('class' => 'date modified')) : ''), isset($langdat['db_lastmod']) && $rpc_updated ? ' class="highlight lang-value"' : ' class="lang-value"');
        $lang_file = tda(isset($langdat['file_lastmod']) ? strong(eLink('lang', 'get_language', 'lang_code', $langname, $file_updated ? gTxt('update') : gTxt('install'), 'force', 'file', '')) . n . span(safe_strftime(get_pref('archive_dateformat'), $langdat['file_lastmod']), array('class' => 'date ' . ($file_updated ? 'created' : 'modified'))) : '-', ' class="lang-value languages_detail' . (isset($langdat['db_lastmod']) && $rpc_updated ? ' highlight' : '') . '"');
        $list .= tr(hCell(gTxt($langname), '', isset($langdat['db_lastmod']) && $rpc_updated ? ' class="highlight lang-label" scope="row"' : ' class="lang-label" scope="row"') . n . $rpc_install . n . $lang_file . tda(in_array($langname, $installed_lang) ? dLink('lang', 'remove_language', 'lang_code', $langname, 1) : '-', ' class="languages_detail' . (isset($langdat['db_lastmod']) && $rpc_updated ? ' highlight' : '') . '"')) . n;
    }
    // Output table and content.
    pagetop(gTxt('tab_languages'), $message);
    echo n . tag(hed(gTxt('tab_languages'), 1, array('class' => 'txp-heading')), 'div', array('class' => 'txp-layout-2col-cell-1')) . n . tag_start('div', array('class' => 'txp-layout-1col', 'id' => 'language_container'));
    if (isset($msg) && $msg) {
        echo graf('<span class="ui-icon ui-icon-closethick"></span> ' . $msg, array('class' => 'alert-block error'));
    }
    echo $lang_form, n . tag(toggle_box('languages_detail'), 'div', array('class' => 'txp-list-options')) . n . tag_start('div', array('class' => 'txp-listtables')) . n . tag_start('table', array('class' => 'txp-list')) . n . tag_start('thead') . tr(hCell(gTxt('language'), '', ' scope="col"') . hCell(gTxt('from_server') . popHelp('install_lang_from_server'), '', ' scope="col"') . hCell(gTxt('from_file') . popHelp('install_lang_from_file'), '', ' class="languages_detail" scope="col"') . hCell(gTxt('remove_lang') . popHelp('remove_lang'), '', ' class="languages_detail" scope="col"')) . n . tag_end('thead') . n . tag_start('tbody') . $list . n . tag_end('tbody') . n . tag_end('table') . n . tag_end('div') . hed(gTxt('install_from_textpack'), 2) . n . tag(form('<label for="textpack-install">' . gTxt('install_textpack') . '</label>' . popHelp('get_textpack') . n . '<textarea class="code" id="textpack-install" name="textpack" cols="' . INPUT_LARGE . '" rows="' . TEXTAREA_HEIGHT_SMALL . '" dir="ltr"></textarea>' . fInput('submit', 'install_new', gTxt('upload')) . eInput('lang') . sInput('get_textpack'), '', '', 'post', '', '', 'text_uploader'), 'div', array('class' => 'txp-control-panel')) . n . tag_end('div');
}
Пример #19
0
function css_edit_raw()
{
    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');
    }
    if ($step == 'pour') {
        $buttons = gTxt('name_for_this_style') . ': ' . fInput('text', 'newname', '', 'edit', '', '', 20) . hInput('savenew', 'savenew');
        $thecss = '';
    } else {
        $buttons = '';
        $thecss = base64_decode(fetch("css", 'txp_css', 'name', $name));
    }
    if ($step != 'pour') {
        $left = graf(gTxt('you_are_editing_css') . br . strong($name)) . graf(eLink('css', 'css_edit_form', 'name', $name, gTxt('edit_css_in_form'))) . graf(sLink('css', 'pour', gTxt('bulkload_existing_css')));
        $copy = gTxt('copy_css_as') . sp . fInput('text', 'newname', '', 'edit') . sp . fInput('submit', 'copy', gTxt('copy'), 'smallerbox');
    } else {
        $left = '&nbsp;';
        $copy = '';
    }
    $right = hed(gTxt('all_stylesheets'), 2) . css_list($name, $default_name);
    echo startTable('edit') . tr(tdtl($left) . td(form(graf($buttons) . '<textarea id="css" class="code" name="css" cols="78" rows="32">' . htmlspecialchars($thecss) . '</textarea>' . br . fInput('submit', '', gTxt('save'), 'publish') . eInput('css') . sInput('css_save') . hInput('name', $name) . $copy)) . tdtl($right)) . endTable();
}
Пример #20
0
function setup_config_contents()
{
    return hed(setup_gTxt('creating_config'), 2) . graf(strong(setup_gTxt('before_you_proceed')) . ' ' . setup_gTxt('create_config', array('{txpath}' => txpspecialchars(txpath)))) . '<textarea class="code" readonly="readonly" name="config" cols="' . INPUT_LARGE . '" rows="' . INPUT_MEDIUM . '">' . makeConfig() . '</textarea>' . '<form action="' . txpspecialchars($_SERVER['PHP_SELF']) . '" method="post">' . graf(fInput('submit', 'submit', setup_gTxt('did_it'), 'publish')) . sInput('getTxpLogin') . '</form>';
}
Пример #21
0
<?php

/*
	This is Textpattern
	Copyright 2005 by Dean Allen
 	All rights reserved.
	Use of this software indicates acceptance of the Textpattern license agreement
$HeadURL$
$LastChangedRevision$
*/
if (!defined('txpinterface')) {
    die('txpinterface is undefined.');
}
global $vars, $statuses;
$vars = array('ID', 'Title', 'Title_html', 'Body', 'Body_html', 'Excerpt', 'textile_excerpt', 'Image', 'textile_body', 'Keywords', 'Status', 'Posted', 'Expires', 'Section', 'Category1', 'Category2', 'Annotate', 'AnnotateInvite', 'publish_now', 'reset_time', 'AuthorID', 'sPosted', 'LastModID', 'sLastMod', 'override_form', 'from_view', 'year', 'month', 'day', 'hour', 'minute', 'second', 'url_title', 'custom_1', 'custom_2', 'custom_3', 'custom_4', 'custom_5', 'custom_6', 'custom_7', 'custom_8', 'custom_9', 'custom_10', 'exp_year', 'exp_month', 'exp_day', 'exp_hour', 'exp_minute', 'exp_second', 'sExpires');
$statuses = array(1 => gTxt('draft'), 2 => gTxt('hidden'), 3 => gTxt('pending'), 4 => strong(gTxt('live')), 5 => gTxt('sticky'));
if (!empty($event) and $event == 'article') {
    require_privs('article');
    $save = gps('save');
    if ($save) {
        $step = 'save';
    }
    $publish = gps('publish');
    if ($publish) {
        $step = 'publish';
    }
    switch (strtolower($step)) {
        case "":
            article_edit();
            break;
        case "create":
Пример #22
0
/**
 * The main panel listing all log hits.
 *
 * @param string|array $message The activity message
 */
function log_list($message = '')
{
    global $event, $log_list_pageby, $expire_logs_after;
    pagetop(gTxt('tab_logs'), $message);
    extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method')));
    if ($sort === '') {
        $sort = get_pref('log_sort_column', 'time');
    } else {
        if (!in_array($sort, array('ip', 'host', 'page', 'refer', 'method', 'status'))) {
            $sort = 'time';
        }
        set_pref('log_sort_column', $sort, 'log', 2, '', 0, PREF_PRIVATE);
    }
    if ($dir === '') {
        $dir = get_pref('log_sort_dir', 'desc');
    } else {
        $dir = $dir == 'asc' ? "asc" : "desc";
        set_pref('log_sort_dir', $dir, 'log', 2, '', 0, PREF_PRIVATE);
    }
    $expire_logs_after = assert_int($expire_logs_after);
    safe_delete('txp_log', "time < DATE_SUB(NOW(), INTERVAL {$expire_logs_after} DAY)");
    switch ($sort) {
        case 'ip':
            $sort_sql = "ip {$dir}";
            break;
        case 'host':
            $sort_sql = "host {$dir}";
            break;
        case 'page':
            $sort_sql = "page {$dir}";
            break;
        case 'refer':
            $sort_sql = "refer {$dir}";
            break;
        case 'method':
            $sort_sql = "method {$dir}";
            break;
        case 'status':
            $sort_sql = "status {$dir}";
            break;
        default:
            $sort = 'time';
            $sort_sql = "time {$dir}";
            break;
    }
    $switch_dir = $dir == 'desc' ? 'asc' : 'desc';
    $search = new Filter($event, array('ip' => array('column' => 'txp_log.ip', 'label' => gTxt('IP')), 'host' => array('column' => 'txp_log.host', 'label' => gTxt('host')), 'page' => array('column' => 'txp_log.page', 'label' => gTxt('page')), 'refer' => array('column' => 'txp_log.refer', 'label' => gTxt('referrer')), 'method' => array('column' => 'txp_log.method', 'label' => gTxt('method')), 'status' => array('column' => 'txp_log.status', 'label' => gTxt('status'), 'type' => 'integer')));
    list($criteria, $crit, $search_method) = $search->getFilter(array('status' => array('can_list' => true)));
    $search_render_options = array('placeholder' => 'search_logs');
    $total = safe_count('txp_log', "{$criteria}");
    echo n . tag(hed(gTxt('tab_logs'), 1, array('class' => 'txp-heading')), 'div', array('class' => 'txp-layout-2col-cell-1'));
    $searchBlock = n . tag($search->renderForm('log_list', $search_render_options), 'div', array('class' => 'txp-layout-2col-cell-2', 'id' => $event . '_control'));
    $contentBlockStart = n . tag_start('div', array('class' => 'txp-layout-1col', 'id' => $event . '_container'));
    if ($total < 1) {
        if ($criteria != 1) {
            echo $searchBlock . $contentBlockStart . graf(span(null, array('class' => 'ui-icon ui-icon-info')) . ' ' . gTxt('no_results_found'), array('class' => 'alert-block information'));
        } else {
            echo $contentBlockStart . graf(span(null, array('class' => 'ui-icon ui-icon-info')) . ' ' . gTxt('no_refers_recorded'), array('class' => 'alert-block information'));
        }
        echo n . tag_end('div');
        return;
    }
    $limit = max($log_list_pageby, 15);
    list($page, $offset, $numPages) = pager($total, $limit, $page);
    echo $searchBlock . $contentBlockStart;
    $rs = safe_rows_start("*, UNIX_TIMESTAMP(time) AS uTime", 'txp_log', "{$criteria} ORDER BY {$sort_sql} LIMIT {$offset}, {$limit}");
    if ($rs) {
        echo n . tag(toggle_box('log_detail'), 'div', array('class' => 'txp-list-options')) . n . tag_start('form', array('class' => 'multi_edit_form', 'id' => 'log_form', 'name' => 'longform', 'method' => 'post', 'action' => 'index.php')) . n . tag_start('div', array('class' => 'txp-listtables')) . n . tag_start('table', array('class' => 'txp-list')) . n . tag_start('thead') . tr(hCell(fInput('checkbox', 'select_all', 0, '', '', '', '', '', 'select_all'), '', ' class="txp-list-col-multi-edit" scope="col" title="' . gTxt('toggle_all_selected') . '"') . column_head('time', 'time', 'log', true, $switch_dir, $crit, $search_method, ('time' == $sort ? "{$dir} " : '') . 'txp-list-col-time') . column_head('IP', 'ip', 'log', true, $switch_dir, $crit, $search_method, ('ip' == $sort ? "{$dir} " : '') . 'txp-list-col-ip') . column_head('host', 'host', 'log', true, $switch_dir, $crit, $search_method, ('host' == $sort ? "{$dir} " : '') . 'txp-list-col-host log_detail') . column_head('page', 'page', 'log', true, $switch_dir, $crit, $search_method, ('page' == $sort ? "{$dir} " : '') . 'txp-list-col-page') . column_head('referrer', 'refer', 'log', true, $switch_dir, $crit, $search_method, ('refer' == $sort ? "{$dir} " : '') . 'txp-list-col-refer') . column_head('method', 'method', 'log', true, $switch_dir, $crit, $search_method, ('method' == $sort ? "{$dir} " : '') . 'txp-list-col-method log_detail') . column_head('status', 'status', 'log', true, $switch_dir, $crit, $search_method, ('status' == $sort ? "{$dir} " : '') . 'txp-list-col-status log_detail')) . n . tag_end('thead') . n . tag_start('tbody');
        while ($a = nextRow($rs)) {
            extract($a, EXTR_PREFIX_ALL, 'log');
            if ($log_refer) {
                $log_refer = href(txpspecialchars(soft_wrap(preg_replace('#^http://#', '', $log_refer), 30)), txpspecialchars($log_refer), ' target="_blank"');
            }
            if ($log_page) {
                $log_anchor = preg_replace('/\\/$/', '', $log_page);
                $log_anchor = soft_wrap(substr($log_anchor, 1), 30);
                $log_page = href(txpspecialchars($log_anchor), txpspecialchars($log_page), ' target="_blank"');
                if ($log_method == 'POST') {
                    $log_page = strong($log_page);
                }
            }
            echo tr(td(fInput('checkbox', 'selected[]', $log_id), '', 'txp-list-col-multi-edit') . hCell(gTime($log_uTime), '', ' class="txp-list-col-time" scope="row"') . td(href(txpspecialchars($log_ip), 'https://whois.domaintools.com/' . rawurlencode($log_ip), array('rel' => 'external', 'target' => '_blank')), '', 'txp-list-col-ip') . td(txpspecialchars($log_host), '', 'txp-list-col-host log_detail') . td($log_page, '', 'txp-list-col-page') . td($log_refer, '', 'txp-list-col-refer') . td(txpspecialchars($log_method), '', 'txp-list-col-method log_detail') . td($log_status, '', 'txp-list-col-status log_detail'));
        }
        echo n . tag_end('tbody') . n . tag_end('table') . n . tag_end('div') . log_multiedit_form($page, $sort, $dir, $crit, $search_method) . tInput() . n . tag_end('form') . n . tag_start('div', array('class' => 'txp-navigation', 'id' => $event . '_navigation')) . pageby_form('log', $log_list_pageby) . nav_form('log', $page, $numPages, $sort, $dir, $crit, $search_method, $total, $limit) . n . tag_end('div');
    }
    echo n . tag_end('div');
}
Пример #23
0
function doImportMTDB($mt_dblogin, $mt_db, $mt_dbpass, $mt_dbhost, $blog_id, $insert_into_section, $insert_with_status, $default_comment_invite)
{
    global $txpcfg;
    //Keep some response on some part
    $results = array();
    //Avoid left joins
    $authors_map = array();
    $categories_map = array();
    // let's go - Dean says ;-).
    $mtlink = mysql_connect($mt_dbhost, $mt_dblogin, $mt_dbpass, true);
    if (!$mtlink) {
        return 'mt database values don&#8217;t work. Please replace them and try again';
    }
    mysql_select_db($mt_db, $mtlink);
    $results[] = 'connected to mt database. Importing Data';
    sleep(2);
    $a = mysql_query("\n\t\t\tselect\n\t\t\tauthor_id as user_id,\n\t\t\tauthor_nickname as name,\n\t\t\tauthor_name as RealName,\n\t\t\tauthor_email as email,\n\t\t\tauthor_password as pass\n\t\t\tfrom mt_author\n\t\t", $mtlink);
    while ($b = mysql_fetch_assoc($a)) {
        $authors[] = $b;
    }
    $a = mysql_query("\n\t\t\tselect\n\t\t\tmt_entry.entry_id as ID,\n\t\t\tmt_entry.entry_text as Body,\n\t\t\tmt_entry.entry_text_more as Body2,\n\t\t\tmt_entry.entry_title as Title,\n\t\t\tmt_entry.entry_excerpt as Excerpt,\n\t\t\tmt_entry.entry_keywords as Keywords,\n\t\t\tmt_entry.entry_created_on as Posted,\n\t\t\tmt_entry.entry_modified_on as LastMod,\n\t\t\tmt_entry.entry_author_id as AuthorID\n\t\t\tfrom mt_entry\n\t\t\twhere entry_blog_id = '{$blog_id}'\n\t\t", $mtlink);
    $results[] = mysql_error();
    while ($b = mysql_fetch_assoc($a)) {
        $cat = mysql_query("select placement_category_id as category_id from mt_placement where placement_entry_id='{$b['ID']}'");
        while ($cat_id = mysql_fetch_row($cat)) {
            $categories[] = $cat_id[0];
        }
        if (!empty($categories[0])) {
            $b['Category1'] = $categories[0];
        }
        if (!empty($categories[1])) {
            $b['Category2'] = $categories[1];
        }
        unset($categories);
        //Trap comments for each article
        $comments = array();
        $q = "\n\t\t\t\tselect\n\t\t\t\tmt_comment.comment_id as discussid,\n\t\t\t\tmt_comment.comment_ip as ip,\n\t\t\t\tmt_comment.comment_author as name,\n\t\t\t\tmt_comment.comment_email as email,\n\t\t\t\tmt_comment.comment_url as web,\n\t\t\t\tmt_comment.comment_text as message,\n\t\t\t\tmt_comment.comment_created_on as posted\n\t\t\t\tfrom mt_comment where comment_blog_id = '{$blog_id}' AND comment_entry_id='{$b['ID']}'\n\t\t\t";
        $c = mysql_query($q, $mtlink);
        while ($d = mysql_fetch_assoc($c)) {
            $comments[] = $d;
        }
        //Attach comments to article
        $b['comments'] = $comments;
        unset($comments);
        //Article finished
        $articles[] = $b;
    }
    $a = mysql_query("\n\t\t\tselect category_id,category_label from mt_category where category_blog_id='{$blog_id}'\n\t\t", $mtlink);
    while ($b = mysql_fetch_assoc($a)) {
        $categories_map[$b['category_id']] = $b['category_label'];
    }
    mysql_close($mtlink);
    //Yes, we have to make a new connection
    //otherwise doArray complains
    $DB = new DB();
    include txpath . '/lib/classTextile.php';
    $textile = new Textile();
    if (!empty($authors)) {
        foreach ($authors as $author) {
            extract($author);
            $name = empty($name) ? $RealName : $name;
            $authors_map[$user_id] = $name;
            $authorid = safe_field('user_id', 'txp_users', "name = '" . doSlash($name) . "'");
            if (!$authorid) {
                //Add new authors
                $q = safe_insert("txp_users", "\n\t\t\t\t\t\tname     = '" . doSlash($RealName) . "',\n\t\t\t\t\t\temail    = '" . doSlash($email) . "',\n\t\t\t\t\t\tpass     = '******',\n\t\t\t\t\t\tRealName = '" . doSlash($RealName) . "',\n\t\t\t\t\t\tprivs='1'");
                if ($q) {
                    $results[] = 'inserted ' . $RealName . ' into txp_users';
                } else {
                    $results[] = mysql_error();
                }
            }
        }
    }
    if (!empty($categories_map)) {
        foreach ($categories_map as $category) {
            $category = doSlash($category);
            $rs = safe_row('id', 'txp_category', "name='{$category}' and type='article'");
            if (!$rs) {
                $q = safe_insert("txp_category", "name='{$category}',type='article',parent='root'");
                if ($q) {
                    $results[] = 'inserted ' . stripslashes($category) . ' into txp_category';
                } else {
                    $results[] = mysql_error();
                }
            }
        }
    }
    if (!empty($articles)) {
        foreach ($articles as $article) {
            extract($article);
            $Body .= trim($Body2) ? "\n\n" . $Body2 : '';
            $Body_html = $textile->textileThis($Body);
            $Excerpt_html = $textile->textileThis($Excerpt);
            $Title = $textile->textileThis($Title, 1);
            $Category1 = !empty($Category1) ? doSlash($Category1) : '';
            $AuthorID = !empty($authors_map[$AuthorID]) ? doSlash($authors_map[$AuthorID]) : '';
            $insertID = safe_insert("textpattern", "\n\t\t\t\t\tID        \t   = '{$ID}',\n\t\t\t\t\tPosted         = '{$Posted}',\n\t\t\t\t\tLastMod        = '{$LastMod}',\n\t\t\t\t\tTitle          = '" . doSlash($Title) . "',\n\t\t\t\t\tBody           = '" . doSlash($Body) . "',\n\t\t\t\t\tExcerpt\t\t   = '" . doSlash($Excerpt) . "',\n\t\t\t\t\tExcerpt_html   = '" . doSlash($Excerpt_html) . "',\n\t\t\t\t\tKeywords\t   = '" . doSlash($Keywords) . "',\n\t\t\t\t\tBody_html      = '" . doSlash($Body_html) . "',\n\t\t\t\t\tAuthorID       = '{$AuthorID}',\n\t\t\t\t\tCategory1      = '{$Category1}',\n\t\t\t\t\tAnnotateInvite = '" . doSlash($default_comment_invite) . "',\n\t\t\t\t\tSection        = '" . doSlash($insert_into_section) . "',\n\t\t\t\t\tuid            = '" . md5(uniqid(rand(), true)) . "',\n\t\t\t\t\tfeed_time      = '" . substr($Posted, 0, 10) . "',\n\t\t\t\t\tStatus         = '{$insert_with_status}'\n\t\t\t\t");
            if ($insertID) {
                $results[] = 'inserted MT entry ' . strong($Title) . ' into Textpattern as article ' . strong($insertID) . '';
                //Do coment for article
                if (!empty($comments) && is_array($comments)) {
                    foreach ($comments as $comment) {
                        extract($comment);
                        $message = nl2br($message);
                        $commentID = safe_insert("txp_discuss", "\n\t\t\t\t\t\t\t\tdiscussid = {$discussid},\n\t\t\t\t\t\t\t\tparentid  = {$insertID},\n\t\t\t\t\t\t\t\tname      = '" . doSlash($name) . "',\n\t\t\t\t\t\t\t\temail     = '" . doSlash($email) . "',\n\t\t\t\t\t\t\t\tweb       = '" . doSlash($web) . "',\n\t\t\t\t\t\t\t\tmessage   = '" . doSlash($message) . "',\n\t\t\t\t\t\t\t\tip        = '{$ip}',\n\t\t\t\t\t\t\t\tposted    = '{$posted}',\n\t\t\t\t\t\t\t\tvisible   = 1");
                        if ($commentID) {
                            $results[] = 'inserted MT comment ' . $commentID . ' for article ' . $insertID . ' into txp_discuss';
                        } else {
                            $results[] = mysql_error();
                        }
                    }
                }
            } else {
                $results[] = mysql_error();
            }
        }
    }
    return join('<br />', $results);
}
Пример #24
0
/**
 * User editor panel.
 *
 * Accessing requires 'admin.edit' privileges.
 */
function author_edit()
{
    global $step, $txp_user;
    require_privs('admin.edit');
    pagetop(gTxt('tab_site_admin'), '');
    $vars = array('user_id', 'name', 'RealName', 'email', 'privs');
    $rs = array();
    $out = array();
    extract(gpsa($vars));
    $is_edit = $user_id && $step == 'author_edit';
    if ($is_edit) {
        $user_id = assert_int($user_id);
        $rs = safe_row('*', 'txp_users', "user_id = {$user_id}");
        extract($rs);
    }
    if ($is_edit) {
        $out[] = hed(gTxt('edit_author'), 2);
    } else {
        $out[] = hed(gTxt('add_new_author'), 2);
    }
    if ($is_edit) {
        $out[] = inputLabel('login_name', strong(txpspecialchars($name)));
    } else {
        $out[] = inputLabel('login_name', fInput('text', 'name', $name, '', '', '', INPUT_REGULAR, '', 'login_name'), 'login_name', 'add_new_author');
    }
    $out[] = inputLabel('real_name', fInput('text', 'RealName', $RealName, '', '', '', INPUT_REGULAR, '', 'real_name'), 'real_name') . inputLabel('login_email', fInput('email', 'email', $email, '', '', '', INPUT_REGULAR, '', 'login_email'), 'email');
    if ($txp_user != $name) {
        $out[] = inputLabel('privileges', privs($privs), 'privileges', 'about_privileges');
    } else {
        $out[] = inputLabel('privileges', strong(get_priv_level($privs))) . hInput('privs', $privs);
    }
    $out[] = pluggable_ui('author_ui', 'extend_detail_form', '', $rs) . graf(fInput('submit', '', gTxt('save'), 'publish')) . eInput('admin');
    if ($user_id) {
        $out[] = hInput('user_id', $user_id) . hInput('name', $name) . sInput('author_save');
    } else {
        $out[] = sInput('author_save_new');
    }
    echo form(n . tag(join('', $out) . n, 'section', array('class' => 'txp-edit')), '', '', 'post', 'edit-form', '', 'user_edit');
}
function _sed_list_plugins_from_cache($message = '')
{
    pagetop(gTxt('edit_plugins'), $message);
    echo startTable('list');
    $filenames = array();
    if (!empty($GLOBALS['prefs']['plugin_cache_dir'])) {
        $dir = dir($GLOBALS['prefs']['plugin_cache_dir']);
        while ($file = $dir->read()) {
            if ($file != '.' && $file != '..') {
                $fileaddr = $GLOBALS['prefs']['plugin_cache_dir'] . DS . $file;
                if (!is_dir($fileaddr)) {
                    $filenames[] = $fileaddr;
                }
            }
        }
        $dir->close();
        ($filenames and count($filenames) > 0) ? natcasesort($filenames) : '';
    }
    echo tr(tda(tag('Plugins found in the plugin cache directory: ' . $GLOBALS['prefs']['plugin_cache_dir'], 'h1'), ' colspan="1" style="border:0;height:50px;text-align:left"'));
    echo assHead('plugin');
    if (count($filenames) > 0) {
        foreach ($filenames as $filename) {
            $fileext = array_pop(explode('.', $filename));
            if ($fileext === 'php') {
                $elink = '<a href="?event=sed_plugin_help_viewer&#38;step=view_help&#38;filename=' . $filename . '">' . (isset($plugin['name']) ? $plugin['name'] : $filename) . '</a>';
                echo tr(td(strong($elink)));
            }
        }
    }
    echo endTable();
}
Пример #26
0
function author_form()
{
    global $step, $txp_user;
    $vars = array('user_id', 'name', 'RealName', 'email', 'privs');
    extract(gpsa($vars));
    if ($user_id && $step == 'author_edit') {
        $user_id = assert_int($user_id);
        extract(safe_row('*', 'txp_users', "user_id = {$user_id}"));
    }
    if ($step == 'author_save' or $step == 'author_save_new') {
        foreach ($vars as $var) {
            ${$var} = '';
        }
    }
    $caption = gTxt($step == 'author_edit' ? 'edit_author' : 'add_new_author');
    return form(hed($caption, 3, ' style="text-align: center;"') . startTable('edit') . tr(fLabelCell('login_name') . ($user_id && $step == 'author_edit' ? td(strong($name)) : fInputCell('name', $name))) . tr(fLabelCell('real_name') . fInputCell('RealName', $RealName)) . tr(fLabelCell('email') . fInputCell('email', $email)) . tr(fLabelCell('privileges') . td(($txp_user != $name ? privs($privs) : hInput('privs', $privs) . strong(get_priv_level($privs))) . sp . popHelp('about_privileges'))) . tr(td() . td(fInput('submit', '', gTxt('save'), 'publish') . ($user_id ? '' : sp . popHelp('add_new_author')))) . endTable() . eInput('admin') . ($user_id ? hInput('user_id', $user_id) . sInput('author_save') : sInput('author_save_new')));
}
Пример #27
0
function fetch_form($name)
{
    static $forms = array();
    if (isset($forms[$name])) {
        return $forms[$name];
    }
    $f = fetch('Form', 'txp_form', 'name', doSlash($name));
    if (!$f) {
        return graf('form ' . strong($name) . ' does not exist');
    }
    $forms[$name] = $f;
    return $f;
}
Пример #28
0
/**
 * Render admin-side message text.
 *
 * @param	string	$thing	Subject
 * @param	string	$thething	Predicate (strong)
 * @param	string	$action	Object
 * @return	string	HTML
 */
function messenger($thing, $thething = '', $action = '')
{
    return gTxt($thing) . ' ' . strong($thething) . ' ' . gTxt($action);
}
Пример #29
0
function discuss_multi_edit()
{
    //FIXME, this method needs some refactoring
    $selected = ps('selected');
    $method = ps('method');
    $done = array();
    if ($selected) {
        // Get all articles for which we have to update the count
        foreach ($selected as $id) {
            $ids[] = "'" . intval($id) . "'";
        }
        $parentids = safe_column("DISTINCT parentid", "txp_discuss", "discussid IN (" . implode(',', $ids) . ")");
        $rs = safe_rows_start('*', 'txp_discuss', "discussid IN (" . implode(',', $ids) . ")");
        while ($row = nextRow($rs)) {
            extract($row);
            $id = intval($discussid);
            $parentids[] = $parentid;
            if ($method == 'delete') {
                // Delete and if succesful update commnet count
                if (safe_delete('txp_discuss', "discussid='{$id}'")) {
                    $done[] = $id;
                }
            } elseif ($method == 'ban') {
                // Ban the IP and hide all messages by that IP
                if (!safe_field('ip', 'txp_discuss_ipban', "ip='" . doSlash($ip) . "'")) {
                    safe_insert("txp_discuss_ipban", "ip = '" . doSlash($ip) . "',\n\t\t\t\t\t\t\tname_used = '" . doSlash($name) . "',\n\t\t\t\t\t\t\tbanned_on_message = '" . doSlash($discussid) . "',\n\t\t\t\t\t\t\tdate_banned = now()\n\t\t\t\t\t\t");
                    safe_update('txp_discuss', "visible = " . SPAM, "ip='" . doSlash($ip) . "'");
                }
                $done[] = $id;
            } elseif ($method == 'spam') {
                if (safe_update('txp_discuss', "visible = " . SPAM, "discussid = {$id}")) {
                    $done[] = $id;
                }
            } elseif ($method == 'unmoderated') {
                if (safe_update('txp_discuss', "visible = " . MODERATE, "discussid = {$id}")) {
                    $done[] = $id;
                }
            } elseif ($method == 'visible') {
                if (safe_update('txp_discuss', "visible = " . VISIBLE, "discussid = {$id}")) {
                    $done[] = $id;
                }
            }
        }
        $done = join(', ', $done);
        if (!empty($done)) {
            // might as well clean up all comment counts while we're here.
            clean_comment_counts($parentids);
            $messages = array('delete' => messenger('comment', $done, 'deleted'), 'ban' => messenger('comment', $done, 'banned'), 'spam' => gTxt('comment') . ' ' . strong($done) . ' ' . gTxt('marked_as') . ' ' . gTxt('spam'), 'unmoderated' => gTxt('comment') . ' ' . strong($done) . ' ' . gTxt('marked_as') . ' ' . gTxt('unmoderated'), 'visible' => gTxt('comment') . ' ' . strong($done) . ' ' . gTxt('marked_as') . ' ' . gTxt('visible'));
            return discuss_list($messages[$method]);
        }
    }
    return discuss_list();
}
Пример #30
-3
 /**
  * index function.
  * 
  * @access public
  * @return void
  */
 public function index()
 {
     $this->output->enable_profiler(false);
     if (!$this->auth->loggedin()) {
         redirect('user/login');
     }
     $data['title'] = $this->system_model->get('app_name');
     $html = row(columns(heading(ucfirst(lang('about')) . ' ' . $this->system_model->get('app_name'), 1), 12));
     $uptime_array = explode(" ", exec("cat /proc/uptime"));
     $seconds = round($uptime_array[0], 0);
     $minutes = $seconds / 60;
     $hours = $minutes / 60;
     $days = floor($hours / 24);
     $hours = sprintf('%02d', floor($hours - $days * 24));
     $minutes = sprintf('%02d', floor($minutes - $days * 24 * 60 - $hours * 60));
     if ($days == 0) {
         $uptime = $hours . ":" . $minutes;
     } elseif ($days == 1) {
         $uptime = $days . " " . lang('day') . ", " . $hours . ":" . $minutes;
     } else {
         $uptime = $days . " " . lang('days') . ", " . $hours . ":" . $minutes;
     }
     $infolist = ul(array(heading('Applikation', 5) . ul(array(strong('Klubb-' . lang('version') . ': ') . KLUBB_VERSION, strong('CodeIgniter-' . lang('version') . ': ') . CI_VERSION, strong(ucfirst(lang('database')) . ': ') . $this->db->platform() . ', ' . lang('version') . ': ' . $this->db->version(), strong(ucfirst(lang('environment') . ': ')) . lang(ENVIRONMENT))), heading('Server', 5) . ul(array(strong('Namn: ') . php_uname('n'), strong('System: ') . php_uname('s') . ' ' . php_uname('r') . ' ' . php_uname('v') . ' ' . php_uname('m'), strong('Upptid: ') . $uptime, strong('PHP-version: ') . phpversion(), strong('PHP-moduler: ') . implode(', ', get_loaded_extensions())))), array('class' => 'no-bullet'));
     $html .= row(columns($infolist));
     $data['breadcrumbs'] = array(array('data' => anchor('/', $this->system_model->get('app_name')), 'mode' => 'unavailable'), array('data' => anchor('about', ucfirst(lang('about') . ' ' . $data['title'])), 'mode' => 'current'));
     $data['html'] = $html;
     $this->system_model->view('template', $data);
 }