示例#1
0
function plugin_list($message = '')
{
    global $event;
    pagetop(gTxt('tab_plugins'), $message);
    echo '<h1 class="txp-heading">' . gTxt('tab_plugins') . '</h1>';
    echo '<div id="' . $event . '_control" class="txp-control-panel">';
    echo n . plugin_form() . n . '</div>';
    extract(gpsa(array('sort', 'dir')));
    if ($sort === '') {
        $sort = get_pref('plugin_sort_column', 'name');
    }
    if ($dir === '') {
        $dir = get_pref('plugin_sort_dir', 'asc');
    }
    $dir = $dir == 'desc' ? 'desc' : 'asc';
    if (!in_array($sort, array('name', 'status', 'author', 'version', 'modified', 'load_order'))) {
        $sort = 'name';
    }
    $sort_sql = $sort . ' ' . $dir;
    set_pref('plugin_sort_column', $sort, 'plugin', 2, '', 0, PREF_PRIVATE);
    set_pref('plugin_sort_dir', $dir, 'plugin', 2, '', 0, PREF_PRIVATE);
    $switch_dir = $dir == 'desc' ? 'asc' : 'desc';
    $rs = safe_rows_start('name, status, author, author_uri, version, description, length(help) as help, abs(strcmp(md5(code),code_md5)) as modified, load_order, flags', 'txp_plugin', '1 order by ' . $sort_sql);
    if ($rs and numRows($rs) > 0) {
        echo n . '<div id="' . $event . '_container" class="txp-container">';
        echo '<form action="index.php" id="plugin_form" class="multi_edit_form" method="post" name="longform">' . n . '<div class="txp-listtables">' . n . startTable('', '', 'txp-list') . n . '<thead>' . tr(n . hCell(fInput('checkbox', 'select_all', 0, '', '', '', '', '', 'select_all'), '', ' title="' . gTxt('toggle_all_selected') . '" class="multi-edit"') . n . column_head('plugin', 'name', 'plugin', true, $switch_dir, '', '', ('name' == $sort ? "{$dir} " : '') . 'name') . n . column_head('author', 'author', 'plugin', true, $switch_dir, '', '', ('author' == $sort ? "{$dir} " : '') . 'author') . n . column_head('version', 'version', 'plugin', true, $switch_dir, '', '', ('version' == $sort ? "{$dir} " : '') . 'version') . n . column_head('plugin_modified', 'modified', 'plugin', true, $switch_dir, '', '', ('modified' == $sort ? "{$dir} " : '') . 'modified') . n . hCell(gTxt('description'), '', ' class="description"') . n . column_head('active', 'status', 'plugin', true, $switch_dir, '', '', ('status' == $sort ? "{$dir} " : '') . 'status') . n . column_head('order', 'load_order', 'plugin', true, $switch_dir, '', '', ('load_order' == $sort ? "{$dir} " : '') . 'load-order') . n . hCell(gTxt('manage'), '', ' class="manage actions"')) . n . '</thead>';
        echo '<tbody>';
        while ($a = nextRow($rs)) {
            foreach ($a as $key => $value) {
                ${$key} = txpspecialchars($value);
            }
            // Fix up the description for clean cases
            $description = preg_replace(array('#&lt;br /&gt;#', '#&lt;(/?(a|b|i|em|strong))&gt;#', '#&lt;a href=&quot;(https?|\\.|\\/|ftp)([A-Za-z0-9:/?.=_]+?)&quot;&gt;#'), array('<br />', '<$1>', '<a href="$1$2">'), $description);
            $help = !empty($help) ? '<a class="plugin-help" href="?event=plugin' . a . 'step=plugin_help' . a . 'name=' . urlencode($name) . '">' . gTxt('help') . '</a>' : '';
            $plugin_prefs = $flags & PLUGIN_HAS_PREFS ? '<a class="plugin-prefs" href="?event=plugin_prefs.' . urlencode($name) . '">' . gTxt('plugin_prefs') . '</a>' : '';
            $manage = array();
            if ($help) {
                $manage[] = $help;
            }
            if ($plugin_prefs) {
                $manage[] = $plugin_prefs;
            }
            $manage_items = $manage ? join(tag(sp . '&#124;' . sp, 'span'), $manage) : '-';
            $edit_url = eLink('plugin', 'plugin_edit', 'name', $name, $name);
            echo tr(n . td(fInput('checkbox', 'selected[]', $name), '', 'multi-edit') . td($edit_url, '', 'name') . td(href($author, $author_uri, ' rel="external"'), '', 'author') . td($version, '', 'version') . td($modified ? '<span class="warning">' . gTxt('yes') . '</span>' : '', '', 'modified') . td($description, '', 'description') . td(status_link($status, $name, yes_no($status)), '', 'status') . td($load_order, '', 'load-order') . td($manage_items, '', 'manage'), $status ? ' class="active"' : '');
            unset($name, $page, $deletelink);
        }
        echo '</tbody>', n, endTable(), n, '</div>', n, plugin_multiedit_form('', $sort, $dir, '', ''), n, tInput(), n, '</form>', n, '</div>';
        // Show/hide "Options" link by setting the appropriate class on the plugins TR
        echo script_js(<<<EOS
textpattern.Relay.register('txpAsyncHref.success', function(event, data) {
\t\$(data['this']).closest('tr').toggleClass('active');
});
EOS
);
    }
}
示例#2
0
/**
 * Commits prefs to the database.
 */
function prefs_save()
{
    global $prefs, $gmtoffset, $is_dst, $auto_dst, $timezone_key, $txp_user;
    // Update custom fields count from database schema and cache it as a hidden pref.
    // TODO: move this when custom fields are refactored.
    $max_custom_fields = count(preg_grep('/^custom_\\d+/', getThings('describe ' . safe_pfx('textpattern'))));
    set_pref('max_custom_fields', $max_custom_fields, 'publish', 2);
    $sql = array();
    $sql[] = 'prefs_id = 1 and event != "" and type in(' . PREF_CORE . ', ' . PREF_PLUGIN . ', ' . PREF_HIDDEN . ')';
    $sql[] = "(user_name = '' or (user_name='" . doSlash($txp_user) . "' and name not in(\n            select name from " . safe_pfx('txp_prefs') . " where user_name = ''\n        )))";
    if (!get_pref('use_comments', 1, 1)) {
        $sql[] = "event != 'comments'";
    }
    $prefnames = safe_rows_start("name, event, user_name, val", 'txp_prefs', join(' and ', $sql));
    $post = stripPost();
    if (isset($post['tempdir']) && empty($post['tempdir'])) {
        $post['tempdir'] = find_temp_dir();
    }
    if (!empty($post['file_max_upload_size'])) {
        $post['file_max_upload_size'] = real_max_upload_size($post['file_max_upload_size']);
    }
    if (isset($post['auto_dst'])) {
        $prefs['auto_dst'] = $auto_dst = $post['auto_dst'];
        if (isset($post['is_dst']) && !$post['auto_dst']) {
            $is_dst = $post['is_dst'];
        }
    }
    // Forge $gmtoffset and $is_dst from $timezone_key if present.
    if (isset($post['timezone_key'])) {
        $key = $post['timezone_key'];
        $tzd = Txp::get('Textpattern_Date_Timezone')->getTimeZones();
        if (isset($tzd[$key])) {
            $prefs['timezone_key'] = $timezone_key = $key;
            $post['gmtoffset'] = $prefs['gmtoffset'] = $gmtoffset = $tzd[$key]['offset'];
            $post['is_dst'] = $prefs['is_dst'] = $is_dst = Txp::get('Textpattern_Date_Timezone')->isDst(null, $key);
        }
    }
    if (isset($post['siteurl'])) {
        $post['siteurl'] = preg_replace('#^https?://#', '', rtrim($post['siteurl'], '/ '));
    }
    while ($a = nextRow($prefnames)) {
        extract($a);
        if (!isset($post[$name]) || !has_privs('prefs.' . $event)) {
            continue;
        }
        if ($name === 'logging' && $post[$name] === 'none' && $post[$name] !== $val) {
            safe_truncate('txp_log');
        }
        if ($name === 'expire_logs_after' && (int) $post[$name] !== (int) $val) {
            safe_delete('txp_log', 'time < date_sub(now(), interval ' . intval($post[$name]) . ' day)');
        }
        update_pref($name, (string) $post[$name], null, null, null, null, (string) $user_name);
    }
    update_lastmod();
    prefs_list(gTxt('preferences_saved'));
}
示例#3
0
/**
 * Commits prefs to the database.
 */
function prefs_save()
{
    global $prefs, $gmtoffset, $is_dst, $auto_dst, $timezone_key, $txp_user;
    // Update custom fields count from database schema and cache it as a hidden pref.
    // TODO: move this when custom fields are refactored.
    $max_custom_fields = count(preg_grep('/^custom_\\d+/', getThings("DESCRIBE " . safe_pfx('textpattern'))));
    set_pref('max_custom_fields', $max_custom_fields, 'publish', 2);
    $sql = array();
    $sql[] = "prefs_id = 1 AND event != '' AND type IN (" . PREF_CORE . ", " . PREF_PLUGIN . ", " . PREF_HIDDEN . ")";
    $sql[] = "(user_name = '' OR (user_name = '" . doSlash($txp_user) . "' AND name NOT IN (\n            SELECT name FROM " . safe_pfx('txp_prefs') . " WHERE user_name = ''\n        )))";
    if (!get_pref('use_comments', 1, 1)) {
        $sql[] = "event != 'comments'";
    }
    $prefnames = safe_rows_start("name, event, user_name, val", 'txp_prefs', join(" AND ", $sql));
    $post = stripPost();
    if (isset($post['tempdir']) && empty($post['tempdir'])) {
        $post['tempdir'] = find_temp_dir();
    }
    if (!empty($post['file_max_upload_size'])) {
        $post['file_max_upload_size'] = real_max_upload_size($post['file_max_upload_size']);
    }
    if (isset($post['auto_dst'])) {
        $prefs['auto_dst'] = $auto_dst = $post['auto_dst'];
        if (isset($post['is_dst']) && !$post['auto_dst']) {
            $is_dst = $post['is_dst'];
        }
    }
    // Forge $gmtoffset and $is_dst from $timezone_key if present.
    if (isset($post['timezone_key'])) {
        $key = $post['timezone_key'];
        $tzd = Txp::get('\\Textpattern\\Date\\Timezone')->getTimeZones();
        if (isset($tzd[$key])) {
            $prefs['timezone_key'] = $timezone_key = $key;
            $post['gmtoffset'] = $prefs['gmtoffset'] = $gmtoffset = $tzd[$key]['offset'];
            $post['is_dst'] = $prefs['is_dst'] = $is_dst = Txp::get('\\Textpattern\\Date\\Timezone')->isDst(null, $key);
        }
    }
    if (isset($post['siteurl'])) {
        $post['siteurl'] = preg_replace('#^https?://#', '', rtrim($post['siteurl'], '/ '));
    }
    while ($a = nextRow($prefnames)) {
        extract($a);
        if (!isset($post[$name]) || !has_privs('prefs.' . $event)) {
            continue;
        }
        if ($name === 'logging' && $post[$name] === 'none' && $post[$name] !== $val) {
            safe_truncate('txp_log');
        }
        if ($name === 'expire_logs_after' && (int) $post[$name] !== (int) $val) {
            safe_delete('txp_log', "time < DATE_SUB(NOW(), INTERVAL " . intval($post[$name]) . " DAY)");
        }
        update_pref($name, (string) $post[$name], null, null, null, null, (string) $user_name);
    }
    update_lastmod('preferences_saved');
    prefs_list(gTxt('preferences_saved'));
}
示例#4
0
 /**
  * Saves pane visibility.
  */
 public function visible()
 {
     extract(psa(array('pane', 'visible', 'origin')));
     send_xml_response();
     if ($this->valid_token($pane) && preg_match('/^[a-z0-9_-]+$/i', $pane)) {
         set_pref("pane_{$pane}_visible", (int) ($visible === 'true'), $origin, PREF_HIDDEN, 'yesnoradio', 0, PREF_PRIVATE);
         return;
     }
     trigger_error('invalid_pane', E_USER_WARNING);
 }
示例#5
0
/**
 * The main panel listing all installed plugins.
 *
 * @param string|array $message The activity message
 */
function plugin_list($message = '')
{
    global $event;
    pagetop(gTxt('tab_plugins'), $message);
    extract(gpsa(array('sort', 'dir')));
    if ($sort === '') {
        $sort = get_pref('plugin_sort_column', 'name');
    } else {
        if (!in_array($sort, array('name', 'status', 'author', 'version', 'modified', 'load_order'))) {
            $sort = 'name';
        }
        set_pref('plugin_sort_column', $sort, 'plugin', 2, '', 0, PREF_PRIVATE);
    }
    if ($dir === '') {
        $dir = get_pref('plugin_sort_dir', 'asc');
    } else {
        $dir = $dir == 'desc' ? "desc" : "asc";
        set_pref('plugin_sort_dir', $dir, 'plugin', 2, '', 0, PREF_PRIVATE);
    }
    $sort_sql = "{$sort} {$dir}";
    $switch_dir = $dir == 'desc' ? 'asc' : 'desc';
    echo n . tag(hed(gTxt('tab_plugins'), 1, array('class' => 'txp-heading')), 'div', array('class' => 'txp-layout-2col-cell-1')) . n . tag_start('div', array('class' => 'txp-layout-1col', 'id' => $event . '_container')) . n . tag(plugin_form(), 'div', array('class' => 'txp-control-panel'));
    $rs = safe_rows_start("name, status, author, author_uri, version, description, length(help) AS help, ABS(STRCMP(MD5(code), code_md5)) AS modified, load_order, flags", 'txp_plugin', "1 = 1 ORDER BY {$sort_sql}");
    if ($rs and numRows($rs) > 0) {
        echo n . tag_start('form', array('class' => 'multi_edit_form', 'id' => 'plugin_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('plugin', 'name', 'plugin', true, $switch_dir, '', '', ('name' == $sort ? "{$dir} " : '') . 'txp-list-col-name') . column_head('author', 'author', 'plugin', true, $switch_dir, '', '', ('author' == $sort ? "{$dir} " : '') . 'txp-list-col-author') . column_head('version', 'version', 'plugin', true, $switch_dir, '', '', ('version' == $sort ? "{$dir} " : '') . 'txp-list-col-version') . column_head('plugin_modified', 'modified', 'plugin', true, $switch_dir, '', '', ('modified' == $sort ? "{$dir} " : '') . 'txp-list-col-modified') . hCell(gTxt('description'), '', ' class="txp-list-col-description" scope="col"') . column_head('active', 'status', 'plugin', true, $switch_dir, '', '', ('status' == $sort ? "{$dir} " : '') . 'txp-list-col-status') . column_head('order', 'load_order', 'plugin', true, $switch_dir, '', '', ('load_order' == $sort ? "{$dir} " : '') . 'txp-list-col-load-order') . hCell(gTxt('manage'), '', ' class="txp-list-col-manage" scope="col"')) . n . tag_end('thead') . n . tag_start('tbody');
        while ($a = nextRow($rs)) {
            foreach ($a as $key => $value) {
                ${$key} = txpspecialchars($value);
            }
            // Fix up the description for clean cases.
            $description = preg_replace(array('#&lt;br /&gt;#', '#&lt;(/?(a|b|i|em|strong))&gt;#', '#&lt;a href=&quot;(https?|\\.|\\/|ftp)([A-Za-z0-9:/?.=_]+?)&quot;&gt;#'), array('<br />', '<$1>', '<a href="$1$2">'), $description);
            if (!empty($help)) {
                $help = href(gTxt('help'), array('event' => 'plugin', 'step' => 'plugin_help', 'name' => $name), array('class' => 'plugin-help'));
            }
            if ($flags & PLUGIN_HAS_PREFS) {
                $plugin_prefs = href(gTxt('plugin_prefs'), array('event' => 'plugin_prefs.' . $name), array('class' => 'plugin-prefs'));
            } else {
                $plugin_prefs = '';
            }
            $manage = array();
            if ($help) {
                $manage[] = $help;
            }
            if ($plugin_prefs) {
                $manage[] = $plugin_prefs;
            }
            $manage_items = $manage ? join(tag(sp . '&#124;' . sp, 'span'), $manage) : '-';
            $edit_url = eLink('plugin', 'plugin_edit', 'name', $name, $name);
            echo tr(td(fInput('checkbox', 'selected[]', $name), '', 'txp-list-col-multi-edit') . hCell($edit_url, '', ' class="txp-list-col-name" scope="row"') . td(href($author, $a['author_uri'], array('rel' => 'external')), '', 'txp-list-col-author') . td($version, '', 'txp-list-col-version') . td($modified ? span(gTxt('yes'), array('class' => 'warning')) : '', '', 'txp-list-col-modified') . td($description, '', 'txp-list-col-description') . td(status_link($status, $name, yes_no($status)), '', 'txp-list-col-status') . td($load_order, '', 'txp-list-col-load-order') . td($manage_items, '', 'txp-list-col-manage'), $status ? ' class="active"' : '');
            unset($name, $page, $deletelink);
        }
        echo n . tag_end('tbody') . n . tag_end('table') . n . tag_end('div') . plugin_multiedit_form('', $sort, $dir, '', '') . tInput() . n . tag_end('form');
    }
    echo n . tag_end('div');
}
示例#6
0
 /**
  * Installer.
  */
 public function install()
 {
     $position = 250;
     foreach (array('path' => array('text_input', '../rah_blobin'), 'key' => array('text_input', md5(uniqid(mt_rand(), true))), 'sync' => array('rah_blobin_sync', 0)) as $name => $val) {
         $n = 'rah_blobin_' . $name;
         if (get_pref($n, false) === false) {
             set_pref($n, $val[1], 'rah_blobin', PREF_PLUGIN, $val[0], $position);
         }
         $position++;
     }
 }
function _sed_si_install_pref($key, $value, $type)
{
    global $prefs, $textarray, $_sed_si_l18n;
    $k = _sed_si_prefix_key($key);
    if (!array_key_exists($k, $prefs)) {
        set_pref($k, $value, sed_si_prefix, 1, $type);
        $prefs[$k] = $value;
    }
    # Insert the preference strings for non-mlp sites...
    if (!array_key_exists($k, $textarray)) {
        $textarray[$k] = $_sed_si_l18n[$key];
    }
}
示例#8
0
function plugin_list($message = '')
{
    global $event;
    pagetop(gTxt('edit_plugins'), $message);
    echo '<div id="' . $event . '_control" class="txp-control-panel">';
    echo n . n . startTable('edit', '', 'plugin-install') . tr(tda(plugin_form(), ' colspan="8" style="height: 30px; border: none;"')) . endTable() . '</div>';
    extract(gpsa(array('sort', 'dir')));
    if ($sort === '') {
        $sort = get_pref('plugin_sort_column', 'name');
    }
    if ($dir === '') {
        $dir = get_pref('plugin_sort_dir', 'asc');
    }
    $dir = $dir == 'desc' ? 'desc' : 'asc';
    if (!in_array($sort, array('name', 'status', 'author', 'version', 'modified', 'load_order'))) {
        $sort = 'name';
    }
    $sort_sql = $sort . ' ' . $dir;
    set_pref('plugin_sort_column', $sort, 'plugin', 2, '', 0, PREF_PRIVATE);
    set_pref('plugin_sort_dir', $dir, 'plugin', 2, '', 0, PREF_PRIVATE);
    $switch_dir = $dir == 'desc' ? 'asc' : 'desc';
    $rs = safe_rows_start('name, status, author, author_uri, version, description, length(help) as help, abs(strcmp(md5(code),code_md5)) as modified, load_order, flags', 'txp_plugin', '1 order by ' . $sort_sql);
    if ($rs and numRows($rs) > 0) {
        echo n . '<div id="' . $event . '_container" class="txp-container txp-list">';
        echo '<form action="index.php" id="plugin_form" method="post" name="longform" onsubmit="return verify(\'' . gTxt('are_you_sure') . '\')">' . startTable('list', '', 'list') . n . '<thead>' . tr(column_head('plugin', 'name', 'plugin', true, $switch_dir, '', '', ('name' == $sort ? "{$dir} " : '') . 'name') . column_head('author', 'author', 'plugin', true, $switch_dir, '', '', ('author' == $sort ? "{$dir} " : '') . 'author') . column_head('version', 'version', 'plugin', true, $switch_dir, '', '', ('version' == $sort ? "{$dir} " : '') . 'version') . column_head('plugin_modified', 'modified', 'plugin', true, $switch_dir, '', '', ('modified' == $sort ? "{$dir} " : '') . 'modified') . hCell(gTxt('description'), '', ' class="description"') . column_head('active', 'status', 'plugin', true, $switch_dir, '', '', ('status' == $sort ? "{$dir} " : '') . 'status') . column_head('order', 'load_order', 'plugin', true, $switch_dir, '', '', ('load_order' == $sort ? "{$dir} " : '') . 'load-order') . hCell(gTxt('manage'), '', ' class="manage actions"') . hCell('', '', ' class="multi-edit"')) . n . '</thead>';
        $tfoot = n . '<tfoot>' . tr(tda(select_buttons() . plugin_multiedit_form('', $sort, $dir, '', ''), ' class="multi-edit" colspan="10" style="text-align: right; border: none;"')) . n . '</tfoot>';
        echo $tfoot;
        echo '<tbody>';
        $ctr = 1;
        while ($a = nextRow($rs)) {
            foreach ($a as $key => $value) {
                ${$key} = htmlspecialchars($value);
            }
            // Fix up the description for clean cases
            $description = preg_replace(array('#&lt;br /&gt;#', '#&lt;(/?(a|b|i|em|strong))&gt;#', '#&lt;a href=&quot;(https?|\\.|\\/|ftp)([A-Za-z0-9:/?.=_]+?)&quot;&gt;#'), array('<br />', '<$1>', '<a href="$1$2">'), $description);
            $help = !empty($help) ? n . t . '<li class="action-view"><a href="?event=plugin' . a . 'step=plugin_help' . a . 'name=' . urlencode($name) . '">' . gTxt('help') . '</a></li>' : '';
            $plugin_prefs = $flags & PLUGIN_HAS_PREFS && $status ? n . t . '<li class="action-options"><a href="?event=plugin_prefs.' . urlencode($name) . '">' . gTxt('plugin_prefs') . '</a></li>' : '';
            echo tr(n . td($name, '', 'name') . td(href($author, $author_uri), '', 'author') . td($version, 10, 'version') . td($modified ? gTxt('yes') : '', '', 'modified') . td($description, 260, 'description') . td(status_link($status, $name, yes_no($status)), 30, 'status') . td($load_order, '', 'load-order') . td(n . '<ul class="actions">' . $help . n . t . '<li class="action-edit">' . eLink('plugin', 'plugin_edit', 'name', $name, gTxt('edit')) . '</li>' . $plugin_prefs . n . '</ul>', '', 'manage') . td(fInput('checkbox', 'selected[]', $name), 30, 'multi-edit'), ' class="' . ($ctr % 2 == 0 ? 'even' : 'odd') . '"');
            $ctr++;
            unset($name, $page, $deletelink);
        }
        echo '</tbody>' . n . endTable() . n . '</form>' . n . '</div>';
    }
}
示例#9
0
 function saveconfig()
 {
     $_SESSION["prefs_cache"] = false;
     $orig_theme = get_pref($this->link, "_THEME_ID");
     foreach (array_keys($_POST) as $pref_name) {
         $pref_name = db_escape_string($pref_name);
         $value = db_escape_string($_POST[$pref_name]);
         if ($pref_name == 'DIGEST_PREFERRED_TIME') {
             if (get_pref($this->link, 'DIGEST_PREFERRED_TIME') != $value) {
                 db_query($this->link, "UPDATE ttrss_users SET\n\t\t\t\t\t\tlast_digest_sent = NULL WHERE id = " . $_SESSION['uid']);
             }
         }
         set_pref($this->link, $pref_name, $value);
     }
     if ($orig_theme != get_pref($this->link, "_THEME_ID")) {
         print "PREFS_THEME_CHANGED";
     } else {
         print __("The configuration was saved.");
     }
 }
示例#10
0
 /**
  * Installer
  * @param string $event Admin-side event.
  * @param string $step Admin-side, plugin-lifecycle step.
  */
 public static function install($event = '', $step = '')
 {
     global $prefs;
     if ($step == 'deleted') {
         safe_delete('txp_prefs', "name like 'rah\\_bitly\\_%'");
         return;
     }
     if (isset($prefs['rah_bitly_version']) && $prefs['rah_bitly_version'] == self::$version) {
         return;
     }
     $position = 250;
     foreach (array('login', 'apikey', 'field') as $name) {
         if (!isset($prefs['rah_bitly_' . $name])) {
             $html = $name == 'field' ? 'rah_bitly_fields' : 'text_input';
             safe_insert('txp_prefs', "prefs_id=1,\n\t\t\t\t\tname='rah_bitly_" . $name . "',\n\t\t\t\t\tval='',\n\t\t\t\t\ttype=1,\n\t\t\t\t\tevent='rah_bitly',\n\t\t\t\t\thtml='{$html}',\n\t\t\t\t\tposition=" . $position);
             $prefs['rah_bitly_' . $name] = '';
         }
         $position++;
     }
     set_pref('rah_bitly_version', self::$version, 'rah_bitly', 2, '', 0);
     $prefs['rah_bitly_version'] = self::$version;
 }
示例#11
0
 function init($name = '')
 {
     static $instance;
     if (empty($name)) {
         $name = pluggable_ui('admin_side', 'theme_name', get_pref('theme_name', 'classic'));
     }
     if ($instance && is_object($instance) && $name == $instance->name) {
         return $instance;
     } else {
         $instance = null;
     }
     $path = txpath . DS . THEME . DS . $name . DS . $name . '.php';
     if (is_file($path)) {
         require_once $path;
     } else {
         $name = 'classic';
         set_pref('theme_name', $name);
         require_once txpath . DS . THEME . DS . $name . DS . $name . '.php';
     }
     $t = "{$name}_theme";
     $instance = new $t($name);
     return $instance;
 }
示例#12
0
function section_set_default()
{
    set_pref('default_section', ps('default_section'), 'section', PREF_HIDDEN, '', 0);
    send_script_response();
}
示例#13
0
文件: txp_log.php 项目: psic/websites
function log_list($message = '')
{
    global $event, $log_list_pageby, $expire_logs_after;
    pagetop(gTxt('visitor_logs'), $message);
    extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method')));
    if ($sort === '') {
        $sort = get_pref('log_sort_column', 'time');
    }
    if ($dir === '') {
        $dir = get_pref('log_sort_dir', 'desc');
    }
    $dir = $dir == 'asc' ? 'asc' : 'desc';
    $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;
    }
    set_pref('log_sort_column', $sort, 'log', 2, '', 0, PREF_PRIVATE);
    set_pref('log_sort_dir', $dir, 'log', 2, '', 0, PREF_PRIVATE);
    $switch_dir = $dir == 'desc' ? 'asc' : 'desc';
    $criteria = 1;
    if ($search_method and $crit) {
        $crit_escaped = doSlash(str_replace(array('\\', '%', '_', '\''), array('\\\\', '\\%', '\\_', '\\\''), $crit));
        $critsql = array('ip' => "ip like '%{$crit_escaped}%'", 'host' => "host like '%{$crit_escaped}%'", 'page' => "page like '%{$crit_escaped}%'", 'refer' => "refer like '%{$crit_escaped}%'", 'method' => "method like '%{$crit_escaped}%'", 'status' => "status like '%{$crit_escaped}%'");
        if (array_key_exists($search_method, $critsql)) {
            $criteria = $critsql[$search_method];
            $limit = 500;
        } else {
            $search_method = '';
            $crit = '';
        }
    } else {
        $search_method = '';
        $crit = '';
    }
    $total = safe_count('txp_log', "{$criteria}");
    echo '<div id="' . $event . '_control" class="txp-control-panel">';
    if ($total < 1) {
        if ($criteria != 1) {
            echo n . log_search_form($crit, $search_method) . n . graf(gTxt('no_results_found'), ' class="indicator"') . '</div>';
        } else {
            echo graf(gTxt('no_refers_recorded'), ' class="indicator"') . '</div>';
        }
        return;
    }
    $limit = max($log_list_pageby, 15);
    list($page, $offset, $numPages) = pager($total, $limit, $page);
    echo n . log_search_form($crit, $search_method) . '</div>';
    $rs = safe_rows_start('*, unix_timestamp(time) as uTime', 'txp_log', "{$criteria} order by {$sort_sql} limit {$offset}, {$limit}");
    if ($rs) {
        echo n . '<div id="' . $event . '_container" class="txp-container txp-list">';
        echo n . n . '<form action="index.php" id="log_form" method="post" name="longform" onsubmit="return verify(\'' . gTxt('are_you_sure') . '\')">' . startTable('list', '', 'list', '', '90%') . n . '<thead>' . n . tr(n . column_head('time', 'time', 'log', true, $switch_dir, $crit, $search_method, ('time' == $sort ? "{$dir} " : '') . 'date time') . column_head('IP', 'ip', 'log', true, $switch_dir, $crit, $search_method, ('ip' == $sort ? "{$dir} " : '') . 'log_detail ip') . column_head('host', 'host', 'log', true, $switch_dir, $crit, $search_method, ('host' == $sort ? "{$dir} " : '') . 'host') . column_head('page', 'page', 'log', true, $switch_dir, $crit, $search_method, ('page' == $sort ? "{$dir} " : '') . 'page') . column_head('referrer', 'refer', 'log', true, $switch_dir, $crit, $search_method, ('refer' == $sort ? "{$dir} " : '') . 'refer') . column_head('method', 'method', 'log', true, $switch_dir, $crit, $search_method, ('method' == $sort ? "{$dir} " : '') . 'log_detail method') . column_head('status', 'status', 'log', true, $switch_dir, $crit, $search_method, ('status' == $sort ? "{$dir} " : '') . 'log_detail status') . hCell('', '', ' class="multi-edit"')) . n . '</thead>';
        $tfoot = n . '<tfoot>' . tr(tda(toggle_box('log_detail'), ' class="detail-toggle" colspan="2" style="text-align: left; border: none;"') . tda(select_buttons() . log_multiedit_form($page, $sort, $dir, $crit, $search_method), ' class="multi-edit" colspan="6" style="text-align: right; border: none;"')) . n . '</tfoot>';
        echo $tfoot;
        echo '<tbody>';
        $ctr = 1;
        while ($a = nextRow($rs)) {
            extract($a, EXTR_PREFIX_ALL, 'log');
            if ($log_refer) {
                $log_refer = 'http://' . $log_refer;
                $log_refer = '<a href="' . htmlspecialchars($log_refer) . '" target="_blank">' . htmlspecialchars(soft_wrap($log_refer, 30)) . '</a>';
            }
            if ($log_page) {
                $log_anchor = preg_replace('/\\/$/', '', $log_page);
                $log_anchor = soft_wrap(substr($log_anchor, 1), 30);
                $log_page = '<a href="' . htmlspecialchars($log_page) . '" target="_blank">' . htmlspecialchars($log_anchor) . '</a>';
                if ($log_method == 'POST') {
                    $log_page = '<strong>' . $log_page . '</strong>';
                }
            }
            echo tr(n . td(gTime($log_uTime), 85, 'date time') . td($log_ip, 20, 'log_detail ip') . td(soft_wrap($log_host, 30), '', 'host') . td($log_page, '', 'page') . td($log_refer, '', 'refer') . td(htmlspecialchars($log_method), 60, 'log_detail method') . td($log_status, 60, 'log_detail status') . td(fInput('checkbox', 'selected[]', $log_id), '', 'multi-edit'), ' class="' . ($ctr % 2 == 0 ? 'even' : 'odd') . '"');
            $ctr++;
        }
        echo '</tbody>' . n . endTable() . n . '</form>' . n . '<div id="' . $event . '_navigation" class="txp-navigation">' . n . nav_form('log', $page, $numPages, $sort, $dir, $crit, $search_method, $total, $limit) . n . pageby_form('log', $log_list_pageby) . n . '</div>' . n . '</div>';
    }
}
示例#14
0
<?php

ob_start("ob_gzhandler");
session_start();
require_once 'includes/main.inc';
if (!isset($_SESSION['language'])) {
    @set_pref('language', 'en');
}
if (!isset($_SESSION['limit'])) {
    @set_pref('limit', false);
}
head('browse');
?>
        <div id="main">
          <h2><?php 
print _("Browse");
?>
</h2>
          <p><?php 
print _("You may browse through the loci and retrieve all related information.");
?>
</p>
<?php 
$sql = sql_connect($config['db']);
$result = sql_query('SELECT a.prefix, a.id, a.name, a.functions, a.status, b.status FROM locus AS a, status AS b WHERE b.lang=\'' . get_pref('language') . '\' AND a.status=b.id' . (get_pref('limit') ? ' AND a.status>0 AND a.status<=' . get_pref('limit') : '') . ' ORDER BY a.name ASC;', $sql);
if (!strlen($r = sql_last_error($sql)) && sql_num_rows($result) > 0) {
    print "          <ul class=\"result locus\">\n";
    while ($row = sql_fetch_row($result)) {
        if (!empty($row[4])) {
            print '            <li><a href="' . $config['server'] . '/locus/L' . decoct($row[0]) . '.' . decoct($row[1]) . '" title="L' . decoct($row[0]) . '.' . decoct($row[1]) . '" class="locus"><span class="name">' . $row[2] . '</span><span class="date"><img src="' . $config['server'] . '/images/status_' . $row[4] . '.png" height="8" width="8" alt="' . $row[5] . '" /></span><span class="description">' . (strlen($row[3]) > 53 ? substr($row[3], 0, 50) . '...' : $row[3]) . "</span></a></li>\n";
        } else {
示例#15
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');
}
示例#16
0
 function view()
 {
     $timing_info = getmicrotime();
     $reply = array();
     if ($_REQUEST["debug"]) {
         $timing_info = print_checkpoint("0", $timing_info);
     }
     $omode = db_escape_string($_REQUEST["omode"]);
     $feed = db_escape_string($_REQUEST["feed"]);
     $method = db_escape_string($_REQUEST["m"]);
     $view_mode = db_escape_string($_REQUEST["view_mode"]);
     $limit = (int) get_pref($this->link, "DEFAULT_ARTICLE_LIMIT");
     @($cat_view = $_REQUEST["cat"] == "true");
     @($next_unread_feed = db_escape_string($_REQUEST["nuf"]));
     @($offset = db_escape_string($_REQUEST["skip"]));
     @($vgroup_last_feed = db_escape_string($_REQUEST["vgrlf"]));
     $order_by = db_escape_string($_REQUEST["order_by"]);
     $include_children = $_REQUEST["include_children"] == "true";
     if (is_numeric($feed)) {
         $feed = (int) $feed;
     }
     /* Feed -5 is a special case: it is used to display auxiliary information
      * when there's nothing to load - e.g. no stuff in fresh feed */
     if ($feed == -5) {
         print json_encode(generate_dashboard_feed($this->link));
         return;
     }
     $result = false;
     if ($feed < -10) {
         $label_feed = -11 - $feed;
         $result = db_query($this->link, "SELECT id FROM ttrss_labels2 WHERE\r\n\t\t\t\t\t\t\tid = '{$label_feed}' AND owner_uid = " . $_SESSION['uid']);
     } else {
         if (!$cat_view && is_numeric($feed) && $feed > 0) {
             $result = db_query($this->link, "SELECT id FROM ttrss_feeds WHERE\r\n\t\t\t\t\t\t\tid = '{$feed}' AND owner_uid = " . $_SESSION['uid']);
         } else {
             if ($cat_view && is_numeric($feed) && $feed > 0) {
                 $result = db_query($this->link, "SELECT id FROM ttrss_feed_categories WHERE\r\n\t\t\t\t\t\t\tid = '{$feed}' AND owner_uid = " . $_SESSION['uid']);
             }
         }
     }
     if ($result && db_num_rows($result) == 0) {
         print json_encode(generate_error_feed($this->link, __("Feed not found.")));
         return;
     }
     /* Updating a label ccache means recalculating all of the caches
      * so for performance reasons we don't do that here */
     if ($feed >= 0) {
         ccache_update($this->link, $feed, $_SESSION["uid"], $cat_view);
     }
     set_pref($this->link, "_DEFAULT_VIEW_MODE", $view_mode);
     set_pref($this->link, "_DEFAULT_VIEW_LIMIT", $limit);
     set_pref($this->link, "_DEFAULT_VIEW_ORDER_BY", $order_by);
     set_pref($this->link, "_DEFAULT_INCLUDE_CHILDREN", $include_children);
     if (!$cat_view && is_numeric($feed) && $feed > 0) {
         db_query($this->link, "UPDATE ttrss_feeds SET last_viewed = NOW()\r\n\t\t\t\t\t\t\tWHERE id = '{$feed}' AND owner_uid = " . $_SESSION["uid"]);
     }
     $reply['headlines'] = array();
     if (!$next_unread_feed) {
         $reply['headlines']['id'] = $feed;
     } else {
         $reply['headlines']['id'] = $next_unread_feed;
     }
     $reply['headlines']['is_cat'] = (bool) $cat_view;
     $override_order = false;
     if (get_pref($this->link, "SORT_HEADLINES_BY_FEED_DATE", $owner_uid)) {
         $date_sort_field = "updated";
     } else {
         $date_sort_field = "date_entered";
     }
     switch ($order_by) {
         case "date":
             if (get_pref($this->link, 'REVERSE_HEADLINES', $owner_uid)) {
                 $override_order = "{$date_sort_field}";
             } else {
                 $override_order = "{$date_sort_field} DESC";
             }
             break;
         case "title":
             if (get_pref($this->link, 'REVERSE_HEADLINES', $owner_uid)) {
                 $override_order = "title DESC, {$date_sort_field}";
             } else {
                 $override_order = "title, {$date_sort_field} DESC";
             }
             break;
         case "score":
             if (get_pref($this->link, 'REVERSE_HEADLINES', $owner_uid)) {
                 $override_order = "score, {$date_sort_field}";
             } else {
                 $override_order = "score DESC, {$date_sort_field} DESC";
             }
             break;
     }
     if ($_REQUEST["debug"]) {
         $timing_info = print_checkpoint("04", $timing_info);
     }
     $ret = $this->format_headlines_list($feed, $method, $view_mode, $limit, $cat_view, $next_unread_feed, $offset, $vgroup_last_feed, $override_order, $include_children);
     $topmost_article_ids = $ret[0];
     $headlines_count = $ret[1];
     $returned_feed = $ret[2];
     $disable_cache = $ret[3];
     $vgroup_last_feed = $ret[4];
     $reply['headlines']['content'] =& $ret[5]['content'];
     $reply['headlines']['toolbar'] =& $ret[5]['toolbar'];
     if ($_REQUEST["debug"]) {
         $timing_info = print_checkpoint("05", $timing_info);
     }
     $reply['headlines-info'] = array("count" => (int) $headlines_count, "vgroup_last_feed" => $vgroup_last_feed, "disable_cache" => (bool) $disable_cache);
     if ($_REQUEST["debug"]) {
         $timing_info = print_checkpoint("20", $timing_info);
     }
     if (is_array($topmost_article_ids) && !get_pref($this->link, 'COMBINED_DISPLAY_MODE') && !$_SESSION["bw_limit"]) {
         $articles = array();
         foreach ($topmost_article_ids as $id) {
             array_push($articles, format_article($this->link, $id, false));
         }
         $reply['articles'] = $articles;
     }
     if ($_REQUEST["debug"]) {
         $timing_info = print_checkpoint("30", $timing_info);
     }
     $reply['runtime-info'] = make_runtime_info($this->link);
     print json_encode($reply);
 }
示例#17
0
 function setpref()
 {
     // set_pref escapes input, so no need to double escape it here
     $key = $_REQUEST['key'];
     $value = str_replace("\n", "<br/>", $_REQUEST['value']);
     set_pref($this->link, $key, $value, $_SESSION['uid'], $key != 'USER_STYLESHEET');
     print json_encode(array("param" => $key, "value" => $value));
 }
示例#18
0
function module_pref_prefs($link)
{
    global $access_level_names;
    $subop = $_REQUEST["subop"];
    $prefs_blacklist = array("HIDE_FEEDLIST", "SYNC_COUNTERS", "ENABLE_LABELS", "ENABLE_SEARCH_TOOLBAR", "HIDE_READ_FEEDS");
    $profile_blacklist = array("ALLOW_DUPLICATE_POSTS", "PURGE_OLD_DAYS", "PURGE_UNREAD_ARTICLES", "DIGEST_ENABLE", "DIGEST_CATCHUP", "BLACKLISTED_TAGS", "ENABLE_FEED_ICONS", "ENABLE_API_ACCESS", "UPDATE_POST_ON_CHECKSUM_CHANGE", "DEFAULT_UPDATE_INTERVAL", "MARK_UNREAD_ON_UPDATE");
    if (FORCE_ARTICLE_PURGE != 0) {
        array_push($prefs_blacklist, "PURGE_OLD_DAYS");
        array_push($prefs_blacklist, "PURGE_UNREAD_ARTICLES");
    }
    if ($subop == "change-password") {
        $old_pw = $_POST["OLD_PASSWORD"];
        $new_pw = $_POST["NEW_PASSWORD"];
        $con_pw = $_POST["CONFIRM_PASSWORD"];
        if ($old_pw == "") {
            print "ERROR: " . __("Old password cannot be blank.");
            return;
        }
        if ($new_pw == "") {
            print "ERROR: " . __("New password cannot be blank.");
            return;
        }
        if ($new_pw != $con_pw) {
            print "ERROR: " . __("Entered passwords do not match.");
            return;
        }
        $old_pw_hash1 = encrypt_password($_POST["OLD_PASSWORD"]);
        $old_pw_hash2 = encrypt_password($_POST["OLD_PASSWORD"], $_SESSION["name"]);
        $new_pw_hash = encrypt_password($_POST["NEW_PASSWORD"], $_SESSION["name"]);
        $active_uid = $_SESSION["uid"];
        if ($old_pw && $new_pw) {
            $login = db_escape_string($_SERVER['PHP_AUTH_USER']);
            $result = db_query($link, "SELECT id FROM ttrss_users WHERE \n\t\t\t\t\tid = '{$active_uid}' AND (pwd_hash = '{$old_pw_hash1}' OR \n\t\t\t\t\t\tpwd_hash = '{$old_pw_hash2}')");
            if (db_num_rows($result) == 1) {
                db_query($link, "UPDATE ttrss_users SET pwd_hash = '{$new_pw_hash}' \n\t\t\t\t\t\tWHERE id = '{$active_uid}'");
                $_SESSION["pwd_hash"] = $new_pw_hash;
                print __("Password has been changed.");
            } else {
                print "ERROR: " . __('Old password is incorrect.');
            }
        }
        return;
    } else {
        if ($subop == "save-config") {
            #			$_SESSION["prefs_op_result"] = "save-config";
            $_SESSION["prefs_cache"] = false;
            //			print_r($_POST);
            $orig_theme = get_pref($link, "_THEME_ID");
            foreach (array_keys($_POST) as $pref_name) {
                $pref_name = db_escape_string($pref_name);
                $value = db_escape_string($_POST[$pref_name]);
                set_pref($link, $pref_name, $value);
            }
            if ($orig_theme != get_pref($link, "_THEME_ID")) {
                print "PREFS_THEME_CHANGED";
            } else {
                print __("The configuration was saved.");
            }
            return;
        } else {
            if ($subop == "getHelp") {
                $pref_name = db_escape_string($_REQUEST["pn"]);
                $result = db_query($link, "SELECT help_text FROM ttrss_prefs\n\t\t\t\tWHERE pref_name = '{$pref_name}'");
                if (db_num_rows($result) > 0) {
                    $help_text = db_fetch_result($result, 0, "help_text");
                    print $help_text;
                } else {
                    printf(__("Unknown option: %s"), $pref_name);
                }
            } else {
                if ($subop == "change-email") {
                    $email = db_escape_string($_POST["email"]);
                    $active_uid = $_SESSION["uid"];
                    db_query($link, "UPDATE ttrss_users SET email = '{$email}' \n\t\t\t\tWHERE id = '{$active_uid}'");
                    print __("E-mail has been changed.");
                    return;
                } else {
                    if ($subop == "reset-config") {
                        $_SESSION["prefs_op_result"] = "reset-to-defaults";
                        if ($_SESSION["profile"]) {
                            $profile_qpart = "profile = '" . $_SESSION["profile"] . "'";
                        } else {
                            $profile_qpart = "profile IS NULL";
                        }
                        db_query($link, "DELETE FROM ttrss_user_prefs \n\t\t\t\tWHERE {$profile_qpart} AND owner_uid = " . $_SESSION["uid"]);
                        initialize_user_prefs($link, $_SESSION["uid"], $_SESSION["profile"]);
                        print "PREFS_THEME_CHANGED";
                        //			print __("The configuration was reset to defaults.");
                        return;
                    } else {
                        set_pref($link, "_PREFS_ACTIVE_TAB", "genConfig");
                        if ($_SESSION["profile"]) {
                            print_notice("Some preferences are only available in default profile.");
                        }
                        if (!SINGLE_USER_MODE) {
                            $result = db_query($link, "SELECT id FROM ttrss_users\n\t\t\t\t\tWHERE id = " . $_SESSION["uid"] . " AND pwd_hash \n\t\t\t\t\t= 'SHA1:5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8'");
                            if (db_num_rows($result) != 0) {
                                print format_warning(__("Your password is at default value, \n\t\t\t\t\t\tplease change it."), "default_pass_warning");
                            }
                            /*				if ($_SESSION["pwd_change_result"] == "failed") {
                            					print format_warning("Could not change the password.");
                            				}
                            
                            				if ($_SESSION["pwd_change_result"] == "ok") {
                            					print format_notice("Password was changed.");
                            				}
                            
                            				$_SESSION["pwd_change_result"] = ""; */
                            /*				if ($_SESSION["prefs_op_result"] == "reset-to-defaults") {
                            					print format_notice(__("The configuration was reset to defaults."));
                            } */
                            #				if ($_SESSION["prefs_op_result"] == "save-config") {
                            #					print format_notice(__("The configuration was saved."));
                            #				}
                            $_SESSION["prefs_op_result"] = "";
                            print "<form onsubmit='return false' id='change_email_form'>";
                            print "<table width=\"100%\" class=\"prefPrefsList\">";
                            print "<tr><td colspan='3'><h3>" . __("Personal data") . "</h3></tr></td>";
                            $result = db_query($link, "SELECT email,access_level FROM ttrss_users\n\t\t\t\t\tWHERE id = " . $_SESSION["uid"]);
                            $email = db_fetch_result($result, 0, "email");
                            print "<tr><td width=\"40%\">" . __('E-mail') . "</td>";
                            print "<td class=\"prefValue\"><input class=\"editbox\" name=\"email\" \n\t\t\t\t\tonfocus=\"javascript:disableHotkeys();\" \n\t\t\t\t\tonblur=\"javascript:enableHotkeys();\"\n\t\t\t\t\tonkeypress=\"return filterCR(event, changeUserEmail)\"\n\t\t\t\t\tvalue=\"{$email}\"></td></tr>";
                            if (!SINGLE_USER_MODE) {
                                $access_level = db_fetch_result($result, 0, "access_level");
                                print "<tr><td width=\"40%\">" . __('Access level') . "</td>";
                                print "<td>" . $access_level_names[$access_level] . "</td></tr>";
                            }
                            print "</table>";
                            print "<input type=\"hidden\" name=\"op\" value=\"pref-prefs\">";
                            print "<input type=\"hidden\" name=\"subop\" value=\"change-email\">";
                            print "</form>";
                            print "<p><button onclick=\"return changeUserEmail()\">" . __("Change e-mail") . "</button>";
                            print "<form onsubmit=\"return false\" \n\t\t\t\t\tname=\"change_pass_form\" id=\"change_pass_form\">";
                            print "<table width=\"100%\" class=\"prefPrefsList\">";
                            print "<tr><td colspan='3'><h3>" . __("Authentication") . "</h3></tr></td>";
                            print "<tr><td width=\"40%\">" . __("Old password") . "</td>";
                            print "<td class=\"prefValue\"><input class=\"editbox\" type=\"password\"\n\t\t\t\t\tonfocus=\"javascript:disableHotkeys();\" \n\t\t\t\t\tonblur=\"javascript:enableHotkeys();\"\n\t\t\t\t\tonkeypress=\"return filterCR(event, changeUserPassword)\"\n\t\t\t\t\tname=\"OLD_PASSWORD\"></td></tr>";
                            print "<tr><td width=\"40%\">" . __("New password") . "</td>";
                            print "<td class=\"prefValue\"><input class=\"editbox\" type=\"password\"\n\t\t\t\t\tonfocus=\"javascript:disableHotkeys();\" \n\t\t\t\t\tonblur=\"javascript:enableHotkeys();\"\n\t\t\t\t\tonkeypress=\"return filterCR(event, changeUserPassword)\"\n\t\t\t\t\tname=\"NEW_PASSWORD\"></td></tr>";
                            print "<tr><td width=\"40%\">" . __("Confirm password") . "</td>";
                            print "<td class=\"prefValue\"><input class=\"editbox\" type=\"password\"\n\t\t\t\t\tonfocus=\"javascript:disableHotkeys();\" \n\t\t\t\t\tonblur=\"javascript:enableHotkeys();\"\n\t\t\t\t\tonkeypress=\"return filterCR(event, changeUserPassword)\"\n\t\t\t\t\tname=\"CONFIRM_PASSWORD\"></td></tr>";
                            print "</table>";
                            print "<input type=\"hidden\" name=\"op\" value=\"pref-prefs\">";
                            print "<input type=\"hidden\" name=\"subop\" value=\"change-password\">";
                            print "</form>";
                            print "<p><button\tonclick=\"return changeUserPassword()\">" . __("Change password") . "</button>";
                        }
                        if ($_SESSION["profile"]) {
                            initialize_user_prefs($link, $_SESSION["uid"], $_SESSION["profile"]);
                            $profile_qpart = "profile = '" . $_SESSION["profile"] . "'";
                        } else {
                            initialize_user_prefs($link, $_SESSION["uid"]);
                            $profile_qpart = "profile IS NULL";
                        }
                        $result = db_query($link, "SELECT \n\t\t\t\tttrss_user_prefs.pref_name,short_desc,help_text,value,type_name,\n\t\t\t\tsection_name,def_value,section_id\n\t\t\t\tFROM ttrss_prefs,ttrss_prefs_types,ttrss_prefs_sections,ttrss_user_prefs\n\t\t\t\tWHERE type_id = ttrss_prefs_types.id AND \n\t\t\t\t\t{$profile_qpart} AND\n\t\t\t\t\tsection_id = ttrss_prefs_sections.id AND\n\t\t\t\t\tttrss_user_prefs.pref_name = ttrss_prefs.pref_name AND\n\t\t\t\t\tshort_desc != '' AND\n\t\t\t\t\towner_uid = " . $_SESSION["uid"] . "\n\t\t\t\tORDER BY section_id,short_desc");
                        print "<form onsubmit='return false' action=\"backend.php\" \n\t\t\t\tmethod=\"POST\" id=\"pref_prefs_form\">";
                        $lnum = 0;
                        $active_section = "";
                        while ($line = db_fetch_assoc($result)) {
                            if (in_array($line["pref_name"], $prefs_blacklist)) {
                                continue;
                            }
                            if ($_SESSION["profile"] && in_array($line["pref_name"], $profile_blacklist)) {
                                continue;
                            }
                            if ($active_section != $line["section_name"]) {
                                if ($active_section != "") {
                                    print "</table>";
                                }
                                print "<p><table width=\"100%\" class=\"prefPrefsList\">";
                                $active_section = $line["section_name"];
                                print "<tr><td colspan=\"3\"><h3>" . __($active_section) . "</h3></td></tr>";
                                if ($line["section_id"] == 2) {
                                    print "<tr><td width=\"40%\">" . __("Select theme") . "</td>";
                                    $user_theme = get_pref($link, "_THEME_ID");
                                    $themes = get_all_themes();
                                    print "<td><select name=\"_THEME_ID\">";
                                    print "<option value=''>" . __('Default') . "</option>";
                                    print "<option disabled>--------</option>";
                                    foreach ($themes as $t) {
                                        $base = $t['base'];
                                        $name = $t['name'];
                                        if ($base == $user_theme) {
                                            $selected = "selected=\"1\"";
                                        } else {
                                            $selected = "";
                                        }
                                        print "<option {$selected} value='{$base}'>{$name}</option>";
                                    }
                                    print "</select></td></tr>";
                                }
                                //					print "<tr class=\"title\">
                                //						<td width=\"25%\">Option</td><td>Value</td></tr>";
                                $lnum = 0;
                            }
                            //				$class = ($lnum % 2) ? "even" : "odd";
                            print "<tr>";
                            $type_name = $line["type_name"];
                            $pref_name = $line["pref_name"];
                            $value = $line["value"];
                            $def_value = $line["def_value"];
                            $help_text = $line["help_text"];
                            print "<td width=\"40%\" class=\"prefName\" id=\"{$pref_name}\">" . __($line["short_desc"]);
                            if ($help_text) {
                                print "<div class=\"prefHelp\">" . __($help_text) . "</div>";
                            }
                            print "</td>";
                            print "<td class=\"prefValue\">";
                            if ($pref_name == "DEFAULT_UPDATE_INTERVAL") {
                                global $update_intervals_nodefault;
                                print_select_hash($pref_name, $value, $update_intervals_nodefault);
                            } else {
                                if ($type_name == "bool") {
                                    //					print_select($pref_name, $value, array("true", "false"));
                                    if ($value == "true") {
                                        $value = __("Yes");
                                    } else {
                                        $value = __("No");
                                    }
                                    print_radio($pref_name, $value, __("Yes"), array(__("Yes"), __("No")));
                                } else {
                                    print "<input class=\"editbox\"\n\t\t\t\t\t\tonfocus=\"javascript:disableHotkeys();\" \n\t\t\t\t\t\tonblur=\"javascript:enableHotkeys();\"  \n\t\t\t\t\t\tname=\"{$pref_name}\" value=\"{$value}\">";
                                }
                            }
                            print "</td>";
                            print "</tr>";
                            $lnum++;
                        }
                        print "</table>";
                        print "<input type=\"hidden\" name=\"op\" value=\"pref-prefs\">";
                        print "<p><button onclick=\"return validatePrefsSave()\">" . __('Save configuration') . "</button> ";
                        print "<button onclick=\"return editProfiles()\">" . __('Manage profiles') . "</button> ";
                        print "<button onclick=\"return validatePrefsReset()\">" . __('Reset to defaults') . "</button></p>";
                        print "</form>";
                    }
                }
            }
        }
    }
}
示例#19
0
safe_alter('txp_section', "MODIFY page VARCHAR(255) NOT NULL default '', MODIFY css VARCHAR(255) NOT NULL default ''");
// Save sections correctly in articles.
safe_alter('textpattern', "MODIFY Section VARCHAR(255) NOT NULL default ''");
safe_alter('txp_section', "MODIFY name VARCHAR(255) NOT NULL");
// Plugins can have longer version numbers.
safe_alter('txp_plugin', "MODIFY version VARCHAR(255) NOT NULL DEFAULT '1.0'");
// Translation strings should allow more than 255 characters.
safe_alter('txp_lang', "MODIFY data TEXT");
// Add meta description to articles...
$cols = getThings('describe `' . PFX . 'textpattern`');
if (!in_array('description', $cols)) {
    safe_alter('textpattern', "ADD description VARCHAR(255) NOT NULL DEFAULT '' AFTER Keywords");
}
// ... categories...
$cols = getThings('describe `' . PFX . 'txp_category`');
if (!in_array('description', $cols)) {
    safe_alter('txp_category', "ADD description VARCHAR(255) NOT NULL DEFAULT '' AFTER title");
}
// ... and sections.
$cols = getThings('describe `' . PFX . 'txp_section`');
if (!in_array('description', $cols)) {
    safe_alter('txp_section', "ADD description VARCHAR(255) NOT NULL DEFAULT '' AFTER css");
}
// Remove textpattern.com ping pref.
if (safe_field('name', 'txp_prefs', "name = 'ping_textpattern_com'")) {
    safe_delete('txp_prefs', "name = 'ping_textpattern_com'");
}
// Add default publishing status pref.
if (!get_pref('default_publish_status')) {
    set_pref('default_publish_status', STATUS_LIVE, 'publish', PREF_CORE, 'defaultPublishStatus', 15, PREF_PRIVATE);
}
示例#20
0
function janitor()
{
    global $prefs;
    // update DST setting
    global $auto_dst, $timezone_key, $is_dst;
    if ($auto_dst && $timezone_key) {
        $is_dst = timezone::is_dst(time(), $timezone_key);
        if ($is_dst != $prefs['is_dst']) {
            $prefs['is_dst'] = $is_dst;
            set_pref('is_dst', $is_dst, 'publish', 2);
        }
    }
}
示例#21
0
/**
 * Saves the active language.
 */
function save_language()
{
    global $textarray, $locale;
    extract(psa(array('language')));
    if (safe_field("lang", 'txp_lang', "lang = '" . doSlash($language) . "' LIMIT 1")) {
        $locale = $prefs['locale'] = Txp::get('\\Textpattern\\L10n\\Locale')->getLanguageLocale($language);
        Txp::get('\\Textpattern\\L10n\\Locale')->setLocale(LC_ALL, $language);
        set_pref('locale', $locale);
        set_pref('language', $language);
        $textarray = load_lang($language);
        list_languages(gTxt('preferences_saved'));
        return;
    }
    list_languages(array(gTxt('language_not_installed', array('{name}' => $language)), E_ERROR));
}
示例#22
0
function file_list($message = '')
{
    global $file_base_path, $file_statuses, $file_list_pageby, $txp_user;
    pagetop(gTxt('file'), $message);
    extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method')));
    if ($sort === '') {
        $sort = get_pref('file_sort_column', 'filename');
    }
    if ($dir === '') {
        $dir = get_pref('file_sort_dir', 'asc');
    }
    $dir = $dir == 'desc' ? 'desc' : 'asc';
    if (!is_dir($file_base_path) or !is_writeable($file_base_path)) {
        echo graf(gTxt('file_dir_not_writeable', array('{filedir}' => $file_base_path)), ' id="warning"');
    } elseif (has_privs('file.edit.own')) {
        $existing_files = get_filenames();
        if (count($existing_files) > 0) {
            echo form(eInput('file') . sInput('file_create') . graf(gTxt('existing_file') . sp . selectInput('filename', $existing_files, '', 1) . sp . fInput('submit', '', gTxt('Create'), 'smallerbox')), 'text-align: center;');
        }
        echo file_upload_form(gTxt('upload_file'), 'upload', 'file_insert');
    }
    switch ($sort) {
        case 'id':
            $sort_sql = 'id ' . $dir;
            break;
        case 'description':
            $sort_sql = 'description ' . $dir . ', filename desc';
            break;
        case 'category':
            $sort_sql = 'category ' . $dir . ', filename desc';
            break;
        case 'downloads':
            $sort_sql = 'downloads ' . $dir . ', filename desc';
            break;
        case 'author':
            $sort_sql = 'author ' . $dir . ', id asc';
            break;
        default:
            $sort = 'filename';
            $sort_sql = 'filename ' . $dir;
            break;
    }
    set_pref('file_sort_column', $sort, 'file', 2, '', 0, PREF_PRIVATE);
    set_pref('file_sort_dir', $dir, 'file', 2, '', 0, PREF_PRIVATE);
    $switch_dir = $dir == 'desc' ? 'asc' : 'desc';
    $criteria = 1;
    if ($search_method and $crit) {
        $crit_escaped = doSlash($crit);
        $critsql = array('id' => "ID in ('" . join("','", do_list($crit_escaped)) . "')", 'filename' => "filename like '%{$crit_escaped}%'", 'description' => "description like '%{$crit_escaped}%'", 'category' => "category like '%{$crit_escaped}%'", 'author' => "author like '%{$crit_escaped}%'");
        if (array_key_exists($search_method, $critsql)) {
            $criteria = $critsql[$search_method];
            $limit = 500;
        } else {
            $search_method = '';
            $crit = '';
        }
    } else {
        $search_method = '';
        $crit = '';
    }
    $total = safe_count('txp_file', "{$criteria}");
    if ($total < 1) {
        if ($criteria != 1) {
            echo n . file_search_form($crit, $search_method) . n . graf(gTxt('no_results_found'), ' class="indicator"');
        } else {
            echo n . graf(gTxt('no_files_recorded'), ' class="indicator"');
        }
        return;
    }
    $limit = max($file_list_pageby, 15);
    list($page, $offset, $numPages) = pager($total, $limit, $page);
    echo file_search_form($crit, $search_method);
    $rs = safe_rows_start('*', 'txp_file', "{$criteria} order by {$sort_sql} limit {$offset}, {$limit}");
    if ($rs) {
        $show_authors = !has_single_author('txp_file');
        echo '<form name="longform" method="post" action="index.php" onsubmit="return verify(\'' . gTxt('are_you_sure') . '\')">' . startTable('list') . tr(column_head('ID', 'id', 'file', true, $switch_dir, $crit, $search_method, 'id' == $sort ? $dir : '') . hCell() . column_head('file_name', 'filename', 'file', true, $switch_dir, $crit, $search_method, 'filename' == $sort ? $dir : '') . column_head('description', 'description', 'file', true, $switch_dir, $crit, $search_method, 'description' == $sort ? $dir : '') . column_head('file_category', 'category', 'file', true, $switch_dir, $crit, $search_method, 'category' == $sort ? $dir : '') . hCell(gTxt('tags')) . hCell(gTxt('status')) . hCell(gTxt('condition')) . column_head('downloads', 'downloads', 'file', true, $switch_dir, $crit, $search_method, 'downloads' == $sort ? $dir : '') . ($show_authors ? column_head('author', 'author', 'file', true, $switch_dir, $crit, $search_method, 'author' == $sort ? $dir : '') : '') . hCell());
        while ($a = nextRow($rs)) {
            extract($a);
            $edit_url = '?event=file' . a . 'step=file_edit' . a . 'id=' . $id . a . 'sort=' . $sort . a . 'dir=' . $dir . a . 'page=' . $page . a . 'search_method=' . $search_method . a . 'crit=' . $crit;
            $file_exists = file_exists(build_file_path($file_base_path, $filename));
            $download_link = $file_exists ? '<li>' . make_download_link($id, '', $filename) . '</li>' : '';
            $category = $category ? '<span title="' . htmlspecialchars(fetch_category_title($category, 'file')) . '">' . $category . '</span>' : '';
            $tag_url = '?event=tag' . a . 'tag_name=file_download_link' . a . 'id=' . $id . a . 'description=' . urlencode($description) . a . 'filename=' . urlencode($filename);
            $condition = '<span class="';
            $condition .= $file_exists ? 'ok' : 'not-ok';
            $condition .= '">';
            $condition .= $file_exists ? gTxt('file_status_ok') : gTxt('file_status_missing');
            $condition .= '</span>';
            $can_edit = has_privs('file.edit') || $author == $txp_user && has_privs('file.edit.own');
            echo tr(n . td($id) . td('<ul>' . ($can_edit ? '<li>' . href(gTxt('edit'), $edit_url) . '</li>' : '') . $download_link . '</ul>', 65) . td($can_edit ? href(htmlspecialchars($filename), $edit_url) : htmlspecialchars($filename), 125) . td(htmlspecialchars($description), 150) . td($category, 90) . td(n . '<ul>' . n . t . '<li><a target="_blank" href="' . $tag_url . a . 'type=textile" onclick="popWin(this.href, 400, 250); return false;">Textile</a></li>' . n . t . '<li><a target="_blank" href="' . $tag_url . a . 'type=textpattern" onclick="popWin(this.href, 400, 250); return false;">Textpattern</a></li>' . n . t . '<li><a target="_blank" href="' . $tag_url . a . 'type=xhtml" onclick="popWin(this.href, 400, 250); return false;">XHTML</a></li>' . n . '</ul>', 75) . td(in_array($status, array_keys($file_statuses)) ? $file_statuses[$status] : '<span class="not-ok">' . gTxt('none') . '</span>', 45) . td($condition, 45) . td($downloads == '0' ? gTxt('none') : $downloads, 25) . ($show_authors ? td('<span title="' . htmlspecialchars(get_author_name($author)) . '">' . htmlspecialchars($author) . '</span>') : '') . td($can_edit ? fInput('checkbox', 'selected[]', $id) : '&nbsp;', 10));
        }
        echo tr(tda(select_buttons() . file_multiedit_form($page, $sort, $dir, $crit, $search_method), ' colspan="' . ($show_authors ? '11' : '10') . '" style="text-align: right; border: none;"')) . endTable() . '</form>' . nav_form('file', $page, $numPages, $sort, $dir, $crit, $search_method, $total, $limit) . pageby_form('file', $file_list_pageby);
    }
}
示例#23
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;
}
示例#24
0
function link_list($message = '')
{
    global $event, $step, $link_list_pageby, $txp_user;
    pagetop(gTxt('tab_link'), $message);
    extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method')));
    if ($sort === '') {
        $sort = get_pref('link_sort_column', 'name');
    }
    if ($dir === '') {
        $dir = get_pref('link_sort_dir', 'asc');
    }
    $dir = $dir == 'desc' ? 'desc' : 'asc';
    switch ($sort) {
        case 'id':
            $sort_sql = 'id ' . $dir;
            break;
        case 'description':
            $sort_sql = 'description ' . $dir . ', id asc';
            break;
        case 'url':
            $sort_sql = 'url ' . $dir . ', id asc';
            break;
        case 'category':
            $sort_sql = 'category ' . $dir . ', id asc';
            break;
        case 'date':
            $sort_sql = 'date ' . $dir . ', id asc';
            break;
        case 'author':
            $sort_sql = 'author ' . $dir . ', id asc';
            break;
        default:
            $sort = 'name';
            $sort_sql = 'linksort ' . $dir . ', id asc';
            break;
    }
    set_pref('link_sort_column', $sort, 'link', 2, '', 0, PREF_PRIVATE);
    set_pref('link_sort_dir', $dir, 'link', 2, '', 0, PREF_PRIVATE);
    $switch_dir = $dir == 'desc' ? 'asc' : 'desc';
    $criteria = 1;
    if ($search_method and $crit != '') {
        $verbatim = preg_match('/^"(.*)"$/', $crit, $m);
        $crit_escaped = doSlash($verbatim ? $m[1] : str_replace(array('\\', '%', '_', '\''), array('\\\\', '\\%', '\\_', '\\\''), $crit));
        $critsql = $verbatim ? array('id' => "ID in ('" . join("','", do_list($crit_escaped)) . "')", 'name' => "linkname = '{$crit_escaped}'", 'description' => "description = '{$crit_escaped}'", 'url' => "url = '{$crit_escaped}'", 'category' => "category = '{$crit_escaped}'", 'author' => "author = '{$crit_escaped}'") : array('id' => "ID in ('" . join("','", do_list($crit_escaped)) . "')", 'name' => "linkname like '%{$crit_escaped}%'", 'description' => "description like '%{$crit_escaped}%'", 'url' => "url like '%{$crit_escaped}%'", 'category' => "category like '%{$crit_escaped}%'", 'author' => "author like '%{$crit_escaped}%'");
        if (array_key_exists($search_method, $critsql)) {
            $criteria = $critsql[$search_method];
        } else {
            $search_method = '';
            $crit = '';
        }
    } else {
        $search_method = '';
        $crit = '';
    }
    $criteria .= callback_event('admin_criteria', 'link_list', 0, $criteria);
    $total = getCount('txp_link', $criteria);
    echo '<h1 class="txp-heading">' . gTxt('tab_link') . '</h1>';
    echo '<div id="' . $event . '_control" class="txp-control-panel">';
    if (has_privs('link.edit')) {
        echo graf(sLink('link', 'link_edit', gTxt('add_new_link')), ' class="txp-buttons"');
    }
    if ($total < 1) {
        if ($criteria != 1) {
            echo n . link_search_form($crit, $search_method) . n . graf(gTxt('no_results_found'), ' class="indicator"') . '</div>';
        } else {
            echo n . graf(gTxt('no_links_recorded'), ' class="indicator"') . '</div>';
        }
        return;
    }
    $limit = max($link_list_pageby, 15);
    list($page, $offset, $numPages) = pager($total, $limit, $page);
    echo link_search_form($crit, $search_method) . '</div>';
    $rs = safe_rows_start('*, unix_timestamp(date) as uDate', 'txp_link', "{$criteria} order by {$sort_sql} limit {$offset}, {$limit}");
    if ($rs) {
        $show_authors = !has_single_author('txp_link');
        echo n . '<div id="' . $event . '_container" class="txp-container">';
        echo n . n . '<form action="index.php" id="links_form" class="multi_edit_form" method="post" name="longform">', n . '<div class="txp-listtables">' . n . startTable('', '', 'txp-list') . n . '<thead>' . n . tr(n . hCell(fInput('checkbox', 'select_all', 0, '', '', '', '', '', 'select_all'), '', ' title="' . gTxt('toggle_all_selected') . '" class="multi-edit"') . n . column_head('ID', 'id', 'link', true, $switch_dir, $crit, $search_method, ('id' == $sort ? "{$dir} " : '') . 'id') . n . column_head('link_name', 'name', 'link', true, $switch_dir, $crit, $search_method, ('name' == $sort ? "{$dir} " : '') . 'name') . n . column_head('description', 'description', 'link', true, $switch_dir, $crit, $search_method, ('description' == $sort ? "{$dir} " : '') . 'links_detail description') . n . column_head('link_category', 'category', 'link', true, $switch_dir, $crit, $search_method, ('category' == $sort ? "{$dir} " : '') . 'category') . n . column_head('url', 'url', 'link', true, $switch_dir, $crit, $search_method, ('url' == $sort ? "{$dir} " : '') . 'url') . n . column_head('date', 'date', 'link', true, $switch_dir, $crit, $search_method, ('date' == $sort ? "{$dir} " : '') . 'links_detail date created') . ($show_authors ? n . column_head('author', 'author', 'link', true, $switch_dir, $crit, $search_method, ('author' == $sort ? "{$dir} " : '') . 'author') : '')) . n . '</thead>';
        echo '<tbody>';
        $validator = new Validator();
        while ($a = nextRow($rs)) {
            extract($a, EXTR_PREFIX_ALL, 'link');
            $edit_url = '?event=link' . a . 'step=link_edit' . a . 'id=' . $link_id . a . 'sort=' . $sort . a . 'dir=' . $dir . a . 'page=' . $page . a . 'search_method=' . $search_method . a . 'crit=' . $crit;
            $validator->setConstraints(array(new CategoryConstraint($link_category, array('type' => 'link'))));
            $vc = $validator->validate() ? '' : ' error';
            $can_edit = has_privs('link.edit') || $link_author == $txp_user && has_privs('link.edit.own');
            $view_url = txpspecialchars($link_url);
            echo tr(n . td(fInput('checkbox', 'selected[]', $link_id), '', 'multi-edit') . n . td($can_edit ? href($link_id, $edit_url, ' title="' . gTxt('edit') . '"') : $link_id, '', 'id') . td($can_edit ? href(txpspecialchars($link_linkname), $edit_url, ' title="' . gTxt('edit') . '"') : txpspecialchars($link_linkname), '', 'name') . td(txpspecialchars($link_description), '', 'links_detail description') . td('<span title="' . txpspecialchars(fetch_category_title($link_category, 'link')) . '">' . $link_category . '</span>', '', 'category' . $vc) . td('<a rel="external" target="_blank" href="' . $view_url . '">' . $view_url . '</a>', '', 'url') . td(gTime($link_uDate), '', 'links_detail date created') . ($show_authors ? td('<span title="' . txpspecialchars(get_author_name($link_author)) . '">' . txpspecialchars($link_author) . '</span>', '', 'author') : ''));
        }
        echo '</tbody>', n, endTable(), n, '</div>', n, link_multiedit_form($page, $sort, $dir, $crit, $search_method), n, tInput(), n, '</form>', n, graf(toggle_box('links_detail'), ' class="detail-toggle"'), n, '<div id="' . $event . '_navigation" class="txp-navigation">', n, nav_form('link', $page, $numPages, $sort, $dir, $crit, $search_method, $total, $limit), n, pageby_form('link', $link_list_pageby), n, '</div>', n, '</div>';
    }
}
示例#25
0
 function togglehiddenfeedcats()
 {
     set_pref($this->link, '_PREFS_SHOW_EMPTY_CATS', get_pref($this->link, '_PREFS_SHOW_EMPTY_CATS') ? 'false' : 'true');
 }
示例#26
0
function janitor()
{
    global $prefs;
    // update DST setting
    global $auto_dst, $timezone_key, $is_dst;
    if ($auto_dst && $timezone_key) {
        $is_dst = timezone::is_dst(time(), $timezone_key);
        if ($is_dst != $prefs['is_dst']) {
            $prefs['is_dst'] = $is_dst;
            set_pref('is_dst', $is_dst, 'publish', 2);
        }
    }
    // deprecation nags
    if (AJAXALLY_CHALLENGED) {
        trigger_error(gTxt('deprecated_configuration', array('{name}' => 'AJAXALLY_CHALLENGED')), E_USER_NOTICE);
    }
}
示例#27
0
function mobile_set_pref($link, $id, $value)
{
    //$_SESSION["mobile-prefs"][$id] = $value;
    return set_pref($link, "_MOBILE_{$id}", $value);
}
示例#28
0
 function based_on($name)
 {
     global $production_status;
     $theme = theme::factory($name);
     if (!$theme) {
         set_pref('theme_name', 'classic');
         if ($production_status === 'debug') {
             echo gTxt('cannot_instantiate_theme', array('{name}' => $name, '{class}' => "{$name}_theme", '{path}' => theme::path($name)));
         }
         return false;
     }
     return true;
 }
示例#29
0
 private function opml_import_preference($doc, $node, $owner_uid)
 {
     $attrs = $node->attributes;
     $pref_name = db_escape_string($attrs->getNamedItem('pref-name')->nodeValue);
     if ($pref_name) {
         $pref_value = db_escape_string($attrs->getNamedItem('value')->nodeValue);
         $this->opml_notice(T_sprintf("Setting preference key %s to %s", $pref_name, $pref_value));
         set_pref($this->link, $pref_name, $pref_value);
     }
 }
示例#30
0
/**
 * The main author list.
 *
 * @param string|array $message The activity message
 */
function author_list($message = '')
{
    global $txp_user, $author_list_pageby;
    pagetop(gTxt('tab_site_admin'), $message);
    if (is_disabled('mail')) {
        echo graf(span(null, array('class' => 'ui-icon ui-icon-alert')) . ' ' . gTxt('warn_mail_unavailable'), array('class' => 'alert-block warning'));
    }
    echo hed(gTxt('tab_site_admin'), 1, array('class' => 'txp-heading'));
    echo n . '<div id="users_control" class="txp-control-panel">';
    $buttons = array();
    // Change password button.
    $buttons[] = sLink('admin', 'new_pass_form', gTxt('change_password'));
    if (!has_privs('admin.edit')) {
        // Change email address button.
        $buttons[] = sLink('admin', 'change_email_form', gTxt('change_email_address'));
    } else {
        // New author button.
        $buttons[] = sLink('admin', 'author_edit', gTxt('add_new_author'));
    }
    echo graf(join(n, $buttons), array('class' => 'txp-buttons'));
    // User list.
    if (has_privs('admin.list')) {
        extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method')));
        if ($sort === '') {
            $sort = get_pref('admin_sort_column', 'name');
        }
        if ($dir === '') {
            $dir = get_pref('admin_sort_dir', 'asc');
        }
        $dir = $dir == 'desc' ? 'desc' : 'asc';
        if (!in_array($sort, array('name', 'RealName', 'email', 'privs', 'last_login'))) {
            $sort = 'name';
        }
        $sort_sql = $sort . ' ' . $dir;
        set_pref('admin_sort_column', $sort, 'admin', 2, '', 0, PREF_PRIVATE);
        set_pref('admin_sort_dir', $dir, 'admin', 2, '', 0, PREF_PRIVATE);
        $switch_dir = $dir == 'desc' ? 'asc' : 'desc';
        $criteria = 1;
        if ($search_method and $crit != '') {
            $verbatim = preg_match('/^"(.*)"$/', $crit, $m);
            $crit_escaped = $verbatim ? doSlash($m[1]) : doLike($crit);
            $critsql = $verbatim ? array('id' => "user_id in ('" . join("','", do_list($crit_escaped)) . "')", 'login' => "name = '{$crit_escaped}'", 'real_name' => "RealName = '{$crit_escaped}'", 'email' => "email = '{$crit_escaped}'", 'privs' => "convert(privs, char) in ('" . join("','", do_list($crit_escaped)) . "')") : array('id' => "user_id in ('" . join("','", do_list($crit_escaped)) . "')", 'login' => "name like '%{$crit_escaped}%'", 'real_name' => "RealName like '%{$crit_escaped}%'", 'email' => "email like '%{$crit_escaped}%'", 'privs' => "convert(privs, char) in ('" . join("','", do_list($crit_escaped)) . "')");
            if (array_key_exists($search_method, $critsql)) {
                $criteria = $critsql[$search_method];
            } else {
                $search_method = '';
                $crit = '';
            }
        } else {
            $search_method = '';
            $crit = '';
        }
        $criteria .= callback_event('admin_criteria', 'author_list', 0, $criteria);
        $total = getCount('txp_users', $criteria);
        if ($total < 1) {
            if ($criteria != 1) {
                echo n . author_search_form($crit, $search_method) . graf(gTxt('no_results_found'), ' class="indicator"') . '</div>';
            }
            return;
        }
        $limit = max($author_list_pageby, 15);
        list($page, $offset, $numPages) = pager($total, $limit, $page);
        $use_multi_edit = has_privs('admin.edit') && safe_count('txp_users', '1=1') > 1;
        echo author_search_form($crit, $search_method) . '</div>';
        $rs = safe_rows_start('*, unix_timestamp(last_access) as last_login', 'txp_users', "{$criteria} order by {$sort_sql} limit {$offset}, {$limit}");
        if ($rs) {
            echo n . tag_start('div', array('id' => 'users_container', 'class' => 'txp-container')) . n . tag_start('form', array('action' => 'index.php', 'id' => 'users_form', 'class' => 'multi_edit_form', 'method' => 'post', 'name' => 'longform')) . n . tag_start('div', array('class' => 'txp-listtables')) . n . tag_start('table', array('class' => 'txp-list')) . n . tag_start('thead') . tr(($use_multi_edit ? hCell(fInput('checkbox', 'select_all', 0, '', '', '', '', '', 'select_all'), '', ' scope="col" title="' . gTxt('toggle_all_selected') . '" class="txp-list-col-multi-edit"') : hCell('', '', ' scope="col" class="txp-list-col-multi-edit"')) . column_head('login_name', 'name', 'admin', true, $switch_dir, '', '', ('name' == $sort ? "{$dir} " : '') . 'txp-list-col-login-name name') . column_head('real_name', 'RealName', 'admin', true, $switch_dir, '', '', ('RealName' == $sort ? "{$dir} " : '') . 'txp-list-col-real-name name') . column_head('email', 'email', 'admin', true, $switch_dir, '', '', ('email' == $sort ? "{$dir} " : '') . 'txp-list-col-email') . column_head('privileges', 'privs', 'admin', true, $switch_dir, '', '', ('privs' == $sort ? "{$dir} " : '') . 'txp-list-col-privs') . column_head('last_login', 'last_login', 'admin', true, $switch_dir, '', '', ('last_login' == $sort ? "{$dir} " : '') . 'txp-list-col-last-login date')) . n . tag_end('thead') . n . tag_start('tbody');
            while ($a = nextRow($rs)) {
                extract(doSpecial($a));
                echo tr(td((has_privs('admin.edit') and $txp_user != $a['name']) ? fInput('checkbox', 'selected[]', $a['name'], 'checkbox') : '', '', 'txp-list-col-multi-edit') . hCell(has_privs('admin.edit') ? eLink('admin', 'author_edit', 'user_id', $user_id, $name) : $name, '', ' scope="row" class="txp-list-col-login-name name"') . td($RealName, '', 'txp-list-col-real-name name') . td(href($email, 'mailto:' . $email), '', 'txp-list-col-email') . td(get_priv_level($privs), '', 'txp-list-col-privs') . td($last_login ? safe_strftime('%b&#160;%Y', $last_login) : '', '', 'txp-list-col-last-login date'));
            }
            echo n . tag_end('tbody') . n . tag_end('table') . n . tag_end('div') . ($use_multi_edit ? author_multiedit_form($page, $sort, $dir, $crit, $search_method) : '') . tInput() . n . tag_end('form') . n . tag_start('div', array('id' => 'users_navigation', 'class' => 'txp-navigation')) . pageby_form('admin', $author_list_pageby) . nav_form('admin', $page, $numPages, $sort, $dir, $crit, $search_method) . n . tag_end('div') . n . tag_end('div');
        }
    } else {
        echo n . tag_end('div');
    }
}