function otf_author($option_key, $result, $ext) { if ($ext) { $s = explode(':', $ext); if (count($s) == 1) { $type = $s[0]; } } switch ($type) { case 'display': $author = get_author_name($result->post_author); break; case 'full': $auth = get_userdata($result->post_author); $author = $auth->first_name . ' ' . $auth->last_name; break; case 'reverse': $auth = get_userdata($result->post_author); $author = $auth->last_name . ', ' . $auth->first_name; break; case 'first': $auth = get_userdata($result->post_author); $author = $auth->first_name; break; case 'last': $auth = get_userdata($result->post_author); $author = $auth->last_name; break; default: $author = get_author_name($result->post_author); } return $author; }
function id_get_author_name() { if (function_exists('get_the_author_meta')) { return get_the_author_meta('display_name'); } return get_author_name(); }
function ipad_html($post) { global $ml_html_banners_enable; $ml_html_banners_enable = get_option("ml_html_banners_enable"); $prefiltered_html = ml_filters_get_filtered($post->post_content); $prefiltered_html = str_replace("\n", "<p></p>", $prefiltered_html); $html = str_get_html($prefiltered_html); $img_tags = $html->find('img'); $iframe_tags = $html->find('iframe'); $object_tags = $html->find('object'); $embed_tags = $html->find('embed'); $tags = array_merge($img_tags, $iframe_tags, $object_tags, $embed_tags); $scripts = $html->find('script'); //on center, with specific width and no height foreach ($tags as $e) { //no width or height if (isset($e->width)) { $e->width = null; } if (isset($e->height)) { $e->height = null; } $e->style = "max-width:520px;margin-top:20px;margin-bottom:20px;"; if ($e->tag == "iframe" || $e->tag == "object" || $e->tag == "embed") { //should be a video $e->width = 500; $e->height = 300; } //center $e->outertext = "<center><div class=\"wp2android_media\">" . $e->outertext . "</div></center><p></p>"; } foreach ($scripts as $s) { $s->outertext = ""; } //JAVASCRIPT INCLUDES //HEAD $header = "<head>" . $header_js; $header .= "<meta name=\"viewport\" content=\"width=device-width; minimum-scale=1.0; maximum-scale=1.0;\" />"; $header .= "<link rel=\"StyleSheet\" href=\"" . plugin_dir_url(__FILE__) . "css/ipad.css\" type=\"text/css\" media=\"screen\">"; $header .= "<link rel=\"StyleSheet\" href=\"" . plugin_dir_url(__FILE__) . "css/ipad_portrait.css\" type=\"text/css\" media=\"screen\" id=\"orient_css\">"; $header .= ml_filters_header($post->postID); $header .= "</head>"; $init_html = "<html manifest=\"" . plugin_dir_url(__FILE__ + "../") . "manifest.php\">" . $header; $title = "<h1 class='title' align='left'>" . $post->post_title . "</h1>"; $author = get_author_name($post->post_author); $text_author = ""; if (strcmp($author, "admin") != 0) { if (strcmp($author, "") != 0) { $text_author = " • " . get_author_name($post->post_author); } } if (get_post_type($post->ID) != "page") { $title .= "<p class='details'>" . mysql2date('F j Y', $post->post_date) . "" . $text_author . "</p><p> </p>"; } $final_html = $init_html; $final_html .= "<body><div id=\"content\">"; $final_html .= $spaces; $final_html .= $title . $html->save() . $spaces . "<br/><br/><br/><br/><br/><br/><br/><br/></div></body></html>"; return $final_html; }
function iphone_html($post) { global $ml_html_banners_enable; $ml_html_banners_enable = get_option(base64_decode('bWxfaHRtbF9iYW5uZXJzX2VuYWJsZQ==')); $prefiltered_html = ml_filters_get_filtered($post->post_content); $prefiltered_html = str_replace(base64_decode('Cg=='), base64_decode('PHA+PC9wPg=='), $prefiltered_html); $html = str_get_html($prefiltered_html); if ($html == NULL) { return $prefiltered_html; } $img_tags = $html->find(base64_decode('aW1n')); $iframe_tags = $html->find(base64_decode('aWZyYW1l')); $object_tags = $html->find(base64_decode('b2JqZWN0')); $embed_tags = $html->find(base64_decode('ZW1iZWQ=')); $tags = array_merge($img_tags, $iframe_tags, $object_tags, $embed_tags); $scripts = $html->find(base64_decode('c2NyaXB0')); foreach ($tags as $e) { if (isset($e->width)) { $e->width = null; } if (isset($e->height)) { $e->height = null; } $e->style = base64_decode('bWF4LXdpZHRoOjI4MHB4Ow=='); $e->outertext = base64_decode('PGNlbnRlcj48ZGl2IGNsYXNzPSJtb2JpbG91ZF9tZWRpYSI+') . $e->outertext . base64_decode('PC9kaXY+PC9jZW50ZXI+PHA+PC9wPg=='); } foreach ($scripts as $s) { $s->outertext = ''; } $header = base64_decode('PGhlYWQ+') . $header_js; $header .= base64_decode('PG1ldGEgbmFtZT0idmlld3BvcnQiIGNvbnRlbnQ9IndpZHRoPWRldmljZS13aWR0aDsgbWluaW11bS1zY2FsZT0xLjA7IG1heGltdW0tc2NhbGU9MS4wOyIgLz4='); $header .= base64_decode('PGxpbmsgcmVsPSJTdHlsZVNoZWV0IiBocmVmPSI=') . plugin_dir_url(__FILE__) . base64_decode('Y3NzL2lwaG9uZS5jc3MiIHR5cGU9InRleHQvY3NzIiAgbWVkaWE9InNjcmVlbiI+'); $header .= base64_decode('PGxpbmsgcmVsPSJTdHlsZVNoZWV0IiBocmVmPSI=') . plugin_dir_url(__FILE__) . base64_decode('Y3NzL2lwaG9uZV9wb3J0cmFpdC5jc3MiIHR5cGU9InRleHQvY3NzIiAgbWVkaWE9InNjcmVlbiIgaWQ9Im9yaWVudF9jc3MiPg=='); $header .= ml_filters_header($post->postID); $header .= base64_decode('PC9oZWFkPg=='); $init_html = base64_decode('PGh0bWwgbWFuaWZlc3Q9Ig==') . plugin_dir_url(__FILE__ + base64_decode('Li4v')) . base64_decode('bWFuaWZlc3QucGhwIj4=') . $header; $title = base64_decode('PGgxIGFsaWduPSdsZWZ0Jz4=') . $post->post_title . base64_decode('PC9oMT4='); $author = get_author_name($post->post_author); $text_author = ''; if (strcmp($author, base64_decode('YWRtaW4=')) != 0) { if (strcmp($author, '') != 0) { $text_author = base64_decode('ICZidWxsOyA=') . get_author_name($post->post_author); } } if (get_post_type($post->ID) != base64_decode('cGFnZQ==')) { $title .= base64_decode('PHAgY2xhc3M9J2RldGFpbHMnPg==') . mysql2date(base64_decode('RiBqIFk='), $post->post_date) . '' . $text_author . base64_decode('PC9wPjxwPiZuYnNwOzwvcD4='); } $final_html = $init_html; if ($ml_html_banners_enable) { $final_html .= base64_decode('PGJvZHk+PGRpdiBpZD0iY29udGVudCIgc3R5bGU9Im1hcmdpbi10b3A6NjBweCI+'); $final_html .= $spaces; } else { $final_html .= base64_decode('PGJvZHk+PGRpdiBpZD0iY29udGVudCIgPg=='); } $final_html .= $spaces . $title . $html->save() . $spaces . base64_decode('PGJyLz48YnIvPjxici8+PGJyLz48YnIvPjxici8+PGJyLz48YnIvPjwvZGl2PjwvYm9keT48L2h0bWw+'); return $final_html; }
function get_page_list() { $cat = $_GET['cat']; $page = $_GET['page']; $posts_per_page = $_GET['posts_per_page']; if (!is_null($cat) && $cat != 0 && !is_null($page)) { $args = array("category__in" => array($cat), "paged" => $page, "posts_per_page" => $posts_per_page, "post_status" => "publish", 'post_type' => 'post', 'orderby' => 'post_date', 'order' => 'desc'); } else { if (!is_null($cat) && $cat != 0 && is_null($page)) { $args = array("category__in" => array($cat), "posts_per_page" => $posts_per_page, "post_status" => "publish", 'post_type' => 'post', 'orderby' => 'post_date', 'order' => 'desc'); } else { if ((is_null($cat) || $cat == 0) && !is_null($page)) { $args = array("paged" => $page, "posts_per_page" => $posts_per_page, "post_status" => "publish", 'post_type' => 'post', 'orderby' => 'post_date', 'order' => 'desc'); } else { $args = array("posts_per_page" => $posts_per_page, "post_status" => "publish", 'post_type' => 'post', 'orderby' => 'post_date', 'order' => 'desc'); } } } if (!is_null($cat)) { $posts = get_posts('post_status=publish&numberposts=-1&category=' . $cat); $count_total = count($posts); } else { $cat_case = get_category_by_slug('case'); $cat_interview = get_category_by_slug('interview'); $cat_personnel = get_category_by_slug('personnel'); $cat_special = get_category_by_slug('special-column'); $cat_news = get_category_by_slug('news'); $posts = get_posts('post_status=publish&numberposts=-1&category=' . $cat_case . ',' . $cat_interview . ',' . $cat_personnel . ',' . $cat_special . ',' . $cat_news); $count_total = count($posts); } $the_query = new WP_Query($args); $resultData = new resultData(); $resultList = array(); $resultData->count_total = $count_total; while ($the_query->have_posts()) { $the_query->the_post(); $post = new postData(); $post->title_plain = get_the_title(); $post->url = get_permalink(); $post->thumbnail = get_template_directory_uri() . "/timthumb.php?src=" . post_thumbnail_src() . "&h=168&w=224&zc=1"; $post->excerpt = get_the_excerpt(); $post->date = get_the_date('20y-m-d'); $post->author_name = get_author_name(); $post->views = getPostViews(get_the_ID()); $the_post_category = get_the_category(get_the_ID()); $post->category_name = $the_post_category[0]->cat_name; $the_post_category = get_the_category(get_the_ID()); $catSlug = $the_post_category[0]->slug; $post->category_slug = $catSlug; $resultList[] = $post; } $resultData->posts = $resultList; header("Content-type: application/json"); echo json_encode($resultData); wp_reset_query(); die; }
function ipad_html($post) { global $ml_html_banners_enable; $ml_html_banners_enable = get_option(base64_decode('bWxfaHRtbF9iYW5uZXJzX2VuYWJsZQ==')); $prefiltered_html = ml_filters_get_filtered($post->post_content); $prefiltered_html = str_replace(base64_decode('Cg=='), base64_decode('PHA+PC9wPg=='), $prefiltered_html); $html = str_get_html($prefiltered_html); $img_tags = $html->find(base64_decode('aW1n')); $iframe_tags = $html->find(base64_decode('aWZyYW1l')); $object_tags = $html->find(base64_decode('b2JqZWN0')); $embed_tags = $html->find(base64_decode('ZW1iZWQ=')); $tags = array_merge($img_tags, $iframe_tags, $object_tags, $embed_tags); $scripts = $html->find(base64_decode('c2NyaXB0')); foreach ($tags as $e) { if (isset($e->width)) { $e->width = null; } if (isset($e->height)) { $e->height = null; } $e->style = base64_decode('bWF4LXdpZHRoOjUyMHB4O21hcmdpbi10b3A6MjBweDttYXJnaW4tYm90dG9tOjIwcHg7'); if ($e->tag == base64_decode('aWZyYW1l') || $e->tag == base64_decode('b2JqZWN0') || $e->tag == base64_decode('ZW1iZWQ=')) { $e->width = 500; $e->height = 300; } $e->outertext = base64_decode('PGNlbnRlcj48ZGl2IGNsYXNzPSJtb2JpbG91ZF9tZWRpYSI+') . $e->outertext . base64_decode('PC9kaXY+PC9jZW50ZXI+PHA+PC9wPg=='); } foreach ($scripts as $s) { $s->outertext = ''; } $header = base64_decode('PGhlYWQ+') . $header_js; $header .= base64_decode('PG1ldGEgbmFtZT0idmlld3BvcnQiIGNvbnRlbnQ9IndpZHRoPWRldmljZS13aWR0aDsgbWluaW11bS1zY2FsZT0xLjA7IG1heGltdW0tc2NhbGU9MS4wOyIgLz4='); $header .= base64_decode('PGxpbmsgcmVsPSJTdHlsZVNoZWV0IiBocmVmPSI=') . plugin_dir_url(__FILE__) . base64_decode('Y3NzL2lwYWQuY3NzIiB0eXBlPSJ0ZXh0L2NzcyIgIG1lZGlhPSJzY3JlZW4iPg=='); $header .= base64_decode('PGxpbmsgcmVsPSJTdHlsZVNoZWV0IiBocmVmPSI=') . plugin_dir_url(__FILE__) . base64_decode('Y3NzL2lwYWRfcG9ydHJhaXQuY3NzIiB0eXBlPSJ0ZXh0L2NzcyIgIG1lZGlhPSJzY3JlZW4iIGlkPSJvcmllbnRfY3NzIj4='); $header .= ml_filters_header($post->postID); $header .= base64_decode('PC9oZWFkPg=='); $init_html = base64_decode('PGh0bWwgbWFuaWZlc3Q9Ig==') . plugin_dir_url(__FILE__ + base64_decode('Li4v')) . base64_decode('bWFuaWZlc3QucGhwIj4=') . $header; $title = base64_decode('PGgxIGNsYXNzPSd0aXRsZScgYWxpZ249J2xlZnQnPg==') . $post->post_title . base64_decode('PC9oMT4='); $author = get_author_name($post->post_author); $text_author = ''; if (strcmp($author, base64_decode('YWRtaW4=')) != 0) { if (strcmp($author, '') != 0) { $text_author = base64_decode('ICZidWxsOyA=') . get_author_name($post->post_author); } } if (get_post_type($post->ID) != base64_decode('cGFnZQ==')) { $title .= base64_decode('PHAgY2xhc3M9J2RldGFpbHMnPg==') . mysql2date(base64_decode('RiBqIFk='), $post->post_date) . '' . $text_author . base64_decode('PC9wPjxwPiZuYnNwOzwvcD4='); } $final_html = $init_html; $final_html .= base64_decode('PGJvZHk+PGRpdiBpZD0iY29udGVudCI+'); $final_html .= $spaces; $final_html .= $title . $html->save() . $spaces . base64_decode('PGJyLz48YnIvPjxici8+PGJyLz48YnIvPjxici8+PGJyLz48YnIvPjwvZGl2PjwvYm9keT48L2h0bWw+'); return $final_html; }
function get_breadcrumbs() { // $xoops_breadcrumbs[0] = array( 'name' => get_bloginfo('description') , 'url' => get_settings('home')); $xoops_breadcrumbs[0] = array('name' => get_bloginfo('name'), 'url' => get_settings('home')); $pagetitle = ''; if (is_category()) { $this_cat = get_category($cat); $p_count = 0; while ($this_cat->parent) { $this_cat = get_category($this_cat->parent); $cat_parrent[$p_count] = array('name' => $this_cat->cat_name, 'url' => get_category_link($this_cat->cat_ID)); $p_count++; } for ($i = 1; $i <= $p_count; $i++) { $xoops_breadcrumbs[$i] = $cat_parrent[$p_count - $i]; } $xoops_breadcrumbs[$p_count + 1] = array('name' => single_cat_title('', false)); } elseif (is_day()) { $xoops_breadcrumbs[1] = array('name' => get_the_time(__('F j, Y'))); } elseif (is_month()) { $xoops_breadcrumbs[1] = array('name' => get_the_time(__('F, Y'))); } elseif (is_year()) { $xoops_breadcrumbs[1] = array('name' => get_the_time('Y')); } elseif (is_author()) { $xoops_breadcrumbs[1] = array('name' => get_author_name(get_query_var('author'))); } elseif (is_single()) { $xoops_breadcrumbs[1] = array('name' => single_post_title('', false)); } elseif (is_page()) { $now_page = get_page($page_id); $this_page = $now_page; $p_count = 0; while ($this_page->post_parent) { $this_page = get_page($this_page->post_parent); $page_parrent[$p_count] = array('name' => $this_page->post_title, 'url' => get_permalink($this_page->ID)); $p_count++; } for ($i = 1; $i <= $p_count; $i++) { $xoops_breadcrumbs[$i] = $page_parrent[$p_count - $i]; } $xoops_breadcrumbs[$p_count + 1] = array('name' => $now_page->post_title); } elseif (is_search()) { $xoops_breadcrumbs[1] = array('name' => $pagetitle); } elseif (function_exists('is_tag')) { if (is_tag()) { $xoops_breadcrumbs[1] = array('name' => single_tag_title('', false)); } } return $xoops_breadcrumbs; }
/** * Provides access to an author's username and email address. * Replaces the spaces in an author's real name with any character. * * @param array $atts * @param string $atts['display'] 'email', 'name', 'username' * @param bool $atts['lowercase'] Lowercases $display * @param string $atts['separator'] Replace spaces in $display with any char. * @param string $atts['username'] Username to base output on. Default: * article author */ function jmd_author($atts) { global $thisarticle; extract(lAtts(array('display' => 'username', 'lowercase' => 0, 'separator' => ' ', 'username' => $thisarticle['authorid']), $atts)); $out = $username; switch ($display) { case 'email': $out = eE(safe_field("email", "txp_users", "name='{$username}'")); break; case 'name': $out = get_author_name($username); break; default: } if ($lowercase == 1) { $out = strtolower($out); } return str_replace(' ', $separator, $out); }
function list_post_revisions($post) { if ($revisions = wp_get_post_revisions($post->ID)) { $items = ''; $revision_id = valid_revision_id() ? $revision_id = $_GET['revision'] : $post->ID; foreach ($revisions as $revision) { $date = wp_post_revision_title($revision, 0); $name = get_author_name($revision->post_author); $query_string = get_query_string($revision); $items .= "<li>"; if ($revision_id == $revision->ID) { $items .= "{$date} by {$name} (<em>displayed above</em>)"; } else { $items .= "<a href=\"{$query_string}\">{$date}</a> by {$name}"; } $items .= "</li>"; } return "<ul class='revision-list'>{$items}</ul>"; } }
_e("Posts By:", "bonestheme"); ?> </span> <!-- google+ rel=me function --> <?php $curauth = get_query_var('author_name') ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author')); $google_profile = get_the_author_meta('google_profile', $curauth->ID); if ($google_profile) { echo '<a href="' . esc_url($google_profile) . '" rel="me">' . $curauth->display_name . '</a>'; ?> </a> <?php } else { ?> <?php echo get_author_name(get_query_var('author')); ?> <?php } ?> </h1> <?php if (have_posts()) { while (have_posts()) { the_post(); ?> <article id="post-<?php the_ID(); ?>
function thesis_default_archive_info() { echo "\t\t\t<div id=\"archive_info\">\n"; if (is_category()) { ?> <p><?php _e('From the category archives:', 'thesis'); ?> </p> <h1><?php single_cat_title(); ?> </h1> <?php } elseif (is_tag()) { ?> <p><?php _e('Posts tagged as:', 'thesis'); ?> </p> <h1><?php single_tag_title(); ?> </h1> <?php } elseif (is_author()) { ?> <p><?php _e('Posts by author:', 'thesis'); ?> </p> <h1><?php echo get_author_name(get_query_var('author')); ?> </h1> <?php } elseif (is_day()) { ?> <p><?php _e('From the daily archives:', 'thesis'); ?> </p> <h1><?php the_time('l, F j, Y'); ?> </h1> <?php } elseif (is_month()) { ?> <p><?php _e('From the monthly archives:', 'thesis'); ?> </p> <h1><?php the_time('F Y'); ?> </h1> <?php } elseif (is_year()) { ?> <p><?php _e('From the yearly archives:', 'thesis'); ?> </p> <h1><?php the_time('Y'); ?> </h1> <?php } elseif (is_search()) { ?> <p><?php _e('You searched for:', 'thesis'); ?> </p> <h1><?php echo attribute_escape(get_search_query()); ?> </h1> <?php } echo "\t\t\t</div>\n"; }
function rss() { global $prefs, $thisarticle; set_error_handler('feedErrorHandler'); ob_clean(); extract($prefs); extract(doSlash(gpsa(array('limit', 'area')))); // build filter criteria from a comma-separated list of sections and categories $feed_filter_limit = get_pref('feed_filter_limit', 10); $section = gps('section'); $category = gps('category'); if (!is_scalar($section) || !is_scalar($category)) { txp_die('Not Found', 404); } $section = $section ? array_slice(array_unique(do_list($section)), 0, $feed_filter_limit) : array(); $category = $category ? array_slice(array_unique(do_list($category)), 0, $feed_filter_limit) : array(); $st = array(); foreach ($section as $s) { $st[] = fetch_section_title($s); } $ct = array(); foreach ($category as $c) { $ct[] = fetch_category_title($c); } $sitename .= $section ? ' - ' . join(' - ', $st) : ''; $sitename .= $category ? ' - ' . join(' - ', $ct) : ''; $dn = explode('/', $siteurl); $mail_or_domain = $use_mail_on_feeds_id ? eE($blog_mail_uid) : $dn[0]; // feed header $out[] = tag('http://textpattern.com/?v=' . $version, 'generator'); $out[] = tag(doSpecial($sitename), 'title'); $out[] = tag(hu, 'link'); $out[] = '<atom:link href="' . pagelinkurl(array('rss' => 1, 'area' => $area, 'section' => $section, 'category' => $category, 'limit' => $limit)) . '" rel="self" type="application/rss+xml" />'; $out[] = tag(doSpecial($site_slogan), 'description'); $last = fetch('unix_timestamp(val)', 'txp_prefs', 'name', 'lastmod'); $out[] = tag(safe_strftime('rfc822', $last), 'pubDate'); $out[] = callback_event('rss_head'); // feed items $articles = array(); $section = doSlash($section); $category = doSlash($category); if (!$area or $area == 'article') { $sfilter = !empty($section) ? "and Section in ('" . join("','", $section) . "')" : ''; $cfilter = !empty($category) ? "and (Category1 in ('" . join("','", $category) . "') or Category2 in ('" . join("','", $category) . "'))" : ''; $limit = $limit ? $limit : $rss_how_many; $limit = intval(min($limit, max(100, $rss_how_many))); $frs = safe_column("name", "txp_section", "in_rss != '1'"); if ($frs) { foreach ($frs as $f) { $query[] = "and Section != '" . doSlash($f) . "'"; } } $query[] = $sfilter; $query[] = $cfilter; $expired = $publish_expired_articles ? '' : ' and (now() <= Expires or Expires = ' . NULLDATETIME . ') '; $rs = safe_rows_start("*, unix_timestamp(Posted) as uPosted, unix_timestamp(LastMod) as uLastMod, unix_timestamp(Expires) as uExpires, ID as thisid", "textpattern", "Status = 4 " . join(' ', $query) . "and Posted < now()" . $expired . "order by Posted desc limit {$limit}"); if ($rs) { while ($a = nextRow($rs)) { extract($a); populateArticleData($a); $cb = callback_event('rss_entry'); $a['posted'] = $uPosted; $permlink = permlinkurl($a); $summary = trim(replace_relative_urls(parse($thisarticle['excerpt']), $permlink)); $content = trim(replace_relative_urls(parse($thisarticle['body']), $permlink)); if ($syndicate_body_or_excerpt) { # short feed: use body as summary if there's no excerpt if (!trim($summary)) { $summary = $content; } $content = ''; } if ($show_comment_count_in_feed) { $count = $comments_count > 0 ? ' [' . $comments_count . ']' : ''; } else { $count = ''; } $Title = escape_title(strip_tags($Title)) . $count; $thisauthor = get_author_name($AuthorID); $item = tag($Title, 'title') . n . (trim($summary) ? tag(n . escape_cdata($summary) . n, 'description') . n : '') . (trim($content) ? tag(n . escape_cdata($content) . n, 'content:encoded') . n : '') . tag($permlink, 'link') . n . tag(safe_strftime('rfc822', $a['posted']), 'pubDate') . n . tag(htmlspecialchars($thisauthor), 'dc:creator') . n . tag('tag:' . $mail_or_domain . ',' . $feed_time . ':' . $blog_uid . '/' . $uid, 'guid', ' isPermaLink="false"') . n . $cb; $articles[$ID] = tag($item, 'item'); $etags[$ID] = strtoupper(dechex(crc32($articles[$ID]))); $dates[$ID] = $uPosted; } } } elseif ($area == 'link') { $cfilter = $category ? "category in ('" . join("','", $category) . "')" : '1'; $limit = $limit ? $limit : $rss_how_many; $limit = intval(min($limit, max(100, $rss_how_many))); $rs = safe_rows_start("*, unix_timestamp(date) as uDate", "txp_link", "{$cfilter} order by date desc limit {$limit}"); if ($rs) { while ($a = nextRow($rs)) { extract($a); $item = tag(doSpecial($linkname), 'title') . n . tag(doSpecial($description), 'description') . n . tag(doSpecial($url), 'link') . n . tag(safe_strftime('rfc822', $uDate), 'pubDate'); $articles[$id] = tag($item, 'item'); $etags[$id] = strtoupper(dechex(crc32($articles[$id]))); $dates[$id] = $date; } } } if (!$articles) { if ($section) { if (safe_field('name', 'txp_section', "name in ('" . join("','", $section) . "')") == false) { txp_die(gTxt('404_not_found'), '404'); } } elseif ($category) { switch ($area) { case 'link': if (safe_field('id', 'txp_category', "name = '{$category}' and type = 'link'") == false) { txp_die(gTxt('404_not_found'), '404'); } break; case 'article': default: if (safe_field('id', 'txp_category', "name in ('" . join("','", $category) . "') and type = 'article'") == false) { txp_die(gTxt('404_not_found'), '404'); } break; } } } else { //turn on compression if we aren't using it already if (extension_loaded('zlib') && ini_get("zlib.output_compression") == 0 && ini_get('output_handler') != 'ob_gzhandler' && !headers_sent()) { // make sure notices/warnings/errors don't fudge up the feed // when compression is used $buf = ''; while ($b = @ob_get_clean()) { $buf .= $b; } @ob_start('ob_gzhandler'); echo $buf; } handle_lastmod(); $hims = serverset('HTTP_IF_MODIFIED_SINCE'); $imsd = $hims ? strtotime($hims) : 0; if (is_callable('apache_request_headers')) { $headers = apache_request_headers(); if (isset($headers["A-IM"])) { $canaim = strpos($headers["A-IM"], "feed"); } else { $canaim = false; } } else { $canaim = false; } $hinm = stripslashes(serverset('HTTP_IF_NONE_MATCH')); $cutarticles = false; if ($canaim !== false) { foreach ($articles as $id => $thing) { if (strpos($hinm, $etags[$id]) !== false) { unset($articles[$id]); $cutarticles = true; $cut_etag = true; } if ($dates[$id] < $imsd) { unset($articles[$id]); $cutarticles = true; $cut_time = true; } } } if (isset($cut_etag) && isset($cut_time)) { header("Vary: If-None-Match, If-Modified-Since"); } else { if (isset($cut_etag)) { header("Vary: If-None-Match"); } else { if (isset($cut_time)) { header("Vary: If-Modified-Since"); } } } $etag = @join("-", $etags); if (strstr($hinm, $etag)) { txp_status_header('304 Not Modified'); exit(0); } if ($cutarticles) { //header("HTTP/1.1 226 IM Used"); //This should be used as opposed to 200, but Apache doesn't like it. //http://intertwingly.net/blog/2004/09/11/Vary-ETag/ says that the status code should be 200. header("Cache-Control: no-store, im"); header("IM: feed"); } } $out = array_merge($out, $articles); header("Content-Type: application/rss+xml; charset=utf-8"); if (isset($etag)) { header('ETag: "' . $etag . '"'); } return '<?xml version="1.0" encoding="utf-8"?>' . n . '<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom">' . n . tag(join(n, $out), 'channel') . n . '</rss>'; }
the_post(); ?> <h1 class="page-title"><?php printf(__('Posts by: <a href="%s">%s</a>', 'carrington-blog'), get_author_posts_url($authordata->ID), get_author_name($authordata->ID)); ?> </h1> <?php if (!empty($bio)) { ?> <div class="description author-bio"> <h2><?php printf(__('About %s', 'carrington-blog'), get_author_name($authordata->ID)); ?> </h2> <?php echo cfct_basic_content_formatting(get_the_author_description()); ?> </div> <?php } break; } } rewind_posts();
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) : ' ', 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); } }
/** * Display the links to the extra feeds such as category feeds. * * @since 2.8.0 * * @param array $args Optional arguments. */ function feed_links_extra($args) { $defaults = array('seperator' => _c('»|Seperator character for feed titles in theme head'), 'singletitle' => __('%1$s %2$s %3$s Comments Feed'), 'cattitle' => __('%1$s %2$s %3$s Category Feed'), 'tagtitle' => __('%1$s %2$s %3$s Tag Feed'), 'authortitle' => __('%1$s %2$s Posts by %3$s Feed'), 'searchtitle' => __('%1$s %2$s Search Results for "%3$s" Feed')); $args = wp_parse_args($args, $defaults); if (is_single() || is_page()) { $post =& get_post($id = 0); if (comments_open() || pings_open() || $post->comment_count > 0) { $title = attribute_escape(sprintf($args['singletitle'], get_bloginfo('name'), $args['seperator'], wp_specialchars(get_the_title()))); $href = get_post_comments_feed_link($post->ID); } } elseif (is_category()) { $cat_id = intval(get_query_var('cat')); $title = attribute_escape(sprintf($args['cattitle'], get_bloginfo('name'), $args['seperator'], get_cat_name($cat_id))); $href = get_category_feed_link($cat_id); } elseif (is_tag()) { $tag_id = intval(get_query_var('tag_id')); $tag = get_tag($tag_id); $title = attribute_escape(sprintf($args['tagtitle'], get_bloginfo('name'), $args['seperator'], $tag->name)); $href = get_tag_feed_link($tag_id); } elseif (is_author()) { $author_id = intval(get_query_var('author')); $title = attribute_escape(sprintf($args['authortitle'], get_bloginfo('name'), $args['seperator'], get_author_name($author_id))); $href = get_author_feed_link($author_id); } elseif (is_search()) { $title = attribute_escape(sprintf($args['searchtitle'], get_bloginfo('name'), $args['seperator'], get_search_query())); $href = get_search_feed_link(); } if (isset($title) && isset($href)) { echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . $title . '" href="' . $href . '" />' . "\n"; } }
function bloggergetrecentposts($m) { global $wpdb; error_reporting(0); $blog_ID = $m->getParam(1); $username = $m->getParam(2); $password = $m->getParam(3); $numposts = $m->getParam(4); $blog_ID = $blog_ID->scalarval(); $username = $username->scalarval(); $password = $password->scalarval(); $numposts = $numposts->scalarval(); if ($numposts > 0) { $limit = " LIMIT {$numposts}"; } else { $limit = ''; } if (user_pass_ok($username, $password)) { $sql = "SELECT * FROM " . wp_table('posts') . " ORDER BY post_date DESC" . $limit; $result = $wpdb->get_results($sql); if (!$result) { return new xmlrpcresp(0, $GLOBALS['xmlrpcerruser'] + 2, 'For some strange yet very annoying reason, the entries could not be fetched.'); } $data = new xmlrpcval('', 'array'); $i = 0; foreach ($result as $row) { $postdata = array('ID' => $row->ID, 'Author_ID' => $row->post_author, 'Date' => $row->post_date, 'Content' => $row->post_content, 'Title' => $row->post_title ? $row->post_title : ' ', 'Category' => $row->post_category); logIO('O', "Post Title: " . mb_conv($postdata['Title'], 'UTF-8', $GLOBALS['blog_charset'])); // Don't convert to GMT //$post_date = mysql2date('U', $postdata['Date']); $post_date = strtotime($postdata['Date']); $post_date = date('Ymd', $post_date) . 'T' . date('H:i:s', $post_date); $content = '<title>' . mb_conv($postdata['Title'], 'UTF-8', $GLOBALS['blog_charset']) . '</title>'; $content .= '<category>' . mb_conv(get_cat_name($postdata['Category']), 'UTF-8', $GLOBALS['blog_charset']) . '</category>'; $content .= mb_conv($postdata['Content'], 'UTF-8', $GLOBALS['blog_charset']); $category = new xmlrpcval($postdata['Category']); $authorname = get_author_name($postdata['Author_ID']); $struct[$i] = new xmlrpcval(array('authorName' => new xmlrpcval(mb_conv($authorname, 'UTF-8', $GLOBALS['blog_charset'])), 'userid' => new xmlrpcval($postdata['Author_ID']), 'dateCreated' => new xmlrpcval($post_date, 'dateTime.iso8601'), 'content' => new xmlrpcval($content), 'postid' => new xmlrpcval($postdata['ID']), 'category' => $category), 'struct'); $i = $i + 1; } $data = array($struct[0]); for ($j = 1; $j < $i; $j++) { array_push($data, $struct[$j]); } $resp = new xmlrpcval($data, 'array'); return new xmlrpcresp($resp); } else { return new xmlrpcresp(0, $GLOBALS['xmlrpcerruser'] + 3, 'Wrong username/password combination ' . $username . ' / ' . starify($password)); } }
function list_list($message = '', $post = '') { global $statuses, $comments_disabled_after, $step, $txp_user, $article_list_pageby; pagetop(gTxt('tab_list'), $message); extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method'))); $sesutats = array_flip($statuses); $dir = $dir == 'asc' ? 'asc' : 'desc'; switch ($sort) { case 'id': $sort_sql = 'ID ' . $dir; break; case 'expires': $sort_sql = 'Expires ' . $dir; break; case 'title': $sort_sql = 'Title ' . $dir . ', Posted desc'; break; case 'section': $sort_sql = 'Section ' . $dir . ', Posted desc'; break; case 'category1': $sort_sql = 'Category1 ' . $dir . ', Posted desc'; break; case 'category2': $sort_sql = 'Category2 ' . $dir . ', Posted desc'; break; case 'status': $sort_sql = 'Status ' . $dir . ', Posted desc'; break; case 'author': $sort_sql = 'AuthorID ' . $dir . ', Posted desc'; break; case 'comments': $sort_sql = 'comments_count ' . $dir . ', Posted desc'; break; case 'lastmod': $sort_sql = 'LastMod ' . $dir . ', Posted desc'; break; default: $sort = 'posted'; $sort_sql = 'Posted ' . $dir; break; } $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)) . "')", 'title_body_excerpt' => "Title rlike '{$crit_escaped}' or Body rlike '{$crit_escaped}' or Excerpt rlike '{$crit_escaped}'", 'section' => "Section rlike '{$crit_escaped}'", 'keywords' => "FIND_IN_SET('" . $crit_escaped . "',Keywords)", 'categories' => "Category1 rlike '{$crit_escaped}' or Category2 rlike '{$crit_escaped}'", 'status' => "Status = '" . @$sesutats[gTxt($crit_escaped)] . "'", 'author' => "AuthorID rlike '{$crit_escaped}'", 'article_image' => "Image in ('" . join("','", do_list($crit_escaped)) . "')", 'posted' => "Posted like '{$crit_escaped}%'", 'lastmod' => "LastMod 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('textpattern', "{$criteria}"); if ($total < 1) { if ($criteria != 1) { echo n . list_search_form($crit, $search_method) . n . graf(gTxt('no_results_found'), ' class="indicator"'); } else { echo graf(gTxt('no_articles_recorded'), ' class="indicator"'); } return; } $limit = max($article_list_pageby, 15); list($page, $offset, $numPages) = pager($total, $limit, $page); echo n . list_search_form($crit, $search_method); $rs = safe_rows_start('*, unix_timestamp(Posted) as posted, unix_timestamp(LastMod) as lastmod, unix_timestamp(Expires) as expires', 'textpattern', "{$criteria} order by {$sort_sql} limit {$offset}, {$limit}"); if ($rs) { $total_comments = array(); // fetch true comment count, not the public comment count // maybe we should have another row in the db? $rs2 = safe_rows_start('parentid, count(*) as num', 'txp_discuss', "1 group by parentid order by parentid"); if ($rs2) { while ($a = nextRow($rs2)) { $pid = $a['parentid']; $num = $a['num']; $total_comments[$pid] = $num; } } echo n . n . '<form name="longform" method="post" action="index.php" onsubmit="return verify(\'' . gTxt('are_you_sure') . '\')">' . n . startTable('list', '', '', '', '90%') . n . tr(n . column_head('ID', 'id', 'list', true, $switch_dir, $crit, $search_method, 'id' == $sort ? $dir : '') . column_head('posted', 'posted', 'list', true, $switch_dir, $crit, $search_method, 'posted' == $sort ? $dir : '') . column_head('article_modified', 'lastmod', 'list', true, $switch_dir, $crit, $search_method, ('lastmod' == $sort ? "{$dir} " : '') . 'articles_detail') . column_head('expires', 'expires', 'list', true, $switch_dir, $crit, $search_method, ('expires' == $sort ? "{$dir} " : '') . 'articles_detail') . column_head('title', 'title', 'list', true, $switch_dir, $crit, $search_method, 'title' == $sort ? $dir : '') . column_head('section', 'section', 'list', true, $switch_dir, $crit, $search_method, 'section' == $sort ? $dir : '') . column_head('category1', 'category1', 'list', true, $switch_dir, $crit, $search_method, ('category1' == $sort ? "{$dir} " : '') . 'articles_detail') . column_head('category2', 'category2', 'list', true, $switch_dir, $crit, $search_method, ('category2' == $sort ? "{$dir} " : '') . 'articles_detail') . column_head('status', 'status', 'list', true, $switch_dir, $crit, $search_method, 'status' == $sort ? $dir : '') . column_head('author', 'author', 'list', true, $switch_dir, $crit, $search_method, 'author' == $sort ? $dir : '') . column_head('comments', 'comments', 'list', true, $switch_dir, $crit, $search_method, ('comments' == $sort ? "{$dir} " : '') . 'articles_detail') . hCell()); include_once txpath . '/publish/taghandlers.php'; while ($a = nextRow($rs)) { extract($a); if (empty($Title)) { $Title = '<em>' . eLink('article', 'edit', 'ID', $ID, gTxt('untitled')) . '</em>'; } else { $Title = eLink('article', 'edit', 'ID', $ID, $Title); } $Category1 = $Category1 ? '<span title="' . htmlspecialchars(fetch_category_title($Category1)) . '">' . $Category1 . '</span>' : ''; $Category2 = $Category2 ? '<span title="' . htmlspecialchars(fetch_category_title($Category2)) . '">' . $Category2 . '</span>' : ''; $view_url = permlinkurl($a); if ($Status != 4 and $Status != 5) { $view_url .= (strpos($view_url, '?') === FALSE ? '?' : '&') . 'txpreview=' . intval($ID) . '.' . time(); } $manage = n . '<ul class="articles_detail">' . n . t . '<li>' . eLink('article', 'edit', 'ID', $ID, gTxt('edit')) . '</li>' . n . t . '<li><a href="' . $view_url . '" class="article-view">' . gTxt('view') . '</a></li>' . n . '</ul>'; $Status = !empty($Status) ? $statuses[$Status] : ''; $comments = gTxt('none'); if (isset($total_comments[$ID]) and $total_comments[$ID] > 0) { $comments = href(gTxt('manage'), 'index.php?event=discuss' . a . 'step=list' . a . 'search_method=parent' . a . 'crit=' . $ID) . ' (' . $total_comments[$ID] . ')'; } $comment_status = $Annotate ? gTxt('on') : gTxt('off'); if ($comments_disabled_after) { $lifespan = $comments_disabled_after * 86400; $time_since = time() - $posted; if ($time_since > $lifespan) { $comment_status = gTxt('expired'); } } $comments = n . '<ul>' . n . t . '<li>' . $comment_status . '</li>' . n . t . '<li>' . $comments . '</li>' . n . '</ul>'; echo n . n . tr(n . td(eLink('article', 'edit', 'ID', $ID, $ID) . $manage) . td(gTime($posted), '', $posted < time() ? '' : 'unpublished') . td(gTime($lastmod), '', "articles_detail") . td($expires ? gTime($expires) : '', '', 'articles_detail') . td($Title) . td('<span title="' . htmlspecialchars(fetch_section_title($Section)) . '">' . $Section . '</span>', 75) . td($Category1, 100, "articles_detail") . td($Category2, 100, "articles_detail") . td($a['Status'] < 4 ? $Status : '<a href="' . permlinkurl($a) . '">' . $Status . '</a>', 50) . td('<span title="' . htmlspecialchars(get_author_name($AuthorID)) . '">' . htmlspecialchars($AuthorID) . '</span>') . td($comments, 50, "articles_detail") . td(($a['Status'] >= 4 and has_privs('article.edit.published') or $a['Status'] >= 4 and $AuthorID == $txp_user and has_privs('article.edit.own.published') or $a['Status'] < 4 and has_privs('article.edit') or $a['Status'] < 4 and $AuthorID == $txp_user and has_privs('article.edit.own')) ? fInput('checkbox', 'selected[]', $ID) : ' ')); } echo n . n . tr(tda(toggle_box('articles_detail'), ' colspan="2" style="text-align: left; border: none;"') . tda(select_buttons() . list_multiedit_form($page, $sort, $dir, $crit, $search_method), ' colspan="9" style="text-align: right; border: none;"')) . n . endTable() . n . '</form>' . n . nav_form('list', $page, $numPages, $sort, $dir, $crit, $search_method, $total, $limit) . n . pageby_form('list', $article_list_pageby); } }
function preText($s, $prefs) { extract($prefs); if (gps('rss')) { include txpath . '/publish/rss.php'; exit(rss()); } if (gps('atom')) { include txpath . '/publish/atom.php'; exit(atom()); } // set messy variables $out = makeOut('id', 's', 'c', 'q', 'pg', 'p', 'month'); // if messy vars exist, bypass url parsing if (!$out['id'] && !$out['s']) { // define the useable url, minus any subdirectories. // this is pretty fugly, if anyone wants to have a go at it - dean $subpath = preg_quote(preg_replace("/http:\\/\\/.*(\\/.*)/Ui", "\$1", hu), "/"); $req = preg_replace("/^{$subpath}/i", "/", serverSet('REQUEST_URI')); extract(chopUrl($req)); //first we sniff out some of the preset url schemes if (!empty($u1)) { switch ($u1) { case 'atom': include txpath . '/publish/atom.php'; exit(atom()); case 'rss': include txpath . '/publish/rss.php'; exit(rss()); case strtolower(gTxt('section')): $out['s'] = ckEx('section', $u2) ? $u2 : 'default'; break; case strtolower(gTxt('category')): $out['c'] = ckEx('category', $u2) ? $u2 : ''; break; case urlencode(strtolower(gTxt('author'))): $author_name = !empty($u2) ? urldecode($u2) : ''; $out['author'] = safe_field('name', 'txp_users', "RealName like '{$author_name}'"); break; case strtolower(gTxt('file_download')): $out['s'] = 'file_download'; $out['id'] = !empty($u2) ? $u2 : ''; break; case 'p': $out['p'] = is_numeric($u2) ? $u2 : ''; break; default: // then see if the prefs-defined permlink scheme is usable switch ($permlink_mode) { case 'section_id_title': $out['s'] = ckEx('section', $u1) ? $u1 : 'default'; $out['id'] = is_numeric($u2) && ckExID($u2) ? $u2 : ''; break; case 'year_month_day_title': if (empty($u4)) { $out['month'] = "{$u1}-{$u2}"; if (!empty($u3)) { $out['month'] .= "-{$u3}"; } $out['s'] = 'default'; } else { $when = date("Y-m-d", strtotime("{$u1}-{$u2}-{$u3}") + $timeoffset); $rs = lookupByDateTitle($when, $u4); $out['id'] = !empty($rs['ID']) ? $rs['ID'] : ''; $out['s'] = !empty($rs['Section']) ? $rs['Section'] : ''; } break; case 'section_title': $rs = lookupByTitleSection($u2, $u1); $out['id'] = !empty($rs['ID']) ? $rs['ID'] : ''; $out['s'] = ckEx('section', $u1) ? $u1 : 'default'; break; case 'title_only': $rs = lookupByTitle($u1); $out['id'] = !empty($rs['ID']) ? $rs['ID'] : ''; $out['s'] = !empty($rs['Section']) ? $rs['Section'] : ckEx('section', $u1) ? $u1 : 'default'; break; case 'id_title': if (is_numeric($u1) && ckExID($u1)) { $rs = lookupByID($u1); $out['id'] = !empty($rs['ID']) ? $rs['ID'] : ''; $out['s'] = !empty($rs['Section']) ? $rs['Section'] : 'default'; } else { # We don't want to miss the /section/ pages $out['s'] = ckEx('section', $u1) ? $u1 : 'default'; } break; } } } else { $out['s'] = 'default'; } } else { // Messy mode, but prevent to get the id for file_downloads if ($out['id'] && !$out['s']) { $out['s'] = safe_field('section', 'textpattern', "ID='" . doSlash($out['id']) . "'"); } } if ($out['s'] == 'file_download') { // get id of potential filename if (!is_numeric($out['id'])) { $rs = safe_row("*", "txp_file", "filename='" . $out['id'] . "'"); } else { $rs = safe_row("*", "txp_file", "id='" . $out['id'] . "'"); } $out = $rs ? array_merge($out, $rs) : array('s' => 'file_download', 'file_error' => 404); return $out; } $out['s'] = empty($out['s']) ? 'default' : $out['s']; $s = $out['s']; $id = $out['id']; // hackish if (empty($id)) { $GLOBALS['is_article_list'] = true; } // by this point we should know the section, so grab its page and css $rs = safe_row("*", "txp_section", "name = '{$s}' limit 1"); $out['page'] = @$rs['page']; $out['css'] = @$rs['css']; if (is_numeric($id)) { $idrs = safe_row("Posted, AuthorID, Keywords", "textpattern", "ID={$id}"); extract($idrs); if ($np = getNextPrev($id, $Posted, $s)) { $out = array_merge($out, $np); } $out['id_keywords'] = $Keywords; $out['id_author'] = get_author_name($AuthorID); } $out['path_from_root'] = $path_from_root; // these are deprecated as of 1.0 $out['pfr'] = $path_from_root; // leaving them here for plugin compat $out['path_to_site'] = $path_to_site; $out['permlink_mode'] = $permlink_mode; $out['sitename'] = htmlspecialchars($sitename); return $out; }
/** * Generates and outputs an Atom feed. * * This function can only be called once on a page. It outputs an Atom feed * based on the requested URL parameters. Accepts HTTP GET parameters 'limit', * 'area', 'section' and 'category'. */ function atom() { global $thisarticle, $prefs; set_error_handler('feedErrorHandler'); ob_clean(); extract($prefs); $last = fetch("UNIX_TIMESTAMP(val)", 'txp_prefs', 'name', 'lastmod'); extract(doSlash(gpsa(array('limit', 'area')))); // Build filter criteria from a comma-separated list of sections // and categories. $feed_filter_limit = get_pref('feed_filter_limit', 10); $section = gps('section'); $category = gps('category'); if (!is_scalar($section) || !is_scalar($category)) { txp_die('Not Found', 404); } $section = $section ? array_slice(do_list_unique($section), 0, $feed_filter_limit) : array(); $category = $category ? array_slice(do_list_unique($category), 0, $feed_filter_limit) : array(); $st = array(); foreach ($section as $s) { $st[] = fetch_section_title($s); } $ct = array(); foreach ($category as $c) { $ct[] = fetch_category_title($c); } $sitename .= $section ? ' - ' . join(' - ', $st) : ''; $sitename .= $category ? ' - ' . join(' - ', $ct) : ''; $pub = safe_row("RealName, email", 'txp_users', "privs = 1"); // Feed header. $out[] = tag(htmlspecialchars($sitename), 'title', t_text); $out[] = tag(htmlspecialchars($site_slogan), 'subtitle', t_text); $out[] = '<link' . r_relself . ' href="' . pagelinkurl(array('atom' => 1, 'area' => $area, 'section' => $section, 'category' => $category, 'limit' => $limit)) . '" />'; $out[] = '<link' . r_relalt . t_texthtml . ' href="' . hu . '" />'; // Atom feeds with mail or domain name. $dn = explode('/', $siteurl); $mail_or_domain = $use_mail_on_feeds_id ? eE($blog_mail_uid) : $dn[0]; $out[] = tag('tag:' . $mail_or_domain . ',' . $blog_time_uid . ':' . $blog_uid . ($section ? '/' . join(',', $section) : '') . ($category ? '/' . join(',', $category) : ''), 'id'); $out[] = tag('Textpattern', 'generator', ' uri="http://textpattern.com/" version="' . $version . '"'); $out[] = tag(safe_strftime("w3cdtf", $last), 'updated'); $auth[] = tag($pub['RealName'], 'name'); $auth[] = $include_email_atom ? tag(eE($pub['email']), 'email') : ''; $auth[] = tag(hu, 'uri'); $out[] = tag(n . t . t . join(n . t . t, $auth) . n, 'author'); $out[] = callback_event('atom_head'); // Feed items. $articles = array(); $section = doSlash($section); $category = doSlash($category); if (!$area or $area == 'article') { $sfilter = !empty($section) ? "AND Section IN ('" . join("','", $section) . "')" : ''; $cfilter = !empty($category) ? "AND (Category1 IN ('" . join("','", $category) . "') OR Category2 IN ('" . join("','", $category) . "'))" : ''; $limit = $limit ? $limit : $rss_how_many; $limit = intval(min($limit, max(100, $rss_how_many))); $frs = safe_column("name", 'txp_section', "in_rss != '1'"); $query = array(); foreach ($frs as $f) { $query[] = "AND Section != '" . doSlash($f) . "'"; } $query[] = $sfilter; $query[] = $cfilter; $expired = $publish_expired_articles ? " " : " AND (" . now('expires') . " <= Expires OR Expires = " . NULLDATETIME . ") "; $rs = safe_rows_start("*,\n ID AS thisid,\n UNIX_TIMESTAMP(Posted) AS uPosted,\n UNIX_TIMESTAMP(Expires) AS uExpires,\n UNIX_TIMESTAMP(LastMod) AS uLastMod", 'textpattern', "Status = 4 AND Posted <= " . now('posted') . $expired . join(' ', $query) . "ORDER BY Posted DESC LIMIT {$limit}"); if ($rs) { while ($a = nextRow($rs)) { extract($a); populateArticleData($a); $cb = callback_event('atom_entry'); $e = array(); $a['posted'] = $uPosted; $a['expires'] = $uExpires; if ($show_comment_count_in_feed) { $count = $comments_count > 0 ? ' [' . $comments_count . ']' : ''; } else { $count = ''; } $thisauthor = get_author_name($AuthorID); $e['thisauthor'] = tag(n . t . t . t . tag(htmlspecialchars($thisauthor), 'name') . n . t . t, 'author'); $e['issued'] = tag(safe_strftime('w3cdtf', $uPosted), 'published'); $e['modified'] = tag(safe_strftime('w3cdtf', $uLastMod), 'updated'); $escaped_title = htmlspecialchars($Title); $e['title'] = tag($escaped_title . $count, 'title', t_html); $permlink = permlinkurl($a); $e['link'] = '<link' . r_relalt . t_texthtml . ' href="' . $permlink . '" />'; $e['id'] = tag('tag:' . $mail_or_domain . ',' . $feed_time . ':' . $blog_uid . '/' . $uid, 'id'); $e['category1'] = trim($Category1) ? '<category term="' . htmlspecialchars($Category1) . '" />' : ''; $e['category2'] = trim($Category2) ? '<category term="' . htmlspecialchars($Category2) . '" />' : ''; $summary = trim(replace_relative_urls(parse($thisarticle['excerpt']), $permlink)); $content = trim(replace_relative_urls(parse($thisarticle['body']), $permlink)); if ($syndicate_body_or_excerpt) { // Short feed: use body as summary if there's no excerpt. if (!trim($summary)) { $summary = $content; } $content = ''; } if (trim($content)) { $e['content'] = tag(n . escape_cdata($content) . n, 'content', t_html); } if (trim($summary)) { $e['summary'] = tag(n . escape_cdata($summary) . n, 'summary', t_html); } $articles[$ID] = tag(n . t . t . join(n . t . t, $e) . n . $cb, 'entry'); $etags[$ID] = strtoupper(dechex(crc32($articles[$ID]))); $dates[$ID] = $uLastMod; } } } elseif ($area == 'link') { $cfilter = $category ? "category in ('" . join("','", $category) . "')" : '1'; $limit = $limit ? $limit : $rss_how_many; $limit = intval(min($limit, max(100, $rss_how_many))); $rs = safe_rows_start("*", 'txp_link', "{$cfilter} ORDER BY date DESC, id DESC LIMIT {$limit}"); if ($rs) { while ($a = nextRow($rs)) { extract($a); $e['title'] = tag(htmlspecialchars($linkname), 'title', t_html); $e['content'] = tag(n . htmlspecialchars($description) . n, 'content', t_html); $url = preg_replace("/^\\/(.*)/", "https?://{$siteurl}/\$1", $url); $url = preg_replace("/&((?U).*)=/", "&\\1=", $url); $e['link'] = '<link' . r_relalt . t_texthtml . ' href="' . $url . '" />'; $e['issued'] = tag(safe_strftime('w3cdtf', strtotime($date)), 'published'); $e['modified'] = tag(gmdate('Y-m-d\\TH:i:s\\Z', strtotime($date)), 'updated'); $e['id'] = tag('tag:' . $mail_or_domain . ',' . safe_strftime('%Y-%m-%d', strtotime($date)) . ':' . $blog_uid . '/' . $id, 'id'); $articles[$id] = tag(n . t . t . join(n . t . t, $e) . n, 'entry'); $etags[$id] = strtoupper(dechex(crc32($articles[$id]))); $dates[$id] = $date; } } } if (!$articles) { if ($section) { if (safe_field("name", 'txp_section', "name IN ('" . join("','", $section) . "')") == false) { txp_die(gTxt('404_not_found'), '404'); } } elseif ($category) { switch ($area) { case 'link': if (safe_field("id", 'txp_category', "name = '{$category}' AND type = 'link'") == false) { txp_die(gTxt('404_not_found'), '404'); } break; case 'article': default: if (safe_field("id", 'txp_category', "name IN ('" . join("','", $category) . "') AND type = 'article'") == false) { txp_die(gTxt('404_not_found'), '404'); } break; } } } else { // Turn on compression if we aren't using it already. if (extension_loaded('zlib') && ini_get("zlib.output_compression") == 0 && ini_get('output_handler') != 'ob_gzhandler' && !headers_sent()) { // Make sure notices/warnings/errors don't fudge up the feed when // compression is used. $buf = ''; while ($b = @ob_get_clean()) { $buf .= $b; } @ob_start('ob_gzhandler'); echo $buf; } handle_lastmod(); $hims = serverset('HTTP_IF_MODIFIED_SINCE'); $imsd = $hims ? strtotime($hims) : 0; if (is_callable('apache_request_headers')) { $headers = apache_request_headers(); if (isset($headers["A-IM"])) { $canaim = strpos($headers["A-IM"], "feed"); } else { $canaim = false; } } else { $canaim = false; } $hinm = stripslashes(serverset('HTTP_IF_NONE_MATCH')); $cutarticles = false; if ($canaim !== false) { foreach ($articles as $id => $thing) { if (strpos($hinm, $etags[$id])) { unset($articles[$id]); $cutarticles = true; $cut_etag = true; } if ($dates[$id] < $imsd) { unset($articles[$id]); $cutarticles = true; $cut_time = true; } } } if (isset($cut_etag) && isset($cut_time)) { header("Vary: If-None-Match, If-Modified-Since"); } elseif (isset($cut_etag)) { header("Vary: If-None-Match"); } elseif (isset($cut_time)) { header("Vary: If-Modified-Since"); } $etag = @join("-", $etags); if (strstr($hinm, $etag)) { txp_status_header('304 Not Modified'); exit(0); } if ($etag) { header('ETag: "' . $etag . '"'); } if ($cutarticles) { // header("HTTP/1.1 226 IM Used"); // This should be used as opposed to 200, but Apache doesn't like it. // http://intertwingly.net/blog/2004/09/11/Vary-ETag/ says that the // status code should be 200. header("Cache-Control: no-store, im"); header("IM: feed"); } } $out = array_merge($out, $articles); header('Content-type: application/atom+xml; charset=utf-8'); return chr(60) . '?xml version="1.0" encoding="UTF-8"?' . chr(62) . n . '<feed xml:lang="' . txpspecialchars($language) . '" xmlns="http://www.w3.org/2005/Atom">' . join(n, $out) . '</feed>'; }
function image_list($message = '') { global $txpcfg, $extensions, $img_dir, $file_max_upload_size, $image_list_pageby, $txp_user, $event; pagetop(gTxt('tab_image'), $message); extract($txpcfg); extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method'))); if ($sort === '') { $sort = get_pref('image_sort_column', 'id'); } if ($dir === '') { $dir = get_pref('image_sort_dir', 'desc'); } $dir = $dir == 'asc' ? 'asc' : 'desc'; echo hed(gTxt('tab_image'), 1, array('class' => 'txp-heading')); echo n . '<div id="' . $event . '_control" class="txp-control-panel">'; if (!is_dir(IMPATH) or !is_writeable(IMPATH)) { echo graf(span(null, array('class' => 'ui-icon ui-icon-alert')) . ' ' . gTxt('img_dir_not_writeable', array('{imgdir}' => IMPATH)), array('class' => 'alert-block warning')); } elseif (has_privs('image.edit.own')) { echo upload_form(gTxt('upload_image'), 'upload_image', 'image_insert', 'image', '', $file_max_upload_size); } switch ($sort) { case 'name': $sort_sql = 'name ' . $dir; break; case 'thumbnail': $sort_sql = 'thumbnail ' . $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 = 'id'; $sort_sql = 'id ' . $dir; break; } set_pref('image_sort_column', $sort, 'image', 2, '', 0, PREF_PRIVATE); set_pref('image_sort_dir', $dir, 'image', 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' => "ID in ('" . join("','", do_list($crit_escaped)) . "')", 'name' => "name = '{$crit_escaped}'", 'category' => "category = '{$crit_escaped}'", 'author' => "author = '{$crit_escaped}'", 'alt' => "alt = '{$crit_escaped}'", 'caption' => "caption = '{$crit_escaped}'") : array('id' => "ID in ('" . join("','", do_list($crit_escaped)) . "')", 'name' => "name like '%{$crit_escaped}%'", 'category' => "category like '%{$crit_escaped}%'", 'author' => "author like '%{$crit_escaped}%'", 'alt' => "alt like '%{$crit_escaped}%'", 'caption' => "caption like '%{$crit_escaped}%'"); if (array_key_exists($search_method, $critsql)) { $criteria = $critsql[$search_method]; $limit = 500; } else { $search_method = ''; $crit = ''; } } else { $search_method = ''; $crit = ''; } $criteria .= callback_event('admin_criteria', 'image_list', 0, $criteria); $total = safe_count('txp_image', "{$criteria}"); if ($total < 1) { if ($criteria != 1) { echo n . image_search_form($crit, $search_method) . graf(gTxt('no_results_found'), ' class="indicator"') . '</div>'; } else { echo graf(gTxt('no_images_recorded'), ' class="indicator"') . '</div>'; } return; } $limit = max($image_list_pageby, 15); list($page, $offset, $numPages) = pager($total, $limit, $page); echo image_search_form($crit, $search_method); $rs = safe_rows_start('*, unix_timestamp(date) as uDate', 'txp_image', "{$criteria} order by {$sort_sql} limit {$offset}, {$limit}\n "); echo pluggable_ui('image_ui', 'extend_controls', '', $rs); echo '</div>'; // End txp-control-panel. if ($rs) { $show_authors = !has_single_author('txp_image'); echo n . tag_start('div', array('id' => $event . '_container', 'class' => 'txp-container')) . n . tag_start('form', array('action' => 'index.php', 'id' => 'images_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(hCell(fInput('checkbox', 'select_all', 0, '', '', '', '', '', 'select_all'), '', ' scope="col" title="' . gTxt('toggle_all_selected') . '" class="txp-list-col-multi-edit"') . column_head('ID', 'id', 'image', true, $switch_dir, $crit, $search_method, ('id' == $sort ? "{$dir} " : '') . 'txp-list-col-id') . column_head('name', 'name', 'image', true, $switch_dir, $crit, $search_method, ('name' == $sort ? "{$dir} " : '') . 'txp-list-col-name') . column_head('date', 'date', 'image', true, $switch_dir, $crit, $search_method, ('date' == $sort ? "{$dir} " : '') . 'txp-list-col-created date images_detail') . column_head('thumbnail', 'thumbnail', 'image', true, $switch_dir, $crit, $search_method, ('thumbnail' == $sort ? "{$dir} " : '') . 'txp-list-col-thumbnail') . hCell(gTxt('tags'), '', ' scope="col" class="txp-list-col-tag-build images_detail"') . column_head('image_category', 'category', 'image', true, $switch_dir, $crit, $search_method, ('category' == $sort ? "{$dir} " : '') . 'txp-list-col-category category') . ($show_authors ? column_head('author', 'author', 'image', true, $switch_dir, $crit, $search_method, ('author' == $sort ? "{$dir} " : '') . 'txp-list-col-author name') : '')) . n . tag_end('thead') . n . tag_start('tbody'); $validator = new Validator(); while ($a = nextRow($rs)) { extract($a); $edit_url = array('event' => 'image', 'step' => 'image_edit', 'id' => $id, 'sort' => $sort, 'dir' => $dir, 'page' => $page, 'search_method' => $search_method, 'crit' => $crit); $name = empty($name) ? gTxt('unnamed') : txpspecialchars($name); if ($thumbnail) { if ($ext != '.swf') { $thumbnail = '<img class="content-image" src="' . imagesrcurl($id, $ext, true) . "?{$uDate}" . '" alt="" ' . "title='{$id}{$ext} ({$w} × {$h})'" . ($thumb_w ? " width='{$thumb_w}' height='{$thumb_h}'" : '') . ' />'; } else { $thumbnail = ''; } } else { $thumbnail = gTxt('no'); } if ($ext != '.swf') { $tag_url = '?event=tag' . a . 'tag_name=image' . a . 'id=' . $id . a . 'ext=' . $ext . a . 'w=' . $w . a . 'h=' . $h . a . 'alt=' . urlencode($alt) . a . 'caption=' . urlencode($caption); $tagbuilder = href('Textile', $tag_url . a . 'type=textile', ' target="_blank" onclick="popWin(this.href); return false;"') . sp . span('|', array('role' => 'separator')) . sp . href('Textpattern', $tag_url . a . 'type=textpattern', ' target="_blank" onclick="popWin(this.href); return false;"') . sp . span('|', array('role' => 'separator')) . sp . href('HTML', $tag_url . a . 'type=html', ' target="_blank" onclick="popWin(this.href); return false;"'); } else { $tagbuilder = sp; } $validator->setConstraints(array(new CategoryConstraint($category, array('type' => 'image')))); $vc = $validator->validate() ? '' : ' error'; $category = $category ? span($category, array('title' => fetch_category_title($category, 'image'))) : ''; $can_edit = has_privs('image.edit') || $author === $txp_user && has_privs('image.edit.own'); echo tr(td($can_edit ? fInput('checkbox', 'selected[]', $id) : ' ', '', 'txp-list-col-multi-edit') . hCell(($can_edit ? href($id, $edit_url, array('title' => gTxt('edit'))) : $id) . sp . span(span('[', array('aria-hidden' => 'true')) . href(gTxt('view'), imagesrcurl($id, $ext)) . span(']', array('aria-hidden' => 'true')), array('class' => 'images_detail')), '', ' scope="row" class="txp-list-col-id"') . td($can_edit ? href($name, $edit_url, ' title="' . gTxt('edit') . '"') : $name, '', 'txp-list-col-name') . td(gTime($uDate), '', 'txp-list-col-created date images_detail') . td(pluggable_ui('image_ui', 'thumbnail', $can_edit ? href($thumbnail, $edit_url) : $thumbnail, $a), '', 'txp-list-col-thumbnail') . td($tagbuilder, '', 'txp-list-col-tag-build images_detail') . td($category, '', 'txp-list-col-category category' . $vc) . ($show_authors ? td(span(txpspecialchars($author), array('title' => get_author_name($author))), '', 'txp-list-col-author name') : '')); } echo n . tag_end('tbody') . n . tag_end('table') . n . tag_end('div') . image_multiedit_form($page, $sort, $dir, $crit, $search_method) . tInput() . n . tag_end('form') . graf(toggle_box('images_detail'), array('class' => 'detail-toggle')) . n . tag_start('div', array('id' => $event . '_navigation', 'class' => 'txp-navigation')) . pageby_form('image', $image_list_pageby) . nav_form('image', $page, $numPages, $sort, $dir, $crit, $search_method, $total, $limit) . n . tag_end('div') . n . tag_end('div'); } }
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>'; } }
function _b_wp_recent_posts_show($options, $wp_num = "") { $no_posts = empty($options[0]) ? 10 : $options[0]; $cat_date = empty($options[1]) ? 0 : $options[1]; $show_rss_icon = empty($options[2]) ? 0 : $options[2]; $show_rdf_icon = empty($options[3]) ? 0 : $options[3]; $show_rss2_icon = empty($options[4]) ? 0 : $options[4]; $show_atom_icon = empty($options[5]) ? 0 : $options[5]; $rss_num = empty($options[6]) ? "" : $options[6]; $category = intval(empty($options[7]) ? "all" : $options[7]); $new_flg = empty($options[8]) ? 0 : $options[8]; $tpl_file = empty($options[9]) ? 'wp_recent_posts.html' : $options[9]; $new1_span = 1 * 60 * 60 * 24; $new2_span = 7 * 60 * 60 * 24; if (empty($category) || $category == 'all' || $category == '0') { $whichcat = ''; $join = ''; $cat_param = ''; } else { $join = ' LEFT JOIN ' . wp_table('post2cat') . ' ON (' . wp_table('posts') . '.ID = ' . wp_table('post2cat') . '.post_id) '; $whichcat = ' AND (category_id = ' . $category . ')'; $cat_param = 'cat=' . $category; } $now = current_time('mysql'); $request = 'SELECT * FROM ' . wp_table('posts') . $join . ' WHERE post_status = \'publish\''; $request .= ' AND post_date <= \'' . $now . '\'' . $whichcat; $request .= ' ORDER BY post_date DESC LIMIT 0, ' . $no_posts; $lposts = $GLOBALS['wpdb']->get_results($request); $date = ""; $pdate = ""; $block['style'] = block_style_get(false); $block['divid'] = 'wpRecentPost' . $wp_num . '_' . $category; $block['cat_date'] = $cat_date; $block['records'] = array(); if ($lposts) { foreach ($lposts as $lpost) { if ($cat_date) { $date = mysql2date('Y-n-j', $lpost->post_date); if ($date != $pdate) { $_record['date'] = $date; $_record['pdate'] = $pdate; $pdate = $date; } else { $_record['date'] = ''; } } $_record['new'] = 0; $_record['newstr'] = ''; if ($new_flg) { $m = $lpost->post_date; $elapse = current_time('timestamp') - mktime(substr($m, 11, 2), substr($m, 14, 2), substr($m, 17, 2), substr($m, 5, 2), substr($m, 8, 2), substr($m, 0, 4)); if ($elapse < $new1_span) { $_record['new'] = 1; $_record['newstr'] = ' <span class="new1">New!</span>'; } else { if ($elapse < $new2_span) { $_record['new'] = 2; $_record['newstr'] = ' <span class="new2">New</span>'; } else { $_record['new'] = 0; $_record['newstr'] = ''; } } } $_record['post_title'] = htmlspecialchars($lpost->post_title); $_record['post_author'] = htmlspecialchars(get_author_name($lpost->post_author)); if (trim($_record['post_title']) == '') { $_record['post_title'] = _WP_POST_NOTITLE; } $_record['permalink'] = get_permalink($lpost->ID); $block['records'][] = $_record; } } $feed_param = $rss_num ? "?num=" . $rss_num : ""; $block['feed_icons'] = array(); if (empty($category) || $category == 'all' || $category == '0') { if ($show_rss_icon) { $block['feed_icons'][] = array('url' => get_bloginfo('rss_url') . $feed_param, 'icon' => wp_siteurl() . '/wp-images/rss.gif', 'alt' => 'rss'); } if ($show_rdf_icon) { $block['feed_icons'][] = array('url' => get_bloginfo('rdf_url') . $feed_param, 'icon' => wp_siteurl() . '/wp-images/rdf.gif', 'alt' => 'rdf'); } if ($show_rss2_icon) { $block['feed_icons'][] = array('url' => get_bloginfo('rss2_url') . $feed_param, 'icon' => wp_siteurl() . '/wp-images/rss2.gif', 'alt' => 'rss2'); } if ($show_atom_icon) { $block['feed_icons'][] = array('url' => get_bloginfo('atom_url') . $feed_param, 'icon' => wp_siteurl() . '/wp-images/atom.gif', 'alt' => 'atom'); } } else { if ($show_rss_icon) { $block['feed_icons'][] = array('url' => get_category_rss_link(false, $category, "", 'rss') . $feed_param, 'icon' => wp_siteurl() . '/wp-images/rss.gif', 'alt' => 'rss'); } if ($show_rdf_icon) { $block['feed_icons'][] = array('url' => get_category_rss_link(false, $category, "", 'rdf') . $feed_param, 'icon' => wp_siteurl() . '/wp-images/rdf.gif', 'alt' => 'rdf'); } if ($show_rss2_icon) { $block['feed_icons'][] = array('url' => get_category_rss_link(false, $category, "", 'rss2') . $feed_param, 'icon' => wp_siteurl() . '/wp-images/rss2.gif', 'alt' => 'rss2'); } if ($show_atom_icon) { $block['feed_icons'][] = array('url' => get_category_rss_link(false, $category, "", 'atom') . $feed_param, 'icon' => wp_siteurl() . '/wp-images/atom.gif', 'alt' => 'atom'); } } $_wpTpl =& new WordPresTpl('theme'); $_wpTpl->assign('block', $block); if (!$_wpTpl->tpl_exists($tpl_file)) { $tpl_file = 'wp_recent_posts.html'; } $block['content'] = $_wpTpl->fetch($tpl_file); return $block; }
$total_articles = !empty($articles) ? $articles[0]['total_found'] : 0; $total_pages = !empty($articles) ? $articles[0]['total_pages'] : 0; // per page - same definition as list_admin_articles() $per_page = !isset($_GET['per_page']) || empty($_GET['per_page']) ? 15 : (int) $_GET['per_page']; // sub header text $title_text = array(); $status = ''; // category if (isset($_GET['category_id'])) { $title_text[] = " filed under " . get_category_title($_GET['category_id']); $sub_header_text[] = get_category_title($_GET['category_id']); } // author if (isset($_GET['author_id'])) { $title_text[] = " by " . get_author_name($_GET['author_id']); $sub_header_text[] = 'author: ' . get_author_name($_GET['author_id']); } // tag if (isset($_GET['tag_id'])) { $title_text[] = " tagged " . get_tag_title($_GET['tag_id']); $sub_header_text[] = 'tag: ' . get_tag_title($_GET['tag_id']); } // postdated if (isset($_GET['postdated'])) { $status = ' postdated'; } // other statuses if (isset($_GET['status'])) { $status_list = define_article_status(); $status = ' ' . $status_list[$_GET['status']]; }
function link_list($message = '') { global $event, $step, $link_list_pageby, $txp_user; 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 '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) { $crit_escaped = doSlash(str_replace(array('\\', '%', '_', '\''), array('\\\\', '\\%', '\\_', '\\\''), $crit)); $critsql = array('id' => "ID in ('" . join("','", do_list($crit_escaped)) . "')", 'name' => "linkname 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]; } else { $search_method = ''; $crit = ''; } } else { $search_method = ''; $crit = ''; } $total = getCount('txp_link', $criteria); echo '<div id="' . $event . '_control" class="txp-control-panel">'; 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 class="txp-list">'; echo n . n . '<form action="index.php" id="links_form" method="post" name="longform" onsubmit="return verify(\'' . gTxt('are_you_sure') . '\')">', startTable('list', '', 'list') . n . '<thead>' . n . tr(column_head('ID', 'id', 'link', true, $switch_dir, $crit, $search_method, ('id' == $sort ? "{$dir} " : '') . 'id') . hCell('', '', ' class="actions"') . column_head('link_name', 'name', 'link', true, $switch_dir, $crit, $search_method, ('name' == $sort ? "{$dir} " : '') . 'name') . column_head('description', 'description', 'link', true, $switch_dir, $crit, $search_method, ('description' == $sort ? "{$dir} " : '') . 'description') . column_head('link_category', 'category', 'link', true, $switch_dir, $crit, $search_method, ('category' == $sort ? "{$dir} " : '') . 'category') . column_head('date', 'date', 'link', true, $switch_dir, $crit, $search_method, ('date' == $sort ? "{$dir} " : '') . 'date created') . ($show_authors ? column_head('author', 'author', 'link', true, $switch_dir, $crit, $search_method, ('author' == $sort ? "{$dir} " : '') . 'author') : '') . hCell('', '', ' class="multi-edit"')) . n . '</thead>'; $tfoot = n . '<tfoot>' . tr(tda(select_buttons() . link_multiedit_form($page, $sort, $dir, $crit, $search_method), ' class="multi-edit" colspan="' . ($show_authors ? '8' : '7') . '" style="text-align: right; border: none;"')) . n . '</tfoot>'; echo $tfoot; echo '<tbody>'; $ctr = 1; while ($a = nextRow($rs)) { extract($a); $edit_url = '?event=link' . a . 'step=link_edit' . a . 'id=' . $id . a . 'sort=' . $sort . a . 'dir=' . $dir . a . 'page=' . $page . a . 'search_method=' . $search_method . a . 'crit=' . $crit; $can_edit = has_privs('link.edit') || $author == $txp_user && has_privs('link.edit.own'); echo tr(n . td($id, 20, 'id') . td(n . '<ul>' . ($can_edit ? n . t . '<li class="action-edit">' . href(gTxt('edit'), $edit_url) . '</li>' : '') . n . t . '<li class="action-view">' . href(gTxt('view'), $url) . '</li>' . n . '</ul>', 35, 'actions') . td($can_edit ? href($linkname, $edit_url) : $linkname, 125, 'name') . td(htmlspecialchars($description), 150, 'description') . td('<span title="' . htmlspecialchars(fetch_category_title($category, 'link')) . '">' . $category . '</span>', 125, 'category') . td(gTime($uDate), 75, 'date created') . ($show_authors ? td('<span title="' . htmlspecialchars(get_author_name($author)) . '">' . htmlspecialchars($author) . '</span>', '', 'author') : '') . td(fInput('checkbox', 'selected[]', $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('link', $page, $numPages, $sort, $dir, $crit, $search_method, $total, $limit) . pageby_form('link', $link_list_pageby) . n . '</div>' . n . '</div>'; } }
function atom() { global $thisarticle; extract($GLOBALS['prefs']); define("t_texthtml", ' type="text/html"'); define("t_text", ' type="text"'); define("t_html", ' type="html"'); define("t_xhtml", ' type="xhtml"'); define('t_appxhtml', ' type="xhtml"'); define("r_relalt", ' rel="alternate"'); define("r_relself", ' rel="self"'); $area = doSlash(gps('area')); extract(doSlash(gpsa(array('category', 'section', 'limit')))); $last = fetch('unix_timestamp(val)', 'txp_prefs', 'name', 'lastmod'); $sitename .= $section ? ' - ' . $section : ''; $sitename .= $category ? ' - ' . $category : ''; $pub = safe_row("RealName, email", "txp_users", "privs=1"); $out[] = tag(escape_output($sitename), 'title', t_text); $out[] = tag(escape_output($site_slogan), 'subtitle', t_text); $out[] = '<link' . r_relself . ' href="' . pagelinkurl(array('atom' => 1, 'area' => $area, 'section' => $section, 'category' => $category, 'limit' => $limit)) . '" />'; $out[] = '<link' . r_relalt . t_texthtml . ' href="' . hu . '" />'; $articles = array(); //Atom feeds with mail or domain name $dn = explode('/', $siteurl); $mail_or_domain = $use_mail_on_feeds_id ? eE($blog_mail_uid) : $dn[0]; $out[] = tag('tag:' . $mail_or_domain . ',' . $blog_time_uid . ':' . $blog_uid . ($section ? '/' . $section : '') . ($category ? '/' . $category : ''), 'id'); $out[] = tag('Textpattern', 'generator', ' uri="http://textpattern.com/" version="' . $version . '"'); $out[] = tag(safe_strftime("w3cdtf", $last), 'updated'); $auth[] = tag($pub['RealName'], 'name'); $auth[] = $include_email_atom ? tag(eE($pub['email']), 'email') : ''; $auth[] = tag(hu, 'uri'); $out[] = tag(n . t . t . join(n . t . t, $auth) . n, 'author'); if (!$area or $area == 'article') { $sfilter = $section ? "and Section = '" . $section . "'" : ''; $cfilter = $category ? "and (Category1='" . $category . "' or Category2='" . $category . "')" : ''; $limit = $limit ? $limit : $rss_how_many; $limit = intval(min($limit, max(100, $rss_how_many))); $frs = safe_column("name", "txp_section", "in_rss != '1'"); $query = array(); foreach ($frs as $f) { $query[] = "and Section != '" . doSlash($f) . "'"; } $query[] = $sfilter; $query[] = $cfilter; $rs = safe_rows_start("*, \n\t\t\t\tID as thisid, \n\t\t\t\tunix_timestamp(Posted) as uPosted,\n\t\t\t\tunix_timestamp(LastMod) as uLastMod", "textpattern", "Status=4 and Posted <= now() " . join(' ', $query) . "order by Posted desc limit {$limit}"); if ($rs) { while ($a = nextRow($rs)) { extract($a); populateArticleData($a); $cb = callback_event('atom_entry'); $e = array(); $a['posted'] = $uPosted; if ($show_comment_count_in_feed) { $count = $comments_count > 0 ? ' [' . $comments_count . ']' : ''; } else { $count = ''; } $thisauthor = get_author_name($AuthorID); $e['thisauthor'] = tag(n . t . t . t . tag(htmlspecialchars($thisauthor), 'name') . n . t . t, 'author'); $e['issued'] = tag(safe_strftime('w3cdtf', $uPosted), 'published'); $e['modified'] = tag(safe_strftime('w3cdtf', $uLastMod), 'updated'); $escaped_title = escape_output($Title); $e['title'] = tag($escaped_title . $count, 'title', t_html); $permlink = permlinkurl($a); $e['link'] = '<link' . r_relalt . t_texthtml . ' href="' . $permlink . '" />'; $e['id'] = tag('tag:' . $mail_or_domain . ',' . $feed_time . ':' . $blog_uid . '/' . $uid, 'id'); $e['category1'] = trim($Category1) ? '<category term="' . htmlspecialchars($Category1) . '" />' : ''; $e['category2'] = trim($Category2) ? '<category term="' . htmlspecialchars($Category2) . '" />' : ''; $summary = trim(replace_relative_urls(parse($thisarticle['excerpt']), $permlink)); $content = trim(replace_relative_urls(parse($thisarticle['body']), $permlink)); if ($syndicate_body_or_excerpt) { # short feed: use body as summary if there's no excerpt if (!trim($summary)) { $summary = $content; } $content = ''; } if (trim($content)) { $e['content'] = tag(n . escape_cdata($content) . n, 'content', t_html); } if (trim($summary)) { $e['summary'] = tag(n . escape_cdata($summary) . n, 'summary', t_html); } $articles[$ID] = tag(n . t . t . join(n . t . t, $e) . n . $cb, 'entry'); $etags[$ID] = strtoupper(dechex(crc32($articles[$ID]))); $dates[$ID] = $uLastMod; } } } elseif ($area == 'link') { $cfilter = $category ? "category='" . $category . "'" : '1'; $limit = $limit ? $limit : $rss_how_many; $limit = intval(min($limit, max(100, $rss_how_many))); $rs = safe_rows_start("*", "txp_link", "{$cfilter} order by date desc, id desc limit {$limit}"); if ($rs) { while ($a = nextRow($rs)) { extract($a); $e['title'] = tag(htmlspecialchars($linkname), 'title', t_html); $e['content'] = tag(n . htmlspecialchars($description) . n, 'content', t_html); $url = preg_replace("/^\\/(.*)/", "https?://{$siteurl}/\$1", $url); $url = preg_replace("/&((?U).*)=/", "&\\1=", $url); $e['link'] = '<link' . r_relalt . t_texthtml . ' href="' . $url . '" />'; $e['issued'] = tag(safe_strftime('w3cdtf', strtotime($date)), 'published'); $e['modified'] = tag(gmdate('Y-m-d\\TH:i:s\\Z', strtotime($date)), 'updated'); $e['id'] = tag('tag:' . $mail_or_domain . ',' . $feed_time . ':' . $id, 'id'); $articles[$id] = tag(n . t . t . join(n . t . t, $e) . n, 'entry'); $etags[$id] = strtoupper(dechex(crc32($articles[$id]))); $dates[$id] = $date; } } } if (!empty($articles)) { //turn on compression if we aren't using it already if (extension_loaded('zlib') && ini_get("zlib.output_compression") == 0 && ini_get('output_handler') != 'ob_gzhandler' && !headers_sent()) { @ob_start("ob_gzhandler"); } handle_lastmod(); $hims = serverset('HTTP_IF_MODIFIED_SINCE'); $imsd = $hims ? strtotime($hims) : 0; if ($imsd >= $last) { txp_status_header("304 Not Modified"); exit; } header("Last-Modified: " . gmdate('D, d M Y H:i:s \\G\\M\\T', $last)); if (is_callable('apache_request_headers')) { $headers = apache_request_headers(); if (isset($headers["A-IM"])) { $canaim = strpos($headers["A-IM"], "feed"); } else { $canaim = false; } } else { $canaim = false; } $hinm = stripslashes(serverset('HTTP_IF_NONE_MATCH')); $cutarticles = false; if ($canaim !== false) { foreach ($articles as $id => $thing) { if (strpos($hinm, $etags[$id])) { unset($articles[$id]); $cutarticles = true; $cut_etag = true; } if ($dates[$id] < $imsd) { unset($articles[$id]); $cutarticles = true; $cut_time = true; } } } if (isset($cut_etag) && isset($cut_time)) { header("Vary: If-None-Match, If-Modified-Since"); } else { if (isset($cut_etag)) { header("Vary: If-None-Match"); } else { if (isset($cut_time)) { header("Vary: If-Modified-Since"); } } } $etag = @join("-", $etags); if (strstr($hinm, $etag)) { header("HTTP/1.1 304 Not Modified"); exit; } if ($etag) { header('ETag: "' . $etag . '"'); } if ($cutarticles) { //header("HTTP/1.1 226 IM Used"); //This should be used as opposed to 200, but Apache doesn't like it. //http://intertwingly.net/blog/2004/09/11/Vary-ETag/ says that the status code should be 200. header("Cache-Control: no-store, im"); header("IM: feed"); } $out = array_merge($out, $articles); header('Content-type: application/atom+xml; charset=utf-8'); return chr(60) . '?xml version="1.0" encoding="UTF-8"?' . chr(62) . n . '<feed xml:lang="' . $language . '" xmlns="http://www.w3.org/2005/Atom">' . join(n, $out) . '</feed>'; } }
function row($row) { global $prefs; extract($prefs); if (!$this->controller) { return; } extract($this->controller->context); extract($row); $event = $this->controller->event; $edit_url = "?event={$event}" . a . 'step=edit' . a . 'id=' . $id . a . 'sort=' . $sort . a . 'dir=' . $dir . a . 'page=' . $page . a . 'search_method=' . $search_method . a . 'crit=' . $crit; $name = empty($name) ? gTxt('unnamed') : htmlspecialchars($name); if ($thumbnail) { if ($ext != '.swf') { $thumbnail = '<img src="' . hu . $img_dir . '/' . $id . 't' . $ext . '" alt="" />'; } else { $thumbnail = ''; } } if ($ext != '.swf') { $tag_url = '?event=tag' . a . 'tag_name=image' . a . 'id=' . $id . a . 'ext=' . $ext . a . 'w=' . $w . a . 'h=' . $h . a . 'alt=' . urlencode($alt) . a . 'caption=' . urlencode($caption); $tagbuilder = '<ul>' . '<li><a target="_blank" href="' . $tag_url . a . 'type=textile" onclick="popWin(this.href); return false;">Textile</a></li>' . '<li><a target="_blank" href="' . $tag_url . a . 'type=textpattern" onclick="popWin(this.href); return false;">Textpattern</a></li>' . '<li><a target="_blank" href="' . $tag_url . a . 'type=xhtml" onclick="popWin(this.href); return false;">XHTML</a></li>' . '</ul>'; } else { $tagbuilder = sp; } $category = $category ? '<span title="' . htmlspecialchars(fetch_category_title($category, 'image')) . '">' . $category . '</span>' : ''; $tr = array(); $tr[] = $id; $tr[] = n . '<ul>' . n . t . '<li>' . href(gTxt('edit'), $edit_url) . '</li>' . n . t . '<li><a href="' . hu . $img_dir . '/' . $id . $ext . '">' . gTxt('view') . '</a></li>' . n . '</ul>'; $tr[] = gTime($uDate); $tr[] = href($name, $edit_url); $tr[] = $thumbnail; $tr[] = $tagbuilder; $tr[] = $category; $tr[] = '<span title="' . htmlspecialchars(get_author_name($author)) . '">' . $author . '</span>'; $tr[] = dLink($this->controller->event, 'delete', 'id', $id, '', '', '', false, array($page, $sort, $dir, $crit, $search_method)); if ($this->edit_actions and isset($row['id'])) { $tr[] = fInput('checkbox', 'selected[]', $row['id']); } return doWrap($tr, 'tr', 'td', 'row-' . (++$this->count % 2 ? 'odd' : 'even')); }
function delibera_get_quem_discordou($ID, $type = 'pauta', $return = 'array') { $discordaram = array(); if ($type == 'pauta') { $discordaram = get_post_meta($ID, 'delibera_discordaram', true); } else { $discordaram = get_comment_meta($ID, 'delibera_discordaram', true); } if (!is_array($discordaram)) { $discordaram = array(); } switch ($return) { case 'string': $ret = ''; foreach ($discordaram as $hora => $discordouem) { foreach ($discordouem as $discordou) { if (strlen($ret) > 0) { $ret .= ", "; } $ret .= $discordou['user'] == false || $discordou['user'] == 0 ? $discordou['ip'] : get_author_name($discordou['user']); } } return $ret; break; case 'array': default: return $discordaram; break; } }
function preText($s, $prefs) { extract($prefs); callback_event('pretext'); if (gps('rss')) { include txpath . '/publish/rss.php'; exit(rss()); } if (gps('atom')) { include txpath . '/publish/atom.php'; exit(atom()); } // set messy variables $out = makeOut('id', 's', 'c', 'q', 'pg', 'p', 'month', 'author'); // some useful vars for taghandlers, plugins $out['request_uri'] = serverSet('REQUEST_URI'); $out['qs'] = serverSet('QUERY_STRING'); // IIS - can someone confirm whether or not this works? if (!$out['request_uri'] and $argv = serverSet('argv')) { $out['request_uri'] = @substr($argv[0], strpos($argv[0], ';' + 1)); } // define the useable url, minus any subdirectories. // this is pretty fugly, if anyone wants to have a go at it - dean $out['subpath'] = $subpath = preg_quote(preg_replace("/http:\\/\\/.*(\\/.*)/Ui", "\$1", hu), "/"); $out['req'] = $req = preg_replace("/^{$subpath}/i", "/", serverSet('REQUEST_URI')); $is_404 = 0; // if messy vars exist, bypass url parsing if (!$out['id'] && !$out['s']) { extract(chopUrl($req)); //first we sniff out some of the preset url schemes if (!empty($u1)) { switch ($u1) { case 'atom': include txpath . '/publish/atom.php'; exit(atom()); case 'rss': include txpath . '/publish/rss.php'; exit(rss()); // urldecode(strtolower(urlencode())) looks ugly but is the only way to // make it multibyte-safe without breaking backwards-compatibility // urldecode(strtolower(urlencode())) looks ugly but is the only way to // make it multibyte-safe without breaking backwards-compatibility case urldecode(strtolower(urlencode(gTxt('section')))): $out['s'] = ckEx('section', $u2) ? $u2 : ''; break; case urldecode(strtolower(urlencode(gTxt('category')))): $out['c'] = ckEx('category', $u2) ? $u2 : ''; break; case urldecode(strtolower(urlencode(gTxt('author')))): $out['author'] = !empty($u2) ? $u2 : ''; break; // AuthorID gets resolved from Name further down // AuthorID gets resolved from Name further down case urldecode(strtolower(urlencode(gTxt('file_download')))): $out['s'] = 'file_download'; $out['id'] = !empty($u2) ? $u2 : ''; break; case 'p': $out['p'] = is_numeric($u2) ? $u2 : ''; break; default: // then see if the prefs-defined permlink scheme is usable switch ($permlink_mode) { case 'section_id_title': if (empty($u2)) { $out['s'] = ckEx('section', $u1) ? $u1 : ''; $is_404 = empty($out['s']); } else { $rs = ckExID($u2); $out['s'] = @$rs['Section']; $out['id'] = @$rs['ID']; $is_404 = (empty($out['s']) or empty($out['id'])); } break; case 'year_month_day_title': if (empty($u2)) { $out['s'] = ckEx('section', $u1) ? $u1 : ''; $is_404 = empty($out['s']); } elseif (empty($u4)) { $month = "{$u1}-{$u2}"; if (!empty($u3)) { $month .= "-{$u3}"; } if (preg_match('/\\d+-\\d+(?:-\\d+)?/', $month)) { $out['month'] = $month; $out['s'] = 'default'; } else { $is_404 = 1; } } else { $when = "{$u1}-{$u2}-{$u3}"; $rs = lookupByDateTitle($when, $u4); $out['id'] = !empty($rs['ID']) ? $rs['ID'] : ''; $out['s'] = !empty($rs['Section']) ? $rs['Section'] : ''; $is_404 = (empty($out['s']) or empty($out['id'])); } break; case 'section_title': if (empty($u2)) { $out['s'] = ckEx('section', $u1) ? $u1 : ''; $is_404 = empty($out['s']); } else { $rs = lookupByTitleSection($u2, $u1); $out['id'] = @$rs['ID']; $out['s'] = @$rs['Section']; $is_404 = (empty($out['s']) or empty($out['id'])); } break; case 'title_only': $rs = lookupByTitle($u1); $out['id'] = @$rs['ID']; $out['s'] = empty($rs['Section']) ? ckEx('section', $u1) : $rs['Section']; $is_404 = empty($out['s']); break; case 'id_title': if (is_numeric($u1) && ckExID($u1)) { $rs = lookupByID($u1); $out['id'] = !empty($rs['ID']) ? $rs['ID'] : ''; $out['s'] = !empty($rs['Section']) ? $rs['Section'] : ''; $is_404 = (empty($out['s']) or empty($out['id'])); } else { # We don't want to miss the /section/ pages $out['s'] = ckEx('section', $u1) ? $u1 : ''; $is_404 = empty($out['s']); } break; } } } else { $out['s'] = 'default'; } } else { // Messy mode, but prevent to get the id for file_downloads if ($out['id'] && !$out['s']) { $out['s'] = safe_field('section', 'textpattern', "ID='" . doSlash($out['id']) . "'"); } } // Resolve AuthorID from Authorname if ($out['author']) { $out['author'] = safe_field('name', 'txp_users', "RealName like '" . doSlash($out['author']) . "'"); } // Stats: found or not $out['status'] = $is_404 ? '404' : '200'; if ($out['s'] == 'file_download') { // get id of potential filename if (!is_numeric($out['id'])) { $rs = safe_row("*", "txp_file", "filename='" . doSlash($out['id']) . "'"); } else { $rs = safe_row("*", "txp_file", "id='" . intval($out['id']) . "'"); } $out = $rs ? array_merge($out, $rs) : array('s' => 'file_download', 'file_error' => 404); return $out; } if (!$is_404) { $out['s'] = empty($out['s']) ? 'default' : $out['s']; } $s = $out['s']; $id = $out['id']; // hackish if (empty($id)) { $GLOBALS['is_article_list'] = true; } // by this point we should know the section, so grab its page and css $rs = safe_row("*", "txp_section", "name = '" . doSlash($s) . "' limit 1"); $out['page'] = @$rs['page']; // Remove the below line if nothing breaks // $out['css'] = @$rs['css']; if (is_numeric($id)) { $idrs = safe_row("Posted, AuthorID, Keywords", "textpattern", "ID=" . doSlash($id)); extract($idrs); if ($np = getNextPrev($id, $Posted, $s)) { $out = array_merge($out, $np); } $out['id_keywords'] = $Keywords; $out['id_author'] = get_author_name($AuthorID); } $out['path_from_root'] = $path_from_root; // these are deprecated as of 1.0 $out['pfr'] = $path_from_root; // leaving them here for plugin compat $out['path_to_site'] = $path_to_site; $out['permlink_mode'] = $permlink_mode; $out['sitename'] = htmlspecialchars($sitename); return $out; }
function get_author($name) { $names = get_author_name(); $username = '******' . $name . '.ini'; $tmp = array(); if (!empty($names)) { foreach ($names as $index => $v) { $author = new stdClass(); // Replaced string $replaced = substr($v, 0, strrpos($v, '/')) . '/'; // Author string $str = explode('/', $replaced); $profile = $str[count($str) - 2]; if ($name === $profile) { // Profile URL $url = str_replace($replaced, '', $v); $author->url = site_url() . 'author/' . $profile; // Get the contents and convert it to HTML $content = file_get_contents($v); // Extract the title and body $author->name = get_content_tag('t', $content, $author); $author->about = MarkdownExtra::defaultTransform(remove_html_comments($content)); $tmp[] = $author; } } } if (!empty($tmp) || file_exists($username)) { return $tmp; } else { not_found(); } }
function author($atts) { global $thisarticle; extract(lAtts(array('link' => ''), $atts)); $author_name = get_author_name($thisarticle['authorid']); if (!empty($link)) { return '<a href="' . hu . urlencode(strtolower(gTxt('author'))) . '/' . urlencode($author_name) . '">' . $author_name . '</a>'; } return $author_name; }