Ejemplo n.º 1
0
function section_list($message = '')
{
    pagetop(gTxt('sections'), $message);
    global $url_mode, $txpac, $wlink;
    $out[] = tr(tdcs(strong(gTxt('section_head')) . popHelp('section_category'), 3));
    $out[] = tr(tdcs(form(fInput('text', 'name', '', 'edit', '', '', 10) . fInput('submit', '', gTxt('Create'), 'smallerbox') . eInput('section') . sInput('section_create')), 3));
    $pageslist = safe_column("name", "txp_page", "1");
    $styleslist = safe_column("name", "txp_css", "1");
    $rs = safe_rows("*", "txp_section", "name!='' order by name");
    if ($rs) {
        foreach ($rs as $a) {
            extract($a);
            if ($name == 'default') {
                continue;
            }
            if ($url_mode) {
                $wlink = !check_sections($name) ? sp . wLink('section', 'missing_section_file', 'name', $name) : '';
            }
            $deletelink = dLink('section', 'section_delete', 'name', $name, '', 'type', 'section');
            $form = startTable('edit') . stackRows(fLabelCell(gTxt('section_name') . ':') . fInputCell('name', $name, 1, 20), fLabelCell(gTxt('uses_page') . ':') . td(selectInput('page', $pageslist, $page) . popHelp('section_uses_page'), '', 'noline'), fLabelCell(gTxt('uses_style') . ':') . td(selectInput('css', $styleslist, $css) . popHelp('section_uses_css'), '', 'noline'), fLabelCell(gTxt('selected_by_default') . '?') . td(yesnoradio('is_default', $is_default) . popHelp('section_is_default'), '', 'noline'), fLabelCell(gTxt('on_front_page') . '?') . td(yesnoradio('on_frontpage', $on_frontpage) . popHelp('section_on_frontpage'), '', 'noline'), fLabelCell(gTxt('syndicate') . '?') . td(yesnoradio('in_rss', $in_rss) . popHelp('section_syndicate'), '', 'noline'), fLabelCell(gTxt('include_in_search') . '?') . td(yesnoradio('searchable', $searchable) . popHelp('section_searchable'), '', 'noline'), tda(fInput('submit', '', gTxt('save_button'), 'smallerbox'), ' colspan="2" style="border:0"')) . endTable() . eInput('section') . sInput('section_save') . hInput('old_name', $name);
            $form = form($form);
            $out[] = tr(td($name . $wlink) . td($form) . td($deletelink));
        }
    }
    echo startTable('list') . join('', $out) . endTable();
}
Ejemplo n.º 2
0
    /**
     * Weave the current template and show it ready to paste.
     */
    static function export()
    {
        $f = file_get_contents(txpath . self::$template);
        foreach (self::$what as $table => $columns) {
            $tick = '`';
            $cols = empty($columns) ? '*' : $tick . join('`,`', doSlash($columns)) . $tick;
            $rs = safe_rows($cols, $table, (empty($columns) ? '1=1' : $columns[0] . ' not like \'%.min%\'') . (empty($columns) ? '' : ' ORDER BY `' . $columns[0] . '`'));
            $rows = array();
            foreach ($rs as $a) {
                // Enforce *nix new-lines
                $a = str_replace("\r\n", "\n", $a);
                // Literal backslash into corresponding MySQL literal
                foreach ($a as &$v) {
                    $v = addcslashes(addcslashes($v, '\\'), '\\');
                }
                $a = "'" . join("', '", doSlash($a)) . "'";
                $rows[] = self::$where . ' = "INSERT INTO `".PFX."' . $table . '`(' . $cols . ') VALUES(' . $a . ')";';
            }
            $f = preg_replace("#(// sql:{$table}).*(// /sql:{$table})#s", '$1' . n . join(n, $rows) . n . '$2', $f);
        }
        echo text_area('code', 600, '', $f, 'code');
        echo script_js(<<<EOS
\t\t\$('#code').focus(function() {
\t\t\tthis.select();
\t\t});
EOS
);
    }
Ejemplo n.º 3
0
/**
 * Gets comments as an array from the given article.
 *
 * @param  int $id The article ID
 * @return array|null An array of comments, or NULL on error
 * @example
 * if ($comments = fetchComments(12))
 * {
 *     print_r($comments);
 * }
 */
function fetchComments($id)
{
    $rs = safe_rows("*, UNIX_TIMESTAMP(posted) AS time", 'txp_discuss', "parentid = " . intval($id) . " AND visible = " . VISIBLE . " ORDER BY posted ASC");
    if ($rs) {
        return $rs;
    }
}
Ejemplo n.º 4
0
function fetchComments($id)
{
    $rs = safe_rows("*, unix_timestamp(posted) as time", "txp_discuss", 'parentid=' . intval($id) . ' and visible=' . VISIBLE . ' order by posted asc');
    if ($rs) {
        return $rs;
    }
}
Ejemplo n.º 5
0
function fetchComments($id)
{
    $rs = safe_rows("*, unix_timestamp(posted) as time", "txp_discuss", "parentid='{$id}' and visible='1' order by posted asc");
    if ($rs) {
        return $rs;
    }
}
Ejemplo n.º 6
0
 function export($dir = '')
 {
     if (!$this->checkdir($dir, TEMPLATES_EXPORT)) {
         return;
     }
     foreach ($this->exportTypes as $type => $config) {
         print "\n                <h1>Exporting " . $config['nice_name'] . "</h1>\n                <ul class='results'>\n            ";
         $rows = safe_rows($config['fields'], $config['table'], '1=1');
         foreach ($rows as $row) {
             $filename = sprintf("%s/%s/%s/%s%s", $this->_config['full_base_path'], $dir, $config['subdir'], $row['name'] . (isset($row['type']) ? "." . $row['type'] : ""), $config['ext']);
             $nicefilename = sprintf(".../%s/%s/%s%s", $dir, $config['subdir'], $row['name'] . (isset($row['type']) ? "." . $row['type'] : ""), $config['ext']);
             if (isset($row['css'])) {
                 $row['css'] = base64_decode($row['css']);
             }
             $f = @fopen($filename, "w+");
             if ($f) {
                 fwrite($f, $row[$config['data']]);
                 fclose($f);
                 print "\n                    <li><span class='success'>Successfully exported</span> " . $config['nice_name'] . " '" . $row['name'] . "' to '" . $nicefilename . "'</li>\n                    ";
             } else {
                 print "\n                    <li><span class='failure'>Failure exporting</span> " . $config['nice_name'] . " '" . $row['name'] . "' to '" . $nicefilename . "'</li>\n                    ";
             }
         }
         print "\n                </ul>\n            ";
     }
 }
Ejemplo n.º 7
0
function list_list($message = "", $post = '')
{
    extract(get_prefs());
    $lvars = array("page", "sort", "dir", "crit", 'method');
    extract(gpsa($lvars));
    global $statuses, $step;
    pagetop("Textpattern", $message);
    $total = getCount('textpattern', "1");
    $limit = $article_list_pageby ? $article_list_pageby : 25;
    $numPages = ceil($total / $limit);
    $page = !$page ? 1 : $page;
    $offset = ($page - 1) * $limit;
    if (!$sort) {
        $sort = "Posted";
    }
    if (!$dir) {
        $dir = "desc";
    }
    if ($dir == "desc") {
        $linkdir = "asc";
    } else {
        $linkdir = "desc";
    }
    if ($crit) {
        $critsql = array('title_body' => "Title rlike '{$crit}' or Body rlike '{$crit}'", 'author' => "AuthorID rlike '{$crit}'", 'categories' => "Category1 rlike '{$crit}' or Category2 rlike '{$crit}'", 'section' => "Section rlike '{$crit}'", 'status' => "Status rlike '{$crit}'");
        $criteria = $critsql[$method];
        $limit = 500;
    } else {
        $criteria = 1;
    }
    $rs = safe_rows("*, unix_timestamp(Posted) as uPosted", "textpattern", "{$criteria} order by {$sort} {$dir} limit {$offset},{$limit}");
    echo !$crit ? list_nav_form($page, $numPages, $sort, $dir) : '', list_searching_form($crit, $method);
    if ($rs) {
        echo '<form action="index.php" method="post" onsubmit="return verify(\'' . gTxt('are_you_sure') . '\')">', startTable('list'), '<tr>', column_head('posted', 'Posted', 'list', 1, $linkdir), column_head('title', 'Title', 'list', 1, $linkdir), $use_sections ? column_head('section', 'Section', 'list', 1, $linkdir) : '', $use_categories ? column_head('category1', 'Category1', 'list', 1, $linkdir) . column_head('category2', 'Category2', 'list', 1, $linkdir) : '', hCell(gTxt('Author')), column_head(gTxt('status'), 'Status', 'list', 1, $linkdir), td(), '</tr>';
        foreach ($rs as $a) {
            extract($a);
            if ($use_categories == 1) {
                $cat1 = $Category1;
                $cat2 = $Category2;
            }
            $stat = !empty($Status) ? $statuses[$Status] : '';
            if ($use_sections == 1) {
                $sect = $Section;
            }
            $adate = date("d M y", $uPosted + $timeoffset);
            $alink = eLink('article', 'edit', 'ID', $ID, $adate);
            $tlink = eLink('article', 'edit', 'ID', $ID, $Title);
            $modbox = fInput('checkbox', 'selected[]', $ID);
            echo "<tr>" . n, td($alink), td($tlink, 200), $use_sections ? td($sect, 75) : '', $use_categories ? td($cat1, 75) . td($cat2, 75) : '', td($AuthorID), td($stat, 45), td($modbox), '</tr>' . n;
        }
        echo tr(tda(list_multiedit_form(), ' colspan="8" style="text-align:right;border:0px"'));
        echo "</table></form>";
        echo pageby_form('list', $article_list_pageby);
        unset($sort);
    }
}
Ejemplo n.º 8
0
function page_list($current)
{
    $rs = safe_rows("name", "txp_page", "name != '' order by name");
    foreach ($rs as $a) {
        extract($a);
        $dlink = $name != 'default' ? dLink('page', 'page_delete', 'name', $name) : '';
        $link = '<a href="?event=page' . a . 'name=' . $name . '">' . $name . '</a>';
        $out[] = $current == $name ? tr(td($name) . td($dlink)) : tr(td($link) . td($dlink));
    }
    return startTable('list') . join(n, $out) . endTable();
}
function oui_prefs_custom_field_list($name, $val)
{
    $custom_fields = safe_rows("name, val", 'txp_prefs', "name LIKE 'custom_%_set' AND val<>'' ORDER BY name");
    if ($custom_fields) {
        $vals = array();
        foreach ($custom_fields as $row) {
            $vals[$row['val']] = $row['val'];
        }
        return selectInput($name, $vals, $val, 'true');
    }
    return gtxt('no_custom_fields_recorded');
}
Ejemplo n.º 10
0
function oui_prefs_style_list($name, $val)
{
    $styles = safe_rows("name", 'txp_css', "name != 'default' ORDER BY name");
    if ($styles) {
        $vals = array();
        foreach ($styles as $row) {
            $vals[$row['name']] = $row['name'];
        }
        return selectInput($name, $vals, $val, 'true');
    }
    return gtxt('no_styles_recorded');
}
function oui_prefs_section_list($name, $val)
{
    $sections = safe_rows("name, title", 'txp_section', "name != 'default' ORDER BY title, name");
    if ($sections) {
        $vals = array();
        foreach ($sections as $row) {
            $vals[$row['name']] = $row['title'];
        }
        return selectInput($name, $vals, $val, 'true');
    }
    return gtxt('no_sections_available');
}
Ejemplo n.º 12
0
function oui_prefs_file_list($name, $val)
{
    $files = safe_rows("name, id", 'txp_image', "name != 'default' ORDER BY id, name");
    if ($files) {
        $vals = array();
        foreach ($files as $row) {
            $vals[$row['id']] = $row['name'];
        }
        return selectInput($name, $vals, $val, 'true');
    }
    return gtxt('no_images_recorded');
}
function oui_prefs_article_list($name, $val)
{
    $articles = safe_rows("title, id", 'textpattern', "title != 'default' ORDER BY id, title");
    if ($articles) {
        $vals = array();
        foreach ($articles as $row) {
            $vals[$row['id']] = $row['title'];
        }
        return selectInput($name, $vals, $val, 'true');
    }
    return gtxt('no_articles_recorded');
}
Ejemplo n.º 14
0
 function sed_plugin_list($atts)
 {
     extract(lAtts(array('debug' => 0, 'type' => '', 'link_name' => 1, 'show_author' => 1, 'link_author' => 0, 'show_description' => 1, 'descriptionwrap' => 'p', 'descriptionclass' => 'plugin-description', 'show_version' => 1, 'versionwrap' => 'span', 'versionclass' => 'plugin-version', 'hide_disabled' => 1, 'sort_dir' => 'asc', 'sort_field' => 'name', 'wraptag' => 'ul', 'wrapclass' => 'plugin-list', 'break' => 'li', 'breakclass' => 'plugin-item', 'show_count' => 0, 'exclusions' => ''), $atts));
     $exclusions = explode(',', $exclusions);
     #
     #	Create out plugin search criteria...
     #
     $where = '';
     $w = array();
     if ('' !== $type) {
         $type = 'type=\'' . doSlash($type) . '\'';
         $w[] = $type;
     }
     if ($hide_disabled) {
         $w[] = 'status=\'1\'';
     }
     $where = join(' and ', $w);
     if (empty($where)) {
         $where = '1=1';
     }
     $sort = '';
     if ('' !== $sort_field) {
         $sort = ' order by `' . doSlash($sort_field) . '` ' . doSlash($sort_dir);
     }
     #
     #	Grab the actual data...
     #
     $plugins = safe_rows('name,author,author_uri,version,description,status,type', 'txp_plugin', '(' . $where . ')' . $sort, $debug);
     #
     #	Generate the XHTML results...
     #
     if ($plugins) {
         foreach ($plugins as $plugin) {
             if (in_array($plugin['name'], $exclusions)) {
                 continue;
             }
             $item = tag($plugin['name'], 'span', ' class="plugin-name" ');
             if ($link_name) {
                 $item = tag($item, 'a', ' href="' . $plugin['author_uri'] . '" rel="nofollow" ');
             }
             if ($show_version) {
                 $item .= tag(' v' . $plugin['version'], $versionwrap, ' class="' . $versionclass . '" ');
             }
             if ($show_description) {
                 $item .= tag($plugin['description'], $descriptionwrap, ' class="' . $descriptionclass . '" ');
             }
             $o[] = tag($item, $break, ' class="' . $breakclass . '" ');
         }
     }
     $o = n . join(n, $o);
     return n . tag($o, $wraptag, ' class="' . $wrapclass . '" ') . n . n;
 }
Ejemplo n.º 15
0
function list_plugins($message = '')
{
    pagetop(gTxt('edit_plugins'), $message);
    echo startTable('list') . tr(tda(plugin_form() . plugin_form_old(), ' colspan="5" style="border:0;height:50px"')) . assHead('plugin', 'author', 'version', 'description', 'active', '');
    $rs = safe_rows("*", "txp_plugin", "1 order by name");
    foreach ($rs as $a) {
        extract($a);
        // nice to have eval() do a syntax check on the plugin here
        echo tr(td(eLink('plugin', 'edit', 'name', $name, $name), 150) . td('<a href="' . $author_uri . '">' . $author . '</a>', 100) . td($version, 10) . td($description, 260) . td(status_link($status, $name, yes_no($status)), 30) . td(dLink('plugin', 'delete', 'name', $name), 30));
        unset($name, $page, $deletelink);
    }
    echo endTable();
}
Ejemplo n.º 16
0
function show_mentions()
{
    global $id;
    if ($id) {
        $rs = safe_rows("*", "txp_log_mention", "article_id='{$id}'");
        if ($rs) {
            foreach ($rs as $a) {
                extract($a);
                $out[] = '<a href="http://' . $refpage . '" title="' . $excerpt . '">' . $reftitle . '</a>';
            }
            return hed(gTxt('mentions'), 3) . graf(join(br, $out));
        }
    }
}
Ejemplo n.º 17
0
function css_list($name)
{
    $out[] = startTable('list', 'left');
    $rs = safe_rows("name as cssname", "txp_css", "1");
    if ($rs) {
        foreach ($rs as $a) {
            extract($a);
            $namelink = $name != $cssname ? eLink('css', '', 'name', $cssname, $cssname) : $cssname;
            $deletelink = $cssname != 'default' ? dLink('css', 'css_delete', 'name', $cssname) : '';
            $out[] = tr(td($namelink) . td($deletelink));
        }
        $out[] = endTable();
        return join('', $out);
    }
}
Ejemplo n.º 18
0
function element_list($event, $step)
{
    $message = '';
    pagetop(gTxt('element'), $message);
    echo startTable('list') . assHead('element', 'version', 'date', 'active', 'checksum');
    $rs = safe_rows('*', 'txp_element', '1=1');
    foreach ($rs as $row) {
        extract($row);
        if ($hash) {
            $checksum = md5_file(txpath . '/elements/' . $name . '.php') == $hash ? gTxt('ok') : gTxt('modified');
        } else {
            $checksum = gTxt('unknown');
        }
        echo tr(td($name) . td($version) . td($modified) . td($status ? gTxt('yes') : gTxt('no')) . td($checksum));
    }
    echo endTable();
}
Ejemplo n.º 19
0
/**
 * Performs searching and returns results.
 *
 * This is now performed by doArticles().
 *
 * @param      string $q
 * @deprecated in 4.0.4
 * @see        doArticles()
 */
function search($q)
{
    global $prefs;
    $url = $prefs['siteurl'];
    extract($prefs);
    $s_filter = filterSearch();
    $form = fetch('form', 'txp_form', 'name', 'search_results');
    // Lose this eventually - only used if search_results form is missing.
    $form = !$form ? legacy_form() : $form;
    $rs = safe_rows("*, ID AS thisid, UNIX_TIMESTAMP(Posted) AS posted, Title AS title,\n        MATCH (Title,Body) AGAINST ('{$q}') AS score", 'textpattern', "(Title RLIKE '{$q}' OR Body RLIKE '{$q}') {$s_filter}\n        AND Status = 4 AND Posted <= " . now('posted') . " ORDER BY score DESC LIMIT 40");
    if ($rs) {
        $result_rows = count($rs);
        $text = $result_rows == 1 ? gTxt('article_found') : gTxt('articles_found');
    } else {
        $result_rows = 0;
        $text = gTxt('articles_found');
    }
    $results[] = graf($result_rows . ' ' . $text);
    if ($result_rows > 0) {
        foreach ($rs as $a) {
            extract($a);
            $result_date = safe_strftime($archive_dateformat, $posted);
            $uTitle = $url_title ? $url_title : stripSpace($Title);
            $hurl = permlinkurl($a);
            $result_url = '<a href="' . $hurl . '">' . $hurl . '</a>';
            $result_title = '<a href="' . $hurl . '">' . $Title . '</a>';
            $result = preg_replace("/>\\s*</", "> <", $Body_html);
            preg_match_all("/\\s.{1,50}" . preg_quote($q) . ".{1,50}\\s/i", $result, $concat);
            $concat = join(" ... ", $concat[0]);
            $concat = strip_tags($concat);
            $concat = preg_replace('/^[^>]+>/U', "", $concat);
            $concat = preg_replace("/({$q})/i", "<strong>\$1</strong>", $concat);
            $result_excerpt = $concat ? "... " . $concat . " ..." : '';
            $glob['search_result_title'] = $result_title;
            $glob['search_result_excerpt'] = $result_excerpt;
            $glob['search_result_url'] = $result_url;
            $glob['search_result_date'] = $result_date;
            $GLOBALS['this_result'] = $glob;
            $thisresult = $form;
            $results[] = parse($thisresult);
        }
    }
    return is_array($results) ? join('', $results) : '';
}
Ejemplo n.º 20
0
function search($q)
{
    global $prefs;
    $url = $prefs['siteurl'];
    extract($prefs);
    $s_filter = filterSearch();
    $form = fetch('form', 'txp_form', 'name', 'search_results');
    // lose this eventually - only used if search_results form is missing
    $form = !$form ? legacy_form() : $form;
    $rs = safe_rows("*, ID as thisid, unix_timestamp(Posted) as posted, Title as title,\n\t\t\tmatch (Title,Body) against ('{$q}') as score", "textpattern", "(Title rlike '{$q}' or Body rlike '{$q}') {$s_filter}\n\t\t\tand Status = 4 and Posted <=now() order by score desc limit 40");
    if ($rs) {
        $result_rows = count($rs);
        $text = $result_rows == 1 ? gTxt('article_found') : gTxt('articles_found');
    } else {
        $result_rows = 0;
        $text = gTxt('articles_found');
    }
    $results[] = graf($result_rows . ' ' . $text);
    if ($result_rows > 0) {
        foreach ($rs as $a) {
            extract($a);
            $result_date = safe_strftime($archive_dateformat, $posted);
            $uTitle = $url_title ? $url_title : stripSpace($Title);
            $hurl = permlinkurl($a);
            $result_url = '<a href="' . $hurl . '">' . $hurl . '</a>';
            $result_title = '<a href="' . $hurl . '">' . $Title . '</a>';
            $result = preg_replace("/>\\s*</", "> <", $Body_html);
            preg_match_all("/\\s.{1,50}" . preg_quote($q) . ".{1,50}\\s/i", $result, $concat);
            $concat = join(" ... ", $concat[0]);
            $concat = strip_tags($concat);
            $concat = preg_replace('/^[^>]+>/U', "", $concat);
            $concat = preg_replace("/({$q})/i", "<strong>\$1</strong>", $concat);
            $result_excerpt = $concat ? "... " . $concat . " ..." : '';
            $glob['search_result_title'] = $result_title;
            $glob['search_result_excerpt'] = $result_excerpt;
            $glob['search_result_url'] = $result_url;
            $glob['search_result_date'] = $result_date;
            $GLOBALS['this_result'] = $glob;
            $thisresult = $form;
            $results[] = parse($thisresult);
        }
    }
    return is_array($results) ? join('', $results) : '';
}
Ejemplo n.º 21
0
function search($q)
{
    global $prefs;
    $url = $prefs['siteurl'];
    extract($prefs);
    $s_filter = filterSearch();
    $form = fetch('form', 'txp_form', 'name', 'search_results');
    // lose this eventually - only used if search_results form is missing
    $form = !$form ? legacy_form() : $form;
    $rs = safe_rows("ID, Title, Body_html, Section, unix_timestamp(Posted) as uPosted, \n\t\t\tmatch (Title,Body) against ('{$q}') as score", "textpattern", "Title rlike '{$q}' or Body rlike '{$q}' {$s_filter}\n\t\t\tand Status = 4 and Posted <=now() order by score desc limit 40");
    if ($rs) {
        $result_rows = count($rs);
        $text = $result_rows == 1 ? gTxt('article_found') : gTxt('articles_found');
    } else {
        $result_rows = 0;
        $text = gTxt('articles_found');
    }
    $results[] = graf($result_rows . ' ' . $text);
    if ($result_rows > 0) {
        foreach ($rs as $a) {
            extract($a);
            $result_date = date("j M Y", $uPosted);
            $hurl = $url_mode ? $siteurl . $path_from_root . $Section . '/' . $ID . '/' . stripSpace($Title) : $siteurl . $path_from_root . 'index.php?id=' . $ID;
            $result_url = '<a href="http://' . $hurl . '">' . $hurl . '</a>';
            $result_title = '<a href="http://' . $hurl . '">' . $Title . '</a>';
            $result = preg_replace("/>\\s*</", "> <", $Body_html);
            preg_match_all("/\\s.{0,50}" . $q . ".{0,50}\\s/i", $result, $concat);
            $concat = implode(" ... ", $concat[0]);
            $concat = strip_tags($concat);
            $concat = preg_replace('/^[^>]+>/U', "", $concat);
            $concat = preg_replace("/({$q})/i", "<strong>\$1</strong>", $concat);
            $result_excerpt = $concat ? "... " . $concat . " ..." : '';
            $glob['search_result_title'] = $result_title;
            $glob['search_result_excerpt'] = $result_excerpt;
            $glob['search_result_url'] = $result_url;
            $glob['search_result_date'] = $result_date;
            $GLOBALS['this_result'] = $glob;
            $thisresult = $form;
            $results[] = parse($thisresult);
        }
    }
    return is_array($results) ? join('', $results) : '';
}
Ejemplo n.º 22
0
function form_list($curname)
{
    global $step;
    $out[] = startTable('list');
    $out[] = tr(tda(sLink('form', 'form_create', gTxt('create_new_form')), ' colspan="3" style="height:30px"'));
    $out[] = assHead('form', 'type', '');
    $methods = array('delete' => 'delete');
    $rs = safe_rows("*", "txp_form", "1 order by name");
    if ($rs) {
        foreach ($rs as $a) {
            extract($a);
            $editlink = $curname != $name ? eLink('form', 'form_edit', 'name', $name, $name) : $name;
            $modbox = $name != 'comments' && $name != 'comment_form' && $name != 'default' && $name != 'Links' ? '<input type="checkbox" name="selected_forms[]" value="' . $name . '" />' : sp;
            $out[] = tr(td($editlink) . td(small($type)) . td($modbox));
        }
        $out[] = endTable();
        $out[] = eInput('form') . sInput('form_multi_edit');
        $out[] = graf(selectInput('method', $methods, '', 1) . sp . gTxt('selected') . sp . fInput('submit', 'form_multi_edit', gTxt('go'), 'smallerbox'), ' align="right"');
        return form(join('', $out), '', "verify('" . gTxt('are_you_sure') . "')");
    }
}
Ejemplo n.º 23
0
function log_list()
{
    pagetop(gTxt('visitor_logs'));
    extract(get_prefs());
    global $txpac;
    safe_delete("txp_log", "`time` < date_sub(now(),interval " . $txpac['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("*, 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 = '';
        foreach ($rs as $a) {
            extract($a);
            if ($refer) {
                $referprint = str_replace("www.", "", substr(htmlspecialchars($refer), 0, 50));
                $referprint = '<a href="http://' . $refer . '">' . $referprint . '</a>';
            } else {
                $referprint = '&#160;';
            }
            $pageprint = preg_replace('/\\/$/', '', htmlspecialchars(substr($page, 1)));
            $pageprint = $pageprint == '' ? '' : '<a href="' . $page . '" target="_blank">' . $pageprint . '</a>';
            $fstamp = date("n/j g:i a", $stamp + $timeoffset);
            echo tr(td($fstamp) . td($host) . 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"');
    }
}
Ejemplo n.º 24
0
function image_list($message = '')
{
    global $txpcfg, $extensions, $path_from_root, $img_dir;
    $pfr = $path_from_root;
    extract($txpcfg);
    extract(get_prefs());
    pagetop(gTxt('image'), $message);
    echo pageby_form('image', $article_list_pageby);
    echo startTable('list'), tr(tda(upload_form(gTxt('upload_file'), gTxt('upload'), 'image_insert'), ' colspan="4" style="border:0"')), tr(hCell(ucfirst(gTxt('name'))) . hCell(gTxt('image_category')) . hCell(gTxt('tags')) . hCell(gTxt('author')) . hCell(gTxt('thumbnail')) . hCell());
    $page = gps('page');
    $total = getCount('txp_image', "1");
    $limit = 15;
    $numPages = ceil($total / $limit);
    $page = !$page ? 1 : $page;
    $offset = ($page - 1) * $limit;
    $nav[] = $page > 1 ? PrevNextLink("image", $page - 1, gTxt('prev'), 'prev') : '';
    $nav[] = sp . small($page . '/' . $numPages) . sp;
    $nav[] = $page != $numPages ? PrevNextLink("image", $page + 1, gTxt('next'), 'next') : '';
    $rs = safe_rows("*", "txp_image", "1 order by category,name limit {$offset},{$limit}");
    if ($rs) {
        foreach ($rs as $a) {
            extract($a);
            $thumbnail = $thumbnail ? '<img src="' . $pfr . $img_dir . '/' . $id . 't' . $ext . '" />' : gTxt('no');
            $elink = eLink('image', 'image_edit', 'id', $id, $name);
            $txtilelink = '<a target="_blank" href="?event=tag' . a . 'name=image' . a . 'id=' . $id . a . 'ext=' . $ext . a . 'alt=' . $alt . a . 'h=' . $h . a . 'w=' . $w . a . 'type=textile" onclick="window.open(this.href, \'popupwindow\', \'width=400,height=400,scrollbars,resizable\'); return false;">Textile</a>';
            $txplink = '<a target="_blank" href="?event=tag' . a . 'name=image' . a . 'id=' . $id . a . 'type=textpattern" onclick="window.open(this.href, \'popupwindow\', \'width=400,height=400,scrollbars,resizable\'); return false;">Textpattern</a>';
            $xhtmlink = '<a target="_blank" href="?event=tag' . a . 'name=image' . a . 'id=' . $id . a . 'ext=' . $ext . a . 'h=' . $h . a . 'w=' . $w . a . 'type=xhtml" onclick="window.open(this.href, \'popupwindow\', \'width=400,height=400,scrollbars,resizable\'); return false;">XHTML</a>';
            $dlink = dLink('image', 'image_delete', 'id', $id);
            echo tr(td($elink) . td($category) . td($txtilelink . ' / ' . $txplink . ' / ' . $xhtmlink) . td($author) . td($thumbnail) . td($dlink, 10));
        }
        echo tr(tdcs(graf(join('', $nav)), 4));
    }
    echo endTable();
    $imgdir = $doc_root . $path_from_root . $img_dir;
    if (!is_dir($imgdir) or !is_writeable($imgdir)) {
        echo graf(str_replace("{imgdir}", $imgdir, gTxt('img_dir_not_writeable')), ' style="text-align:center;color:red"');
    }
}
Ejemplo n.º 25
0
function link_list($message = "")
{
    global $step, $link_list_pageby;
    extract(get_prefs());
    $page = gps('page');
    $total = getCount('txp_link', "1");
    $limit = $link_list_pageby;
    $numPages = ceil($total / $limit);
    $page = !$page ? 1 : $page;
    $offset = ($page - 1) * $limit;
    $sort = gps('sort');
    $dir = gps('dir');
    $sort = $sort ? $sort : 'linksort';
    $dir = $dir ? $dir : 'asc';
    if ($dir == "desc") {
        $dir = "asc";
    } else {
        $dir = "desc";
    }
    $nav[] = $page > 1 ? PrevNextLink("link", $page - 1, gTxt('prev'), 'prev') : '';
    $nav[] = sp . small($page . '/' . $numPages) . sp;
    $nav[] = $page != $numPages ? PrevNextLink("link", $page + 1, gTxt('next'), 'next') : '';
    $rs = safe_rows("*", "txp_link", "1 order by {$sort} {$dir} limit {$offset},{$limit}");
    if ($rs) {
        echo '<form action="index.php" method="post" onsubmit="return verify(\'' . gTxt('are_you_sure') . '\')">', startTable('list'), tr(column_head('link_name', 'linksort', 'link', 1, $dir) . column_head('description', 'description', 'link', 1, $dir) . column_head('link_category', 'category', 'link', 1, $dir) . td());
        foreach ($rs as $a) {
            extract($a);
            $elink = eLink('link', 'link_edit', 'id', $id, $linkname);
            $cbox = fInput('checkbox', 'selected[]', $id);
            echo tr(td($elink) . td($description) . td($category) . td($cbox));
        }
        echo tr(tda(link_multiedit_form(), ' colspan="4" style="border:0px;text-align:right"'));
        echo endTable(), '</form>';
        echo pageby_form('link', $link_list_pageby);
        echo graf(join('', $nav), ' align="center"');
    }
}
function customer_export($step = '', $message = '')
{
    $customers = safe_rows("RealName,email,billing_company,billing_address1,billing_address2,billing_city,billing_state,billing_zip,billing_country,billing_fax,billing_phone,shipping_same_as_billing,shipping_company,shipping_address1,shipping_address2,shipping_city,shipping_state,shipping_zip,shipping_country,shipping_fax,shipping_phone,shipping_firstname,shipping_lastname,billing_firstname,billing_lastname", "txp_users", "privs = 0");
    header("Content-type: application/csv");
    header("Content-disposition:attachment;filename=customer_list_" . date("Y-m-d") . ".csv");
    echo "RealName,email,billing_company,billing_address1,billing_address2,billing_city,billing_state,billing_zip,billing_country,billing_fax,billing_phone,shipping_same_as_billing,shipping_company,shipping_address1,shipping_address2,shipping_city,shipping_state,shipping_zip,shipping_country,shipping_fax,shipping_phone,shipping_firstname,shipping_lastname,billing_firstname,billing_lastname\n";
    foreach ($customers as $customer) {
        echo implode(",", $customer) . "\n";
    }
    die;
}
Ejemplo n.º 27
0
/**
 * 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);
}
Ejemplo n.º 28
0
function load_plugins($type = 0)
{
    global $prefs, $plugins, $plugins_ver;
    if (!is_array($plugins)) {
        $plugins = array();
    }
    if (!empty($prefs['plugin_cache_dir'])) {
        $dir = rtrim($prefs['plugin_cache_dir'], '/') . '/';
        // in case it's a relative path
        if (!is_dir($dir)) {
            $dir = rtrim(realpath(txpath . '/' . $dir), '/') . '/';
        }
        $files = glob($dir . '*.php');
        if ($files) {
            natsort($files);
            foreach ($files as $f) {
                load_plugin(basename($f, '.php'));
            }
        }
    }
    $where = 'status = 1 AND type IN (' . ($type ? '1,3' : '0,1') . ')';
    $rs = safe_rows("name, code, version", "txp_plugin", $where . ' order by load_order');
    if ($rs) {
        $old_error_handler = set_error_handler("pluginErrorHandler");
        foreach ($rs as $a) {
            if (!in_array($a['name'], $plugins)) {
                $plugins[] = $a['name'];
                $plugins_ver[$a['name']] = $a['version'];
                $GLOBALS['txp_current_plugin'] = $a['name'];
                $eval_ok = eval($a['code']);
                if ($eval_ok === FALSE) {
                    echo gTxt('plugin_load_error_above') . strong($a['name']) . n . br;
                }
                unset($GLOBALS['txp_current_plugin']);
            }
        }
        restore_error_handler();
    }
}
Ejemplo n.º 29
0
/**
 * Generates a &lt;table&gt; of every language that Textpattern supports.
 *
 * If requested with HTTP POST parameter 'force' set anything other than 'file',
 * outputs any errors in RPC server connection.
 *
 * @param string|array $message The activity message
 */
function list_languages($message = '')
{
    require_once txpath . '/lib/IXRClass.php';
    $active_lang = safe_field("val", 'txp_prefs', "name = 'language'");
    $lang_form = tag(form(tag(gTxt('active_language'), 'label', array('for' => 'language')) . languages('language', $active_lang) . eInput('lang') . sInput('save_language')), 'div', array('class' => 'txp-control-panel'));
    $client = new IXR_Client(RPC_SERVER);
    //    $client->debug = true;
    $available_lang = array();
    $rpc_connect = false;
    $show_files = false;
    // Get items from RPC.
    @set_time_limit(90);
    // TODO: 90 seconds: seriously?
    if ($client->query('tups.listLanguages', get_pref('blog_uid'))) {
        $rpc_connect = true;
        $response = $client->getResponse();
        foreach ($response as $language) {
            $available_lang[$language['language']]['rpc_lastmod'] = gmmktime($language['lastmodified']->hour, $language['lastmodified']->minute, $language['lastmodified']->second, $language['lastmodified']->month, $language['lastmodified']->day, $language['lastmodified']->year);
        }
    } elseif (gps('force') != 'file') {
        $msg = gTxt('rpc_connect_error') . "<!--" . $client->getErrorCode() . ' ' . $client->getErrorMessage() . "-->";
    }
    // Get items from Filesystem.
    $files = get_lang_files();
    if (is_array($files) && !empty($files)) {
        foreach ($files as $file) {
            if ($fp = @fopen(txpath . DS . 'lang' . DS . $file, 'r')) {
                $name = preg_replace('/\\.(txt|textpack)$/i', '', $file);
                $firstline = fgets($fp, 4069);
                fclose($fp);
                if (strpos($firstline, '#@version') !== false) {
                    @(list($fversion, $ftime) = explode(';', trim(substr($firstline, strpos($firstline, ' ', 1)))));
                } else {
                    $fversion = $ftime = null;
                }
                $available_lang[$name]['file_note'] = isset($fversion) ? $fversion : 0;
                $available_lang[$name]['file_lastmod'] = isset($ftime) ? $ftime : 0;
            }
        }
    }
    // Get installed items from the database.
    // We need a value here for the language itself, not for each one of the rows.
    $rows = safe_rows("lang, UNIX_TIMESTAMP(MAX(lastmod)) AS lastmod", 'txp_lang', "1 = 1 GROUP BY lang ORDER BY lastmod DESC");
    $installed_lang = array();
    foreach ($rows as $language) {
        $available_lang[$language['lang']]['db_lastmod'] = $language['lastmod'];
        if ($language['lang'] != $active_lang) {
            $installed_lang[] = $language['lang'];
        }
    }
    $list = '';
    // Create the language table components.
    foreach ($available_lang as $langname => $langdat) {
        $file_updated = isset($langdat['db_lastmod']) && @$langdat['file_lastmod'] > $langdat['db_lastmod'];
        $rpc_updated = @$langdat['rpc_lastmod'] > @$langdat['db_lastmod'];
        $rpc_install = tda($rpc_updated ? strong(eLink('lang', 'get_language', 'lang_code', $langname, isset($langdat['db_lastmod']) ? gTxt('update') : gTxt('install'), 'updating', isset($langdat['db_lastmod']), '')) . n . span(safe_strftime('%d %b %Y %X', @$langdat['rpc_lastmod']), array('class' => 'date modified')) : (isset($langdat['rpc_lastmod']) ? gTxt('up_to_date') : '-') . (isset($langdat['db_lastmod']) ? n . span(safe_strftime('%d %b %Y %X', $langdat['db_lastmod']), array('class' => 'date modified')) : ''), isset($langdat['db_lastmod']) && $rpc_updated ? ' class="highlight lang-value"' : ' class="lang-value"');
        $lang_file = tda(isset($langdat['file_lastmod']) ? strong(eLink('lang', 'get_language', 'lang_code', $langname, $file_updated ? gTxt('update') : gTxt('install'), 'force', 'file', '')) . n . span(safe_strftime(get_pref('archive_dateformat'), $langdat['file_lastmod']), array('class' => 'date ' . ($file_updated ? 'created' : 'modified'))) : '-', ' class="lang-value languages_detail' . (isset($langdat['db_lastmod']) && $rpc_updated ? ' highlight' : '') . '"');
        $list .= tr(hCell(gTxt($langname), '', isset($langdat['db_lastmod']) && $rpc_updated ? ' class="highlight lang-label" scope="row"' : ' class="lang-label" scope="row"') . n . $rpc_install . n . $lang_file . tda(in_array($langname, $installed_lang) ? dLink('lang', 'remove_language', 'lang_code', $langname, 1) : '-', ' class="languages_detail' . (isset($langdat['db_lastmod']) && $rpc_updated ? ' highlight' : '') . '"')) . n;
    }
    // Output table and content.
    pagetop(gTxt('tab_languages'), $message);
    echo n . tag(hed(gTxt('tab_languages'), 1, array('class' => 'txp-heading')), 'div', array('class' => 'txp-layout-2col-cell-1')) . n . tag_start('div', array('class' => 'txp-layout-1col', 'id' => 'language_container'));
    if (isset($msg) && $msg) {
        echo graf('<span class="ui-icon ui-icon-closethick"></span> ' . $msg, array('class' => 'alert-block error'));
    }
    echo $lang_form, n . tag(toggle_box('languages_detail'), 'div', array('class' => 'txp-list-options')) . n . tag_start('div', array('class' => 'txp-listtables')) . n . tag_start('table', array('class' => 'txp-list')) . n . tag_start('thead') . tr(hCell(gTxt('language'), '', ' scope="col"') . hCell(gTxt('from_server') . popHelp('install_lang_from_server'), '', ' scope="col"') . hCell(gTxt('from_file') . popHelp('install_lang_from_file'), '', ' class="languages_detail" scope="col"') . hCell(gTxt('remove_lang') . popHelp('remove_lang'), '', ' class="languages_detail" scope="col"')) . n . tag_end('thead') . n . tag_start('tbody') . $list . n . tag_end('tbody') . n . tag_end('table') . n . tag_end('div') . hed(gTxt('install_from_textpack'), 2) . n . tag(form('<label for="textpack-install">' . gTxt('install_textpack') . '</label>' . popHelp('get_textpack') . n . '<textarea class="code" id="textpack-install" name="textpack" cols="' . INPUT_LARGE . '" rows="' . TEXTAREA_HEIGHT_SMALL . '" dir="ltr"></textarea>' . fInput('submit', 'install_new', gTxt('upload')) . eInput('lang') . sInput('get_textpack'), '', '', 'post', '', '', 'text_uploader'), 'div', array('class' => 'txp-control-panel')) . n . tag_end('div');
}
Ejemplo n.º 30
0
    $update_files = 1;
}
if (!in_array('size', $txpfile)) {
    safe_alter('txp_file', "add size bigint");
    $update_files = 1;
}
if (!in_array('downloads', $txpfile)) {
    safe_alter('txp_file', "ADD downloads INT DEFAULT '0' NOT NULL");
}
if (array_intersect(array('modified', 'created'), $txpfile)) {
    safe_alter('txp_file', "MODIFY modified datetime NOT NULL default '0000-00-00 00:00:00', MODIFY created datetime NOT NULL default '0000-00-00 00:00:00'");
}
// copy existing file timestamps into the new database columns
if ($update_files) {
    $prefs = get_prefs();
    $rs = safe_rows('*', 'txp_file', '1=1');
    foreach ($rs as $row) {
        $path = build_file_path(@$prefs['file_base_path'], @$row['filename']);
        if ($path and $stat = @stat($path)) {
            safe_update('txp_file', "created='" . strftime('%Y-%m-%d %H:%M:%S', $stat['ctime']) . "', modified='" . strftime('%Y-%m-%d %H:%M:%S', $stat['mtime']) . "', size='" . doSlash(sprintf('%u', $stat['size'])) . "'", "id='" . doSlash($row['id']) . "'");
        }
    }
}
safe_update('textpattern', "Keywords=TRIM(BOTH ',' FROM REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(Keywords,'\n',','),'\r',','),'\t',','),'    ',' '),'  ',' '),'  ',' '),' ,',','),', ',','),',,,,',','),',,',','),',,',','))", "Keywords != ''");
// shift preferences to more intuitive spots
// give positions, leave enough room for later additions
safe_update('txp_prefs', "position = 20", "name in(\n\t\t'sitename',\n\t\t'comments_on_default',\n\t\t'img_dir',\n\t\t'comments_require_name',\n\t\t'syndicate_body_or_excerpt',\n\t\t'title_no_widow'\n\t)");
safe_update('txp_prefs', "position = 40", "name in(\n\t\t'siteurl',\n\t\t'comments_default_invite',\n\t\t'file_base_path',\n\t\t'comments_require_email',\n\t\t'rss_how_many',\n\t\t'articles_use_excerpts'\n\t)");
safe_update('txp_prefs', "position = 60", "name in('\n\t\tsite_slogan',\n\t\t'comments_moderate',\n\t\t'never_display_email',\n\t\t'file_max_upload_size',\n\t\t'show_comment_count_in_feed',\n\t\t'allow_form_override'\n\t)");
safe_update('txp_prefs', "position = 80", "name in(\n\t\t'production_status',\n\t\t'comments_disabled_after',\n\t\t'tempdir',\n\t\t'comment_nofollow',\n\t\t'include_email_atom',\n\t\t'attach_titles_to_permalinks'\n\t)");
safe_update('txp_prefs', "position = 100", "name in(\n\t\t'gmtoffset',\n\t\t'comments_auto_append',\n\t\t'plugin_cache_dir',\n\t\t'permalink_title_format',\n\t\t'use_mail_on_feeds_id'\n\t)");