Example #1
0
function pagetop($pagetitle, $message = '', $msgclass = '')
{
    global $css_mode, $siteurl, $sitename, $txp_user, $event;
    $area = gps('area');
    $event = !$event ? 'article' : $event;
    $bm = gps('bm');
    $privs = safe_field('privs', 'txp_users', "name = '" . doSlash($txp_user) . "'");
    $GLOBALS['privs'] = $privs;
    $areas = areas();
    $area = false;
    foreach ($areas as $k => $v) {
        if (in_array($event, $v)) {
            $area = $k;
            break;
        }
    }
    if (gps('logout')) {
        $body_id = 'page-logout';
    } elseif (!$txp_user) {
        $body_id = 'page-login';
    } else {
        $body_id = 'page-' . $event;
    }
    $theme = 'default';
    include txpath . DS . 'theme' . DS . $theme . DS . 'header.php';
}
Example #2
0
/**
 * The main Page editor panel.
 *
 * @param string|array $message The activity message
 */
function page_edit($message = '')
{
    global $event, $step;
    pagetop(gTxt('edit_pages'), $message);
    extract(array_map('assert_string', gpsa(array('copy', 'save_error', 'savenew'))));
    $name = sanitizeForPage(assert_string(gps('name')));
    $newname = sanitizeForPage(assert_string(gps('newname')));
    if ($step == 'page_delete' || empty($name) && $step != 'page_new' && !$savenew) {
        $name = safe_field('page', 'txp_section', "name = 'default'");
    } elseif ((($copy || $savenew) && $newname || $newname && $newname != $name) && !$save_error) {
        $name = $newname;
    }
    $buttons = n . tag(gTxt('page_name'), 'label', array('for' => 'new_page')) . br . fInput('text', 'newname', $name, 'input-medium', '', '', INPUT_MEDIUM, '', 'new_page', false, true);
    if ($name) {
        $buttons .= span(href(gTxt('duplicate'), '#', array('id' => 'txp_clone', 'class' => 'clone', 'title' => gTxt('page_clone'))), array('class' => 'txp-actions'));
    } else {
        $buttons .= hInput('savenew', 'savenew');
    }
    $html = !$save_error ? fetch('user_html', 'txp_page', 'name', $name) : gps('html');
    // Format of each entry is popTagLink -> array ( gTxt() string, class/ID).
    $tagbuild_items = array('page_article' => array('page_article_hed', 'article-tags'), 'page_article_nav' => array('page_article_nav_hed', 'article-nav-tags'), 'page_nav' => array('page_nav_hed', 'nav-tags'), 'page_xml' => array('page_xml_hed', 'xml-tags'), 'page_misc' => array('page_misc_hed', 'misc-tags'), 'page_file' => array('page_file_hed', 'file-tags'));
    $tagbuild_links = '';
    foreach ($tagbuild_items as $tb => $item) {
        $tagbuild_links .= wrapRegion($item[1] . '_group', taglinks($tb), $item[1], $item[0], 'page_' . $item[1]);
    }
    echo hed(gTxt('tab_pages'), 1, array('class' => 'txp-heading'));
    echo n . tag(n . tag(hed(gTxt('tagbuilder'), 2) . $tagbuild_links, 'div', array('id' => 'tagbuild_links', 'class' => 'txp-layout-cell txp-layout-1-4')) . n . tag(form(graf($buttons) . graf(tag(gTxt('page_code'), 'label', array('for' => 'html')) . br . '<textarea class="code" id="html" name="html" cols="' . INPUT_LARGE . '" rows="' . TEXTAREA_HEIGHT_LARGE . '" dir="ltr">' . txpspecialchars($html) . '</textarea>') . graf(fInput('submit', '', gTxt('save'), 'publish') . eInput('page') . sInput('page_save') . hInput('name', $name)), '', '', 'post', 'edit-form', '', 'page_form'), 'div', array('id' => 'main_content', 'class' => 'txp-layout-cell txp-layout-2-4')) . n . tag(graf(sLink('page', 'page_new', gTxt('create_new_page')), ' class="action-create"') . page_list($name) . n, 'div', array('id' => 'content_switcher', 'class' => 'txp-layout-cell txp-layout-1-4')) . n, 'div', array('id' => $event . '_container', 'class' => 'txp-layout-grid'));
}
function view_help($message = '')
{
    pagetop(gTxt('edit_plugins'), $message);
    $filename = gps('filename');
    $plugin = array();
    if (!empty($filename)) {
        $content = file($filename);
        $source_lines = count($content);
        $format = 'none';
        for ($i = 0; $i < $source_lines; $i++) {
            $content[$i] = rtrim($content[$i]);
        }
        $format = 'unknown';
        //	Check for ZEM plugin...
        $plugin['help'] = _zem_extract_section($content, 'HELP');
        if ('' != $plugin['help']) {
            $format = 'zem_help';
        } else {
            //	check for ied style help section...
            $plugin['help'] = _ied_extract_section($content, 'HELP');
            if ('' != $plugin['help']) {
                $format = 'ied_help';
            }
        }
        echo startTable('edit');
        switch ($format) {
            case 'zem_help':
                echo tr(tda('<p>Plugin is in zem template format.</p>', ' width="600"'));
                if (!isset($plugin['allow_html_help']) or 0 === $plugin['allow_html_help']) {
                    #	Textile...
                    $plugin['css'] = _zem_extract_section($content, 'CSS');
                    include_once txpath . '/lib/classTextile.php';
                    if (class_exists('Textile')) {
                        $textile = new Textile();
                        $plugin['help'] = $plugin['css'] . n . $textile->TextileThis($plugin['help']);
                        echo tr(tda('<p>Extracted and Textile processed help section follows&#8230;</p><hr>', ' width="600"'));
                    } else {
                        echo tr(tda('<p>Extracted help section follows, <strong>Textile Processing Failed</strong>&#8230;</p><hr>', ' width="600"'));
                    }
                } else {
                    # (x)html...
                    $plugin['css'] = _zem_extract_section($content, 'CSS');
                    $plugin['help'] = $plugin['css'] . n . $plugin['help_raw'];
                }
                echo tr(tda($plugin['help'], ' width="600"'));
                break;
            case 'ied_help':
                echo tr(tda('<p>Plugin is in ied template format.</p>', ' width="600"'));
                echo tr(tda('<p>Extracted raw help section follows&#8230;</p><hr>', ' width="600"'));
                echo tr(tda($plugin['help'], ' width="600"'));
                break;
            default:
                echo tr(tda('<p><strong>Unknown plugin file format or empty help section.</strong></p><hr>', ' width="600"'));
                break;
        }
        echo endTable();
    } else {
        echo 'Help not accessible from that file.';
    }
}
Example #4
0
function plugin_help()
{
    $name = gps('name');
    pagetop(gTxt('plugin_help'));
    $help = $name ? safe_field('help', 'txp_plugin', "name = '" . doSlash($name) . "'") : '';
    echo startTable('edit') . tr(tda($help, ' width="600"')) . endTable();
}
Example #5
0
function doTxpValidate()
{
    global $logout, $txpcfg;
    $p_userid = ps('p_userid');
    $p_password = ps('p_password');
    $logout = gps('logout');
    $stay = ps('stay');
    if ($logout) {
        setcookie('txp_login', '', time() - 3600);
    }
    if (!empty($_COOKIE['txp_login']) and !$logout) {
        // cookie exists
        @(list($c_userid, $cookie_hash) = split(',', $_COOKIE['txp_login']));
        $nonce = safe_field('nonce', 'txp_users', "name='{$c_userid}'");
        if (md5($c_userid . $nonce) === $cookie_hash && $nonce) {
            // check nonce
            $GLOBALS['txp_user'] = $c_userid;
            // cookie is good, create $txp_user
            return '';
        } else {
            // something's gone wrong
            $GLOBALS['txp_user'] = '';
            setcookie('txp_login', '', time() - 3600);
            return gTxt('bad_cookie');
        }
    } elseif ($p_userid and $p_password) {
        // no cookie, but incoming login vars
        sleep(3);
        // should grind dictionary attacks to a halt
        if (txp_validate($p_userid, $p_password)) {
            $nonce = safe_field('nonce', 'txp_users', "name='{$p_userid}'");
            if (!$nonce) {
                define('TXP_UPDATE', 1);
                include_once txpath . '/update/_update.php';
                exit(graf('Please reload'));
            }
            if ($stay) {
                // persistent cookie required
                setcookie('txp_login', $p_userid . ',' . md5($p_userid . $nonce), time() + 3600 * 24 * 365);
                // expires in 1 year
            } else {
                // session-only cookie required
                setcookie('txp_login', $p_userid . ',' . md5($p_userid . $nonce));
                setcookie('txp_nostay', '1', time() + 3600 * 24 * 365);
                // remember nostay for 1 year
            }
            $GLOBALS['txp_user'] = $p_userid;
            // login is good, create $txp_user
            return '';
        } else {
            $GLOBALS['txp_user'] = '';
            return gTxt('could_not_log_in');
        }
    } else {
        $GLOBALS['txp_user'] = '';
        return gTxt('login_to_textpattern');
    }
}
Example #6
0
function change_email()
{
    global $txp_user;
    $new_email = gps('new_email');
    $rs = safe_update("txp_users", "email  = '{$new_email}'", "name = '{$txp_user}'");
    if ($rs) {
        admin('email address changed to ' . $new_email);
    }
}
Example #7
0
function edit_plugin()
{
    $name = gps('name');
    pagetop(gTxt('edit_plugins'));
    echo plugin_edit_form($name);
    //		echo graf('<a href="?event=plugin'.
    //				a.'step=view_hilighted'.
    //				a.'name='.urlencode($name).
    //				'">View highlighted</a>');
}
Example #8
0
function doTxpValidate()
{
    global $logout, $txpcfg;
    $p_userid = ps('p_userid');
    $p_password = ps('p_password');
    $logout = gps('logout');
    $stay = ps('stay');
    if ($logout) {
        setcookie('txp_login', ' ', time() - 3600);
    }
    if (isset($_COOKIE['txp_login']) and !$logout) {
        // cookie exists
        list($c_userid, $cookie_hash) = split(',', $_COOKIE['txp_login']);
        $nonce = safe_field('nonce', 'txp_users', "name='{$c_userid}'");
        if (md5($c_userid . $nonce) == $cookie_hash) {
            // check secret word
            $GLOBALS['txp_user'] = $c_userid;
            // cookie is good, create $txp_user
            return '';
        } else {
            // something's gone wrong
            $GLOBALS['txp_user'] = '';
            setcookie('txp_login', '', time() - 3600);
            return gTxt('bad_cookie');
        }
    } elseif ($p_userid and $p_password) {
        // no cookie, but incoming login vars
        sleep(3);
        // should grind dictionary attacks to a halt
        if (txp_validate($p_userid, $p_password)) {
            $nonce = safe_field('nonce', 'txp_users', "name='{$p_userid}'");
            if (!$nonce) {
                exit(graf('Missing authentication information. 
										Please run _update.php'));
            }
            if ($stay) {
                // persistent cookie required
                setcookie('txp_login', $p_userid . ',' . md5($p_userid . $nonce), time() + 3600 * 24 * 365);
                // expires in 1 year
            } else {
                // session-only cookie required
                setcookie('txp_login', $p_userid . ',' . md5($p_userid . $nonce));
            }
            $GLOBALS['txp_user'] = $p_userid;
            // login is good, create $txp_user
            return '';
        } else {
            $GLOBALS['txp_user'] = '';
            return gTxt('could_not_log_in');
        }
    } else {
        $GLOBALS['txp_user'] = '';
        return gTxt('login_to_textpattern');
    }
}
Example #9
0
function change_email()
{
    global $txp_user;
    $new_email = gps('new_email');
    if (!is_valid_email($new_email)) {
        author_list(array(gTxt('email_required'), E_ERROR));
        return;
    }
    $rs = safe_update('txp_users', "email = '" . doSlash($new_email) . "'", "name = '" . doSlash($txp_user) . "'");
    author_list($rs ? gTxt('email_changed', array('{email}' => $new_email)) : gTxt(array('author_save_failed', E_ERROR)));
}
Example #10
0
function doTxpValidate()
{
    global $logout, $txpcfg, $txp_user;
    $p_userid = ps('p_userid');
    $p_password = ps('p_password');
    $logout = gps('logout');
    $stay = ps('stay');
    if ($logout) {
        setcookie('txp_login', '', time() - 3600);
    }
    if (!empty($_COOKIE['txp_login']) and !$logout) {
        @(list($c_userid, $cookie_hash) = split(',', cs('txp_login')));
        $nonce = safe_field('nonce', 'txp_users', "name='" . doSlash($c_userid) . "'");
        if ($nonce && $nonce === md5($c_userid . pack('H*', $cookie_hash))) {
            // cookie is good, create $txp_user
            $txp_user = $c_userid;
            return '';
        } else {
            // something's gone wrong
            $txp_user = '';
            setcookie('txp_login', '', time() - 3600);
            return gTxt('bad_cookie');
        }
    } elseif ($p_userid and $p_password) {
        sleep(3);
        // should grind dictionary attacks to a halt
        if (txp_validate($p_userid, $p_password)) {
            $cookie_hash = md5(uniqid(rand()));
            safe_update('txp_users', "nonce = '" . doSlash(md5($p_userid . pack('H*', $cookie_hash))) . "'", "name = '" . doSlash($p_userid) . "'");
            if ($stay) {
                setcookie('txp_login', $p_userid . ',' . $cookie_hash, time() + 3600 * 24 * 365);
                // expires in 1 year
                if (cs('txp_nostay')) {
                    setcookie('txp_nostay', '', time() - 3600);
                }
            } else {
                setcookie('txp_login', $p_userid . ',' . $cookie_hash);
                setcookie('txp_nostay', '1', time() + 3600 * 24 * 365);
                // remember nostay for 1 year
            }
            $txp_user = $p_userid;
            // login is good, create $txp_user
            return '';
        } else {
            $txp_user = '';
            return gTxt('could_not_log_in');
        }
    } else {
        $txp_user = '';
        return gTxt('login_to_textpattern');
    }
}
Example #11
0
function change_email()
{
    global $txp_user;
    $new_email = gps('new_email');
    if (!is_valid_email($new_email)) {
        admin(gTxt('email_required'));
        return;
    }
    $rs = safe_update('txp_users', "email = '" . doSlash($new_email) . "'", "name = '" . doSlash($txp_user) . "'");
    if ($rs) {
        admin(gTxt('email_changed', array('{email}' => $new_email)));
    }
}
Example #12
0
function jmd_sitemap($event, $step)
{
    global $prefs;
    $sitemap = new JMD_Sitemap();
    // Generate sitemap
    if ($step == ('create' || 'edit' || 'update')) {
        $excluded = gps('exclude');
        if ($excluded) {
            $excluded = serialize($excluded);
            $prefs['jmd_sitemap_exclude'] = $excluded;
            safe_update("txp_prefs", "val = '{$excluded}'", "name = 'jmd_sitemap_exclude'");
        }
        $sitemap->writeSitemap();
    }
    // Extensions tab
    if ($event == 'jmd_sitemap') {
        pageTop('jmd_sitemap', $step ? _jmd_sitemap_gtxt('sitemap_updated') : '');
        echo '<div id="jmd_sitemap" style="width: 350px; margin: 0 auto">';
        // File errors
        if (file_exists($sitemap->filename)) {
            if (!is_writable($sitemap->filename)) {
                $fileError = _jmd_sitemap_gtxt('error_not_writable');
            }
        } else {
            $fileError = _jmd_sitemap_gtxt('error_doesnt_exist');
        }
        if (isset($fileError)) {
            echo tag($sitemap->filename . ' ' . $fileError, 'p', ' class="not-ok"');
        }
        $out = '<label for="exclude">' . _jmd_sitemap_gtxt('exclude_sections') . ':</label><br/>
            <select id="exclude" name="exclude[]" multiple="multiple"
                size="5" style="width: 150px; margin: 3px 0 10px">';
        // Exclude sections
        $exclude = $prefs['jmd_sitemap_exclude'];
        $exclude = unserialize($exclude);
        $sections = safe_column("name", "txp_section", "name != 'default'");
        foreach ($sections as $section) {
            $out .= '<option name="' . $section . '"';
            // Select excluded
            if (in_array($section, $exclude)) {
                $out .= ' selected="selected"';
            }
            $out .= ">{$section}</option>";
        }
        $out .= '</select><br/>';
        echo form($out . tag(_jmd_sitemap_gtxt('update_sitemap'), 'button') . eInput('jmd_sitemap') . sInput('update'));
        echo '</div><!--//jmd_sitemap-->';
    }
}
Example #13
0
/**
 * The main Page editor panel.
 *
 * @param string|array $message The activity message
 */
function page_edit($message = '')
{
    global $event, $step;
    pagetop(gTxt('edit_pages'), $message);
    extract(array_map('assert_string', gpsa(array('copy', 'save_error', 'savenew'))));
    $name = sanitizeForPage(assert_string(gps('name')));
    $newname = sanitizeForPage(assert_string(gps('newname')));
    if ($step == 'page_delete' || empty($name) && $step != 'page_new' && !$savenew) {
        $name = safe_field("page", 'txp_section', "name = 'default'");
    } elseif ((($copy || $savenew) && $newname || $newname && $newname != $name) && !$save_error) {
        $name = $newname;
    }
    $titleblock = inputLabel('new_page', fInput('text', 'newname', $name, 'input-medium', '', '', INPUT_MEDIUM, '', 'new_page', false, true), 'page_name', array('', 'instructions_page_name'), array('class' => 'txp-form-field'));
    if ($name === '') {
        $titleblock .= hInput('savenew', 'savenew');
    } else {
        $titleblock .= hInput('name', $name);
    }
    $titleblock .= eInput('page') . sInput('page_save');
    $html = !$save_error ? fetch('user_html', 'txp_page', 'name', $name) : gps('html');
    // Format of each entry is popTagLink -> array ( gTxt() string, class/ID).
    $tagbuild_items = array('page_article' => array('page_article_hed', 'article-tags'), 'page_article_nav' => array('page_article_nav_hed', 'article-nav-tags'), 'page_nav' => array('page_nav_hed', 'nav-tags'), 'page_xml' => array('page_xml_hed', 'xml-tags'), 'page_misc' => array('page_misc_hed', 'misc-tags'), 'page_file' => array('page_file_hed', 'file-tags'));
    $tagbuild_links = '';
    foreach ($tagbuild_items as $tb => $item) {
        $tagbuild_links .= wrapRegion($item[1] . '_group', taglinks($tb), $item[1], $item[0], 'page_' . $item[1]);
    }
    // Pages code columm.
    echo n . tag(hed(gTxt('tab_pages'), 1, array('class' => 'txp-heading')) . form($titleblock . inputLabel('html', '<textarea class="code" id="html" name="html" cols="' . INPUT_LARGE . '" rows="' . TEXTAREA_HEIGHT_LARGE . '" dir="ltr">' . txpspecialchars($html) . '</textarea>', 'page_code', array('', 'instructions_page_code'), array('class' => 'txp-form-field')), '', '', 'post', '', '', 'page_form'), 'div', array('class' => 'txp-layout-4col-cell-1-2-3', 'id' => 'main_content', 'role' => 'region'));
    // Pages create/switcher column.
    $buttonExtras = '';
    if ($name) {
        $buttonExtras .= href('<span class="ui-icon ui-icon-copy"></span> ' . gTxt('duplicate'), '#', array('class' => 'txp-clone', 'data-form' => 'page_form'));
    }
    $buttons = graf(tag_void('input', array('class' => 'publish', 'type' => 'submit', 'method' => 'post', 'value' => gTxt('save'), 'form' => 'page_form')), ' class="txp-save"') . graf(sLink('page', 'page_new', '<span class="ui-icon ui-extra-icon-new-document"></span> ' . gTxt('create_new_page'), 'txp-new') . $buttonExtras, array('class' => 'txp-actions'));
    echo n . tag($buttons . page_list($name) . n, 'div', array('class' => 'txp-layout-4col-cell-4alt', 'id' => 'content_switcher', 'role' => 'region'));
    // Pages tag builder column. TODO: make this a modal?
    //    echo n.tag(
    //        hed(gTxt('tagbuilder'), 2).
    //        $tagbuild_links
    //    , 'div', array(
    //        'class' => '',
    //        'id'    => 'tagbuild_links',
    //    ));
}
Example #14
0
function log_list()
{
    pagetop(gTxt('visitor_logs'));
    extract(get_prefs());
    safe_delete("txp_log", "`time` < date_sub(now(),interval " . $expire_logs_after . " day)");
    safe_optimize("txp_log");
    safe_repair("txp_log");
    $page = gps('page');
    $total = getCount('txp_log', "1");
    $limit = 50;
    $numPages = ceil($total / $limit);
    $page = !$page ? 1 : $page;
    $offset = ($page - 1) * $limit;
    $nav[] = $page > 1 ? PrevNextLink("log", $page - 1, gTxt('prev'), 'prev') : '';
    $nav[] = sp . small($page . '/' . $numPages) . sp;
    $nav[] = $page != $numPages ? PrevNextLink("log", $page + 1, gTxt('next'), 'next') : '';
    $rs = safe_rows_start("*, unix_timestamp(time) as stamp", "txp_log", "1 order by time desc limit {$offset},{$limit}");
    if ($rs) {
        echo startTable('list'), assHead('time', 'host', 'page', 'referrer');
        $stamp = '';
        while ($a = nextRow($rs)) {
            extract($a);
            if ($refer) {
                $referprint = preg_replace("/^www\\./", "", chunk(htmlspecialchars($refer), 50));
                $referprint = '<a href="http://' . htmlspecialchars($refer) . '">' . $referprint . '</a>';
            } else {
                $referprint = '&#160;';
            }
            $pageprint = preg_replace('/\\/$/', '', htmlspecialchars(substr($page, 1)));
            $pageprint = $pageprint == '' ? '' : '<a href="' . htmlspecialchars($page) . '" target="_blank">' . chunk($pageprint, 50) . '</a>';
            if ($method == 'POST') {
                $pageprint = '<b>' . $pageprint . '</b>';
            }
            $fstamp = date("n/j g:i a", $stamp + tz_offset());
            $hostprint = chunk($host, 40);
            echo tr(td($fstamp) . td($hostprint) . td($pageprint) . td($referprint));
            unset($refer, $referprint, $page, $pageprint);
        }
        echo '<tr><td colspan="4" align="right" style="padding:10px">', join('', $nav), "</td></tr>", endTable();
    } else {
        echo graf(gTxt('no_refers_recorded'), ' align="center"');
    }
}
Example #15
0
function mdp_calendar_calcDates($year = '', $month = '', $static, $calid)
{
    global $gmtoffset, $is_dst;
    // Since year and date are now attributes, first check to make sure the user
    // hasn't set them.
    $incoming_calid = gps('calid');
    $incoming_year = (gps('y') and is_numeric(gps('y'))) ? (int) gps('y') : '';
    $incoming_month = (gps('m') and is_numeric(gps('m'))) ? (int) gps('m') : '';
    if ($static) {
        // if we're static w/o any supplied var's, use the current
        if (!$year) {
            $year = safe_strftime('%Y');
        }
        if (!$month) {
            $month = safe_strftime('%m');
        }
    } else {
        // otherwise use current only if we arn't passed something else
        if ($calid == $incoming_calid) {
            // use incoming
            if (!$year) {
                $year = $incoming_year ? $incoming_year : safe_strftime('%Y');
            }
            if (!$month) {
                $month = $incoming_month ? $incoming_month : safe_strftime('%m');
            }
        } else {
            // use current
            if (!$year) {
                $year = safe_strftime('%Y');
            }
            if (!$month) {
                $month = safe_strftime('%m');
            }
        }
    }
    // The times in the DB are stored using the servers localtime, so we don't
    // want to adjust anything since mktime uses the servers localtime.
    $ts_first = mktime(0, 0, 0, $month, 1, $year);
    $ts_last = mktime(23, 59, 59, $month, date('t', $ts_first), $year);
    return array('year' => $year, 'month' => $month, 'ts_first' => $ts_first, 'ts_last' => $ts_last);
}
Example #16
0
function _sed_article_copyright_callback($event, $step)
{
    if (!empty($event) and $event != 'article') {
        return;
    }
    require_privs('article');
    $save = gps('save');
    if ($save) {
        $step = 'save';
    }
    $publish = gps('publish');
    if ($publish) {
        $step = 'publish';
    }
    switch (strtolower($step)) {
        case 'publish':
        case 'delete':
        case 'save':
            _update_cache();
    }
}
Example #17
0
function link_edit($message = "")
{
    global $vars, $step;
    extract(gpsa($vars));
    pagetop(gTxt('edit_links', $message));
    $id = gps('id');
    if ($id && $step == 'link_edit') {
        extract(safe_row("*", "txp_link", "id = {$id}"));
    }
    if ($step == 'link_save' or $step == 'link_post') {
        foreach ($vars as $var) {
            ${$var} = '';
        }
    }
    $textarea = '<textarea name="description" cols="40" rows="7" tabindex="4">' . $description . '</textarea>';
    $selects = linkcategory_popup($category);
    $editlink = ' [' . eLink('category', 'list', '', '', gTxt('edit')) . ']';
    $out = startTable('edit') . tr(fLabelCell('title') . fInputCell('linkname', $linkname, 1, 30)) . tr(fLabelCell('sort_value') . fInputCell('linksort', $linksort, 2, 15)) . tr(fLabelCell('url', 'link_url') . fInputCell('url', $url, 3, 30)) . tr(fLabelCell('link_category', 'link_category') . td($selects . $editlink)) . tr(fLabelCell('description', 'link_description') . tda($textarea, ' valign="top"')) . tr(td() . td(fInput("submit", '', gTxt('save'), "publish"))) . endTable() . eInput('link') . sInput($step == 'link_edit' ? 'link_save' : 'link_post') . hInput('id', $id);
    echo form($out);
    echo link_list();
}
Example #18
0
function page_save()
{
    extract(doSlash(gpsa(array('name', 'html', 'copy'))));
    if ($copy) {
        $newname = doSlash(trim(preg_replace('/[<>&"\']/', '', gps('newname'))));
        if ($newname and safe_field('name', 'txp_page', "name = '{$newname}'")) {
            $message = gTxt('page_already_exists', array('{name}' => $newname));
        } elseif ($newname) {
            safe_insert('txp_page', "name = '{$newname}', user_html = '{$html}'");
            update_lastmod();
            $message = gTxt('page_created', array('{name}' => $newname));
        } else {
            $message = gTxt('page_name_invalid');
        }
        page_edit($message);
    } else {
        safe_update('txp_page', "user_html = '{$html}'", "name = '{$name}'");
        update_lastmod();
        $message = gTxt('page_updated', array('{name}' => $name));
        page_edit($message);
    }
}
Example #19
0
/**
 * Interface for the CSV import.
 *
 * @param string $event
 * @param string $step
 */
function jmd_csv($event, $step)
{
    global $jmd_csv, $file_base_path;
    ob_start('jmd_csv_head');
    $jmd_csv = new JMD_CSV();
    if ($step === 'import') {
        $file = gps('file');
        if ($file) {
            $handle = fopen($file_base_path . DS . $file, 'r');
            if ($handle) {
                $jmd_csv->import($handle, gps('status'));
                $msg = gTxt('jmd_csv_imported');
            } else {
                $msg = gTxt('jmd_csv_file_error');
            }
        }
    }
    pageTop('jmd_csv', isset($msg) ? $msg : '');
    $gTxt = 'gTxt';
    $out = <<<EOD
<fieldset id="jmd_csv">
    <legend>{$gTxt('jmd_csv_import_csv')}</legend>
    <div>
        <label>{$gTxt('jmd_csv_file')}
            {$jmd_csv->fileList()}
        </label>
    </div>
    <div>
        <label>{$gTxt('import_status')}
            {$jmd_csv->statusList()}
        </label>
    </div>
    <button type="submit">{$gTxt('jmd_csv_import')}</button>
</fieldset>
EOD;
    echo form($out . eInput('jmd_csv') . sInput('import'));
}
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());
}
Example #21
0
function delete_declaration($css)
{
    $thedec = gps('declaration');
    $name = gps('name');
    $i = 0;
    foreach ($css as $a => $b) {
        $cursel = $i++;
        $ii = 0;
        foreach ($b as $c => $d) {
            $curdec = $ii++;
            if ($cursel . '-' . $curdec != $thedec) {
                $out[$a][$c] = $d;
            }
        }
    }
    $css = base64_encode(css_format($out));
    safe_update("txp_css", "css='" . doSlash($css) . "'", "name='" . doSlash($name) . "'");
    // update site last mod time
    update_lastmod();
    return parseCSS(base64_decode(fetch('css', 'txp_css', 'name', $name)));
}
Example #22
0
function tag_link_to_next()
{
    global $step, $endform, $name;
    $label = gps('label');
    $label = !$label ? '<txp:next_title />' : $label;
    $out = form(startTable('list') . tr(tdcs(hed(gTxt('tag_link_to_next'), 3), 2)) . tagRow('link_text', fInput('text', 'label', $label, 'edit', '', '', 25)) . $endform);
    $out .= $step == 'build' ? tdb(tbd($name, $label)) : '';
    return $out;
}
Example #23
0
 $prefs = get_user_prefs() + $prefs;
 build_element_list($elements_main);
 if ($elements_aux) {
     build_element_list($elements_aux);
 }
 load_elements('init');
 register_element_tabs();
 $event = gps('event') ? gps('event') : 'article';
 $step = gps('step');
 if (!$dbversion or $dbversion != $thisversion or $txp_using_svn) {
     define('TXP_UPDATE', 1);
     include txpath . '/update/_update.php';
 }
 load_elements($event);
 register_element_tabs();
 if (!empty($admin_side_plugins) and gps('event') != 'plugin') {
     load_plugins(1);
 }
 include txpath . '/lib/txplib_head.php';
 // ugly hack, for the people that don't update their admin_config.php
 // Get rid of this when we completely remove admin_config and move privs to db
 if ($event == 'list') {
     require_privs('article');
 } else {
     require_privs($event);
 }
 callback_event($event, $step, 1);
 // let elements override older /include/txp_foo.php admin pages
 if (!controller_name($event)) {
     $inc = txpath . '/include/txp_' . $event . '.php';
     if (is_readable($inc)) {
Example #24
0
/**
 * Installs a language from the RPC server or from a file.
 *
 * This function fetches language strings for the given language code from
 * either the RPC server or a file.
 *
 * Action is taken based on three HTTP POST parameters: 'lang_code', 'force' and
 * 'updating'. The 'lang_code' is the installed langauge, e.g. 'en-gb', 'fi-fi'.
 * The 'force' when set to 'file' can be used force an installation from a local
 * file. The 'updating' specifies whether only to install (0) or to update (1).
 */
function get_language()
{
    global $prefs, $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);
    // TODO: 90 seconds: seriously?
    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);
            }
            callback_event('lang_installed', 'file', false, $lang_code);
            return list_languages(gTxt($lang_code) . sp . gTxt('updated'));
        } else {
            pagetop(gTxt('installing_language'));
            echo graf('<span class="ui-icon ui-icon-closethick"></span> ' . gTxt('rpc_connect_error') . "<!--" . $client->getErrorCode() . ' ' . $client->getErrorMessage() . "-->", array('class' => 'alert-block error'));
        }
    } else {
        $response = $client->getResponse();
        $lang_struct = unserialize($response);
        if ($lang_struct === false) {
            $errors = $size = 1;
        } else {
            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');
        callback_event('lang_installed', 'remote', false, $lang_code);
        if ($errors > 0) {
            $msg = array($msg . sprintf(" (%s errors, %s ok)", $errors, $size - $errors), E_ERROR);
        }
        list_languages($msg);
    }
}
Example #25
0
function article_edit($message = '', $concurrent = FALSE)
{
    global $vars, $txp_user, $comments_disabled_after, $txpcfg, $prefs;
    extract($prefs);
    extract(gpsa(array('view', 'from_view', 'step')));
    if (!empty($GLOBALS['ID'])) {
        // newly-saved article
        $ID = $GLOBALS['ID'];
        $step = 'edit';
    } else {
        $ID = gps('ID');
    }
    include_once txpath . '/lib/classTextile.php';
    $textile = new Textile();
    // switch to 'text' view upon page load and after article post
    if (!$view || gps('save') || gps('publish')) {
        $view = 'text';
    }
    if (!$step) {
        $step = "create";
    }
    if ($step == "edit" && $view == "text" && !empty($ID) && $from_view != 'preview' && $from_view != 'html' && !$concurrent) {
        $pull = true;
        //-- it's an existing article - off we go to the db
        $ID = assert_int($ID);
        $rs = safe_row("*, unix_timestamp(Posted) as sPosted,\n\t\t\t\tunix_timestamp(Expires) as sExpires,\n\t\t\t\tunix_timestamp(LastMod) as sLastMod", "textpattern", "ID={$ID}");
        extract($rs);
        $reset_time = $publish_now = $Status < 4;
    } else {
        $pull = false;
        //-- assume they came from post
        if ($from_view == 'preview' or $from_view == 'html') {
            $store_out = array();
            $store = unserialize(base64_decode(ps('store')));
            foreach ($vars as $var) {
                if (isset($store[$var])) {
                    $store_out[$var] = $store[$var];
                }
            }
        } else {
            $store_out = gpsa($vars);
            if ($concurrent) {
                $store_out['sLastMod'] = safe_field('unix_timestamp(LastMod) as sLastMod', 'textpattern', 'ID=' . $ID);
            }
        }
        extract($store_out);
    }
    $GLOBALS['step'] = $step;
    if ($step == 'create') {
        $textile_body = $use_textile;
        $textile_excerpt = $use_textile;
    }
    if ($step != 'create') {
        // Previous record?
        $prev_id = checkIfNeighbour('prev', $sPosted);
        // Next record?
        $next_id = checkIfNeighbour('next', $sPosted);
    }
    $page_title = $Title ? $Title : gTxt('write');
    pagetop($page_title, $message);
    echo n . n . '<form name="article" method="post" action="index.php">';
    if (!empty($store_out)) {
        echo hInput('store', base64_encode(serialize($store_out)));
    }
    echo hInput('ID', $ID) . eInput('article') . sInput($step) . '<input type="hidden" name="view" />' . startTable('edit') . '<tr>' . n . '<td id="article-col-1">';
    if ($view == 'text') {
        //-- markup help --------------
        echo side_help($textile_body, $textile_excerpt) . '<h3 class="plain"><a href="#advanced" onclick="toggleDisplay(\'advanced\'); return false;">' . gTxt('advanced_options') . '</a></h3>', '<div id="advanced" class="toggle" style="display:none">', n . graf('<label for="markup-body">' . gTxt('article_markup') . '</label>' . br . pref_text('textile_body', $textile_body, 'markup-body')), n . graf('<label for="markup-excerpt">' . gTxt('excerpt_markup') . '</label>' . br . pref_text('textile_excerpt', $textile_excerpt, 'markup-excerpt')), $allow_form_override ? graf('<label for="override-form">' . gTxt('override_default_form') . '</label>' . sp . popHelp('override_form') . br . form_pop($override_form, 'override-form')) : '', $custom_1_set ? custField(1, $custom_1_set, $custom_1) : '', $custom_2_set ? custField(2, $custom_2_set, $custom_2) : '', $custom_3_set ? custField(3, $custom_3_set, $custom_3) : '', $custom_4_set ? custField(4, $custom_4_set, $custom_4) : '', $custom_5_set ? custField(5, $custom_5_set, $custom_5) : '', $custom_6_set ? custField(6, $custom_6_set, $custom_6) : '', $custom_7_set ? custField(7, $custom_7_set, $custom_7) : '', $custom_8_set ? custField(8, $custom_8_set, $custom_8) : '', $custom_9_set ? custField(9, $custom_9_set, $custom_9) : '', $custom_10_set ? custField(10, $custom_10_set, $custom_10) : '', n . graf('<label for="keywords">' . gTxt('keywords') . '</label>' . sp . popHelp('keywords') . br . n . '<textarea id="keywords" name="Keywords" cols="18" rows="5">' . htmlspecialchars(str_replace(',', ', ', $Keywords)) . '</textarea>'), n . graf('<label for="article-image">' . gTxt('article_image') . '</label>' . sp . popHelp('article_image') . br . fInput('text', 'Image', $Image, 'edit', '', '', 22, '', 'article-image')), n . graf('<label for="url-title">' . gTxt('url_title') . '</label>' . sp . popHelp('url_title') . br . fInput('text', 'url_title', $url_title, 'edit', '', '', 22, '', 'url-title')), '</div>

			<h3 class="plain"><a href="#recent" onclick="toggleDisplay(\'recent\'); return false;">' . gTxt('recent_articles') . '</a>' . '</h3>' . '<div id="recent" class="toggle" style="display:none">';
        $recents = safe_rows_start("Title, ID", 'textpattern', "1=1 order by LastMod desc limit 10");
        if ($recents) {
            echo '<ul class="plain-list">';
            while ($recent = nextRow($recents)) {
                if (!$recent['Title']) {
                    $recent['Title'] = gTxt('untitled') . sp . $recent['ID'];
                }
                echo n . t . '<li><a href="?event=article' . a . 'step=edit' . a . 'ID=' . $recent['ID'] . '">' . escape_title($recent['Title']) . '</a></li>';
            }
            echo '</ul>';
        }
        echo '</div>';
    } else {
        echo sp;
    }
    echo '</td>' . n . '<td id="article-main">';
    //-- title input --------------
    if ($view == 'preview') {
        echo hed(gTxt('preview'), 2) . hed($Title, 1);
    } elseif ($view == 'html') {
        echo hed('XHTML', 2) . hed($Title, 1);
    } elseif ($view == 'text') {
        echo n . '<p><label for="title">' . gTxt('title') . '</label>' . sp . popHelp('title') . br . '<input type="text" id="title" name="Title" value="' . escape_title($Title) . '" class="edit" size="40" tabindex="1" />';
        if ($step != 'create') {
            include_once txpath . '/publish/taghandlers.php';
            $url = permlinkurl_id($ID);
            if ($Status != 4 and $Status != 5) {
                $url .= (strpos($url, '?') === FALSE ? '?' : '&amp;') . 'txpreview=' . intval($ID) . '.' . time();
            }
            echo sp . sp . '<a href="' . $url . '" class="article-view">' . gTxt('view') . '</a>';
        }
        echo '</p>';
    }
    //-- body --------------------
    if ($view == 'preview') {
        if ($textile_body == USE_TEXTILE) {
            echo $textile->TextileThis($Body);
        } else {
            if ($textile_body == CONVERT_LINEBREAKS) {
                echo nl2br($Body);
            } else {
                if ($textile_body == LEAVE_TEXT_UNTOUCHED) {
                    echo $Body;
                }
            }
        }
    } elseif ($view == 'html') {
        if ($textile_body == USE_TEXTILE) {
            $bod = $textile->TextileThis($Body);
        } else {
            if ($textile_body == CONVERT_LINEBREAKS) {
                $bod = nl2br($Body);
            } else {
                if ($textile_body == LEAVE_TEXT_UNTOUCHED) {
                    $bod = $Body;
                }
            }
        }
        echo tag(str_replace(array(n, t), array(br, sp . sp . sp . sp), htmlspecialchars($bod)), 'code');
    } else {
        echo n . graf('<label for="body">' . gTxt('body') . '</label>' . sp . popHelp('body') . br . '<textarea id="body" name="Body" cols="55" rows="31" tabindex="2">' . htmlspecialchars($Body) . '</textarea>');
    }
    //-- excerpt --------------------
    if ($articles_use_excerpts) {
        if ($view == 'text') {
            echo n . graf('<label for="excerpt">' . gTxt('excerpt') . '</label>' . sp . popHelp('excerpt') . br . '<textarea id="excerpt" name="Excerpt" cols="55" rows="5" tabindex="3">' . htmlspecialchars($Excerpt) . '</textarea>');
        } else {
            echo n . '<hr width="50%" />';
            echo $textile_excerpt == USE_TEXTILE ? $view == 'preview' ? graf($textile->textileThis($Excerpt)) : tag(str_replace(array(n, t), array(br, sp . sp . sp . sp), htmlspecialchars($textile->TextileThis($Excerpt))), 'code') : graf($Excerpt);
        }
    }
    //-- author --------------
    if ($view == "text" && $step != "create") {
        echo '<p class="small">' . gTxt('posted_by') . ': ' . htmlspecialchars($AuthorID) . ' &#183; ' . safe_strftime('%d %b %Y &#183; %X', $sPosted);
        if ($sPosted != $sLastMod) {
            echo br . gTxt('modified_by') . ': ' . htmlspecialchars($LastModID) . ' &#183; ' . safe_strftime('%d %b %Y &#183; %X', $sLastMod);
        }
        echo '</p>';
    }
    echo hInput('from_view', $view), '</td>';
    echo '<td id="article-tabs">';
    //-- layer tabs -------------------
    echo $use_textile == USE_TEXTILE || $textile_body == USE_TEXTILE ? '<ul>' . (tab('text', $view) . tab('html', $view) . tab('preview', $view)) . '</ul>' : '&#160;';
    echo '</td>';
    echo '<td id="article-col-2">';
    if ($view == 'text') {
        if ($step != 'create') {
            echo n . graf(href(gtxt('create_new'), 'index.php?event=article'));
        }
        //-- prev/next article links --
        if ($step != 'create' and ($prev_id or $next_id)) {
            echo '<p>', $prev_id ? prevnext_link('&#8249;' . gTxt('prev'), 'article', 'edit', $prev_id, gTxt('prev')) : '', $next_id ? prevnext_link(gTxt('next') . '&#8250;', 'article', 'edit', $next_id, gTxt('next')) : '', '</p>';
        }
        //-- status radios --------------
        echo n . n . '<fieldset id="write-status">' . n . '<legend>' . gTxt('status') . '</legend>' . n . status_radio($Status) . n . '</fieldset>';
        //-- category selects -----------
        echo n . n . '<fieldset id="write-sort">' . n . '<legend>' . gTxt('sort_display') . '</legend>' . n . graf('<label for="category-1">' . gTxt('category1') . '</label> ' . '<span class="small">[' . eLink('category', '', '', '', gTxt('edit')) . ']</span>' . br . n . category_popup('Category1', $Category1, 'category-1')) . n . graf('<label for="category-2">' . gTxt('category2') . '</label>' . br . n . category_popup('Category2', $Category2, 'category-2'));
        //-- section select --------------
        if (!$from_view && !$pull) {
            $Section = getDefaultSection();
        }
        echo n . graf('<label for="section">' . gTxt('section') . '</label> ' . '<span class="small">[' . eLink('section', '', '', '', gTxt('edit')) . ']</span>' . br . section_popup($Section, 'section')) . n . '</fieldset>' . n . n . '<h3 class="plain"><a href="#more" onclick="toggleDisplay(\'more\'); return false;">' . gTxt('more') . '</a></h3>', '<div id="more" class="toggle" style="display:none">';
        //-- comments stuff --------------
        if ($step == "create") {
            //Avoiding invite disappear when previewing
            $AnnotateInvite = !empty($store_out['AnnotateInvite']) ? $store_out['AnnotateInvite'] : $comments_default_invite;
            if ($comments_on_default == 1) {
                $Annotate = 1;
            }
        }
        if ($use_comments == 1) {
            echo n . n . '<fieldset id="write-comments">' . n . '<legend>' . gTxt('comments') . '</legend>';
            $comments_expired = false;
            if ($step != 'create' && $comments_disabled_after) {
                $lifespan = $comments_disabled_after * 86400;
                $time_since = time() - $sPosted;
                if ($time_since > $lifespan) {
                    $comments_expired = true;
                }
            }
            if ($comments_expired) {
                echo n . n . graf(gTxt('expired'));
            } else {
                echo n . n . graf(onoffRadio('Annotate', $Annotate)) . n . n . graf('<label for="comment-invite">' . gTxt('comment_invitation') . '</label>' . br . fInput('text', 'AnnotateInvite', $AnnotateInvite, 'edit', '', '', '', '', 'comment-invite'));
            }
            echo n . n . '</fieldset>';
        }
        if ($step == "create" and empty($GLOBALS['ID'])) {
            //-- timestamp -------------------
            //Avoiding modified date to disappear
            $persist_timestamp = !empty($store_out['year']) ? safe_strtotime($store_out['year'] . '-' . $store_out['month'] . '-' . $store_out['day'] . ' ' . $store_out['hour'] . ':' . $store_out['minute'] . ':' . $store_out['second']) : time();
            echo n . n . '<fieldset id="write-timestamp">' . n . '<legend>' . gTxt('timestamp') . '</legend>' . n . graf(checkbox('publish_now', '1', $publish_now, '', 'publish_now') . '<label for="publish_now">' . gTxt('set_to_now') . '</label>') . n . graf(gTxt('or_publish_at') . sp . popHelp('timestamp')) . n . graf(gtxt('date') . sp . tsi('year', '%Y', $persist_timestamp) . ' / ' . tsi('month', '%m', $persist_timestamp) . ' / ' . tsi('day', '%d', $persist_timestamp)) . n . graf(gTxt('time') . sp . tsi('hour', '%H', $persist_timestamp) . ' : ' . tsi('minute', '%M', $persist_timestamp) . ' : ' . tsi('second', '%S', $persist_timestamp)) . n . '</fieldset>';
            //-- expires -------------------
            $persist_timestamp = !empty($store_out['exp_year']) ? safe_strtotime($store_out['exp_year'] . '-' . $store_out['exp_month'] . '-' . $store_out['exp_day'] . ' ' . $store_out['exp_hour'] . ':' . $store_out['exp_minute'] . ':' . $store_out['second']) : NULLDATETIME;
            echo n . n . '<fieldset id="write-expires">' . n . '<legend>' . gTxt('expires') . '</legend>' . n . graf(gtxt('date') . sp . tsi('exp_year', '%Y', $persist_timestamp) . ' / ' . tsi('exp_month', '%m', $persist_timestamp) . ' / ' . tsi('exp_day', '%d', $persist_timestamp)) . n . graf(gTxt('time') . sp . tsi('exp_hour', '%H', $persist_timestamp) . ' : ' . tsi('exp_minute', '%M', $persist_timestamp) . ' : ' . tsi('exp_second', '%S', $persist_timestamp)) . n . '</fieldset>' . n . n . '</div>';
            //-- publish button --------------
            echo has_privs('article.publish') ? fInput('submit', 'publish', gTxt('publish'), "publish", '', '', '', 4) : fInput('submit', 'publish', gTxt('save'), "publish", '', '', '', 4);
        } else {
            //-- timestamp -------------------
            if (!empty($year)) {
                $sPosted = safe_strtotime($year . '-' . $month . '-' . $day . ' ' . $hour . ':' . $minute . ':' . $second);
            }
            echo n . n . '<fieldset id="write-timestamp">' . n . '<legend>' . gTxt('timestamp') . '</legend>' . n . graf(checkbox('reset_time', '1', $reset_time, '', 'reset_time') . '<label for="reset_time">' . gTxt('reset_time') . '</label>') . n . graf(gTxt('published_at') . sp . popHelp('timestamp')) . n . graf(gtxt('date') . sp . tsi('year', '%Y', $sPosted) . ' / ' . tsi('month', '%m', $sPosted) . ' / ' . tsi('day', '%d', $sPosted)) . n . graf(gTxt('time') . sp . tsi('hour', '%H', $sPosted) . ' : ' . tsi('minute', '%M', $sPosted) . ' : ' . tsi('second', '%S', $sPosted)) . n . hInput('sPosted', $sPosted), n . hInput('sLastMod', $sLastMod), n . hInput('AuthorID', $AuthorID), n . hInput('LastModID', $LastModID), n . '</fieldset>';
            //-- expires -------------------
            if (!empty($exp_year)) {
                if (empty($exp_month)) {
                    $exp_month = 1;
                }
                if (empty($exp_day)) {
                    $exp_day = 1;
                }
                if (empty($exp_hour)) {
                    $exp_hour = 0;
                }
                if (empty($exp_minute)) {
                    $exp_minute = 0;
                }
                if (empty($exp_second)) {
                    $exp_second = 0;
                }
                $sExpires = safe_strtotime($exp_year . '-' . $exp_month . '-' . $exp_day . ' ' . $exp_hour . ':' . $exp_minute . ':' . $exp_second);
            }
            echo n . n . '<fieldset id="write-expires">' . n . '<legend>' . gTxt('expires') . '</legend>' . n . graf(gtxt('date') . sp . tsi('exp_year', '%Y', $sExpires) . ' / ' . tsi('exp_month', '%m', $sExpires) . ' / ' . tsi('exp_day', '%d', $sExpires)) . n . graf(gTxt('time') . sp . tsi('exp_hour', '%H', $sExpires) . ' : ' . tsi('exp_minute', '%M', $sExpires) . ' : ' . tsi('exp_second', '%S', $sExpires)) . n . hInput('sExpires', $sExpires) . n . '</fieldset>' . n . n . '</div>';
            //-- save button --------------
            if ($Status >= 4 and has_privs('article.edit.published') or $Status >= 4 and $AuthorID == $txp_user and has_privs('article.edit.own.published') or $Status < 4 and has_privs('article.edit') or $Status < 4 and $AuthorID == $txp_user and has_privs('article.edit.own')) {
                echo fInput('submit', 'save', gTxt('save'), "publish", '', '', '', 4);
            }
        }
    }
    echo '</td></tr></table></form>';
}
Example #26
0
function form_save()
{
    global $vars, $step, $essential_forms;
    extract(doSlash(gpsa($vars)));
    $name = doSlash(trim(preg_replace('/[<>&"\']/', '', gps('name'))));
    if (!$name) {
        $step = 'form_create';
        $message = gTxt('form_name_invalid');
        return form_edit(array($message, E_ERROR));
    }
    if (!in_array($type, array('article', 'category', 'comment', 'file', 'link', 'misc', 'section'))) {
        $step = 'form_create';
        $message = gTxt('form_type_missing');
        return form_edit(array($message, E_ERROR));
    }
    if ($savenew) {
        $exists = safe_field('name', 'txp_form', "name = '{$name}'");
        if ($exists) {
            $step = 'form_create';
            $message = gTxt('form_already_exists', array('{name}' => $name));
            return form_edit(array($message, E_ERROR));
        }
        safe_insert('txp_form', "Form = '{$Form}', type = '{$type}', name = '{$name}'");
        update_lastmod();
        $message = gTxt('form_created', array('{name}' => $name));
        return form_edit($message);
    }
    safe_update('txp_form', "Form = '{$Form}', type = '{$type}', name = '{$name}'", "name = '{$oldname}'");
    update_lastmod();
    $message = gTxt('form_updated', array('{name}' => $name));
    form_edit($message);
}
Example #27
0
function plugin_help()
{
    global $event;
    $name = gps('name');
    pagetop(gTxt('plugin_help'));
    $help = $name ? safe_field('help', 'txp_plugin', "name = '" . doSlash($name) . "'") : '';
    echo '<div id="' . $event . '_container" class="txp-container txp-view">' . startTable('edit', '', 'plugin-help') . tr(tda($help, ' width="600"')) . endTable() . '</div>';
}
Example #28
0
function event_change_pageby($name)
{
    global $event;
    $qty = gps('qty');
    $pageby = $name . '_list_pageby';
    $GLOBALS[$pageby] = $qty;
    set_pref($pageby, $qty, $event, PREF_HIDDEN, 'text_input', 0, PREF_PRIVATE);
    return;
}
/**
 * Adds headers for each form type.
 *
 * @param string $buffer
 */
function jmd_form_toggle($buffer)
{
    global $DB, $essential_forms, $step;
    if (empty($DB)) {
        $DB = new DB();
    }
    $curForm = gps('name') ? gps('name') : 'default';
    $out = sLink('form', 'form_create', gTxt('create_new_form'), 'action');
    $rs = safe_rows('name, type', 'txp_form', 'name !="" order by type, name asc');
    foreach ($rs as $form) {
        $forms[$form['type']][] = $form['name'];
    }
    $types = array_keys($forms);
    foreach ($types as $type) {
        $out .= <<<EOD
<h3 class="plain" onclick="jmd_form_toggle('type_{$type}');">{$type}</h3>
<table id="type_{$type}">
EOD;
        $count = count($forms[$type]);
        for ($i = 0; $i < $count; $i++) {
            $formName = $forms[$type][$i];
            $formLink = eLink('form', 'form_edit', 'name', $formName, $formName);
            $checkbox = '<input type="checkbox" name="selected_forms[]"
                value="' . $formName . '"/>';
            $class = '';
            if (in_array($formName, $essential_forms)) {
                $checkbox = '';
                $class .= ' single';
            }
            if ($curForm === $formName) {
                $class .= ' current';
                $formLink = tag($formName, 'strong');
            }
            $out .= <<<EOD
<tr class="{$class}">
    <td>
        {$formLink}
    </td>
    <td class="checkbox">
        {$checkbox}
    </td>
</tr>
EOD;
        }
        $out .= '</table>';
    }
    $out .= '<input type="hidden" name="event" value="form" />';
    $pattern = '/<table cellpadding="0" cellspacing="0" border="0" id="list" align="center">(.*)<input type="hidden" name="event" value="form" \\/>/s';
    return preg_replace($pattern, tag($out, 'div', ' id="jmd_form_toggle"'), $buffer);
}
function pagetop($pagetitle, $message = "")
{
    global $css_mode, $siteurl, $sitename, $txp_user, $event;
    $area = gps('area');
    $event = !$event ? 'article' : $event;
    $bm = gps('bm');
    $privs = safe_field("privs", "txp_users", "name = '" . doSlash($txp_user) . "'");
    $GLOBALS['privs'] = $privs;
    $areas = areas();
    $area = false;
    foreach ($areas as $k => $v) {
        if (in_array($event, $v)) {
            $area = $k;
            break;
        }
    }
    if (gps('logout')) {
        $body_id = 'page-logout';
    } elseif (!$txp_user) {
        $body_id = 'page-login';
    } else {
        $body_id = 'page-' . $event;
    }
    ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
	<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php 
    echo LANG;
    ?>
" lang="<?php 
    echo LANG;
    ?>
" dir="<?php 
    echo gTxt('lang_dir');
    ?>
">
	<head>
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
	<meta name="robots" content="noindex, nofollow" />
	<title>Txp &#8250; <?php 
    echo htmlspecialchars($sitename);
    ?>
 &#8250; <?php 
    echo escape_title($pagetitle);
    ?>
</title>
	<link href="textpattern.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript" src="textpattern.js"></script>
	<script type="text/javascript">
	<!--

		var cookieEnabled = checkCookies();

		if (!cookieEnabled)
		{
			confirm('<?php 
    echo trim(gTxt('cookies_must_be_enabled'));
    ?>
');
		}

<?php 
    $edit = array();
    if ($event == 'list') {
        $rs = safe_column('name', 'txp_section', "name != 'default'");
        $edit['section'] = $rs ? selectInput('Section', $rs, '', true) : '';
        $rs = getTree('root', 'article');
        $edit['category1'] = $rs ? treeSelectInput('Category1', $rs, '') : '';
        $edit['category2'] = $rs ? treeSelectInput('Category2', $rs, '') : '';
        $edit['comments'] = onoffRadio('Annotate', safe_field('val', 'txp_prefs', "name = 'comments_on_default'"));
        $edit['status'] = selectInput('Status', array(1 => gTxt('draft'), 2 => gTxt('hidden'), 3 => gTxt('pending'), 4 => gTxt('live'), 5 => gTxt('sticky')), '', true);
        $rs = safe_column('name', 'txp_users', "privs not in(0,6)");
        $edit['author'] = $rs ? selectInput('AuthorID', $rs, '', true) : '';
    }
    if (in_array($event, array('image', 'file', 'link'))) {
        $rs = getTree('root', $event);
        $edit['category'] = $rs ? treeSelectInput('category', $rs, '') : '';
    }
    if ($event == 'plugin') {
        $edit['order'] = selectInput('order', array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9), 5, false);
    }
    if ($event == 'admin') {
        $edit['privilege'] = privs();
    }
    // output JavaScript
    ?>
		function poweredit(elm)
		{
			var something = elm.options[elm.selectedIndex].value;

			// Add another chunk of HTML
			var pjs = document.getElementById('js');

			if (pjs == null)
			{
				var br = document.createElement('br');
				elm.parentNode.appendChild(br);

				pjs = document.createElement('P');
				pjs.setAttribute('id','js');
				elm.parentNode.appendChild(pjs);
			}

			if (pjs.style.display == 'none' || pjs.style.display == '')
			{
				pjs.style.display = 'block';
			}

			if (something != '')
			{
				switch (something)
				{
<?php 
    foreach ($edit as $key => $val) {
        echo "case 'change" . $key . "':" . n . t . "pjs.innerHTML = '<span>" . str_replace(array("\n", '-'), array('', '&#45;'), addslashes($val)) . "</span>';" . n . t . 'break;' . n . n;
    }
    ?>
					default:
						pjs.style.display = 'none';
					break;
				}
			}

			return false;
		}

		addEvent(window, 'load', cleanSelects);
	-->
	</script>
	<script type="text/javascript" src="jquery.js"></script>
	<?php 
    callback_event('admin_side', 'head_end');
    ?>
	</head>
	<body id="<?php 
    echo $body_id;
    ?>
">
	<?php 
    callback_event('admin_side', 'pagetop');
    ?>
  <table id="pagetop" cellpadding="0" cellspacing="0">
  <tr id="branding"><td><h1 id="textpattern">Textpattern</h1></td><td id="navpop"><?php 
    echo navPop(1);
    ?>
</td></tr>
  <tr id="nav-primary"><td align="center" class="tabs" colspan="2">
 		<?php 
    if (!$bm) {
        echo '<table cellpadding="0" cellspacing="0" align="center"><tr>
  <td valign="middle" style="width:368px">&nbsp;' . $message . '</td>', has_privs('tab.content') ? areatab(gTxt('tab_content'), 'content', 'article', $area) : '', has_privs('tab.presentation') ? areatab(gTxt('tab_presentation'), 'presentation', 'page', $area) : '', has_privs('tab.admin') ? areatab(gTxt('tab_admin'), 'admin', 'admin', $area) : '', (has_privs('tab.extensions') and !empty($areas['extensions'])) ? areatab(gTxt('tab_extensions'), 'extensions', array_shift($areas['extensions']), $area) : '', '<td class="tabdown"><a href="' . hu . '" class="plain" target="_blank">' . gTxt('tab_view_site') . '</a></td>', '</tr></table>';
        $secondary = tabsort($area, $event);
        if ($secondary) {
            echo '</td></tr><tr id="nav-secondary"><td align="center" class="tabs" colspan="2">
			<table cellpadding="0" cellspacing="0" align="center"><tr>', $secondary, '</tr></table>';
        }
    }
    echo '</td></tr></table>';
    callback_event('admin_side', 'pagetop_end');
}