WHERE blog_id = ' . intval($blog_id); $db->sql_query($sql); // Reindex the blog $blog_search->index('edit', $blog_id, 0, $message_parser->message, $blog_subject, $user_id); // Update the attachments $blog_attachment->update_attachment_data($blog_id, 0, blog_data::$blog[$blog_id]['user_id']); blog_plugins::plugin_do_arg('blog_edit_after_sql', $blog_id); // Submit the poll if ($auth->acl_get('u_blog_create_poll')) { submit_blog_poll($poll, $blog_id, 'edit'); } // Handle the subscriptions add_blog_subscriptions($blog_id, 'subscription_'); // Insert into the categories list if (sizeof($category_ary) > 1 || isset($category_ary[0]) && $category_ary[0] != 0) { $category_list = get_blog_categories('category_id'); foreach ($category_ary as $i => $cat_id) { if (!isset($category_list[$cat_id])) { unset($category_ary[$i]); } } } put_blogs_in_cats($blog_id, $category_ary, blog_data::$blog[$blog_id]['blog_approved'] == 1 || $auth->acl_get('u_blognoapprove') ? true : false); // If it needs reapproval... if (blog_data::$blog[$blog_id]['blog_approved'] == 0 && !$auth->acl_get('u_blognoapprove')) { $sql = 'UPDATE ' . USERS_TABLE . ' SET blog_count = blog_count - 1 WHERE user_id = ' . $user->data['user_id']; $db->sql_query($sql); set_config('num_blogs', --$config['num_blogs'], true); inform_approve_report('blog_approve', $blog_id); } handle_blog_cache('edit_blog', $user_id);
/** * Handle the categories * * @param int $parent_id If this is set to something other than 0 it will only list categories under the category_id given * @param string $block Set the name of the block to output it to. * @param bool $ignore_subcats True to ignore subcategories, false to display them. * @param array $category_list If you want to send the already gotten category list... */ function handle_categories($parent_id = 0, $block = 'category_row', $ignore_subcats = false, $category_list = false) { global $config, $template, $user; if (!is_array($category_list)) { $category_list = get_blog_categories('left_id'); } blog_plugins::plugin_do('function_handle_categories'); foreach ($category_list as $left_id => $row) { if ($parent_id == $row['category_id'] && !$ignore_subcats) { $template->assign_vars(array('U_CURRENT_CATEGORY' => blog_url(false, false, false, array('page' => $config['user_blog_seo'] ? $row['category_name'] : '*skip*', 'c' => $row['category_id'])), 'CURRENT_CATEGORY' => $row['category_name'], 'CATEGORY_RULES' => generate_text_for_display($row['rules'], $row['rules_uid'], $row['rules_bitfield'], $row['rules_options']))); } if ($parent_id == $row['parent_id']) { $template->assign_block_vars($block, array('CATEGORY_NAME' => $row['category_name'], 'CATEGORY_DESCRIPTION' => generate_text_for_display($row['category_description'], $row['category_description_uid'], $row['category_description_bitfield'], $row['category_description_options']), 'BLOGS' => $row['blog_count'], 'U_CATEGORY' => blog_url(false, false, false, array('page' => $config['user_blog_seo'] ? $row['category_name'] : '*skip*', 'c' => $row['category_id'])), 'S_SUBCATEGORY' => $row['right_id'] > $row['left_id'] + 1 && !$ignore_subcats, 'L_SUBCATEGORY' => $row['right_id'] > $row['left_id'] + 3 ? $user->lang['SUBCATEGORIES'] : $user->lang['SUBCATEGORY'])); // If not, then there are subcategories if ($row['right_id'] > $row['left_id'] + 1 && !$ignore_subcats) { handle_categories($row['category_id'], 'category_row.subcategory', true, $category_list); } } } }
/** * URL handler * * @param int $user_id - The user_id * @param int $blog_id - The blog_id * @param int $reply_id - The reply_id * @param array $url_data - Data to put in the url's. Everything will get built in the url from this array. * For exmaple, if array('page' => 'blog', 'mode' => 'add') is sent it would be built as blog.php?page=blog&mode=add * Send 'anchor' (if needed) as the anchor for the page which will get added to the end of the url as # . $url_data['anchor'] * @param array $extra_data - Extra data that will be used in the URL when required. * When building the url this function checks the blog_data::$(user|blog|reply) arrays to see if the username, blog title, and/or reply title exist for that (user|blog|reply)_id. * If they do not exist in that array and you would like to manually send it you can send it in this array. array('username' => (the username), 'blog_subject' => (blog title), 'reply_subject' => (reply title)) * These are not required to be sent, just send them if you want/need to. * @param bool $force_no_seo - If set to true this will build a normal url (needed for some places), not the pretty ones with the username, title, etc in. */ function blog_url($user_id, $blog_id = false, $reply_id = false, $url_data = array(), $extra_data = array(), $force_no_seo = false) { global $config, $user, $_SID; blog_plugins::plugin_do('function_blog_url'); // don't call the generate_board_url function a whole bunch of times, get it once and keep using it static $start_url = ''; $start_url = $start_url == '' ? (defined('BLOG_ROOT') ? generate_board_url(true) . BLOG_ROOT : generate_board_url()) . '/' : $start_url; $extras = $anchor = ''; // Add the category stuff if c is in the url static $blog_categories = false; if (isset($_GET['c']) && !isset($url_data['c'])) { $category_id = request_var('c', 0); if ($blog_categories === false) { $blog_categories = get_blog_categories('category_id'); } if (!isset($url_data['page']) && isset($blog_categories[$category_id]) && isset($config['user_blog_seo']) && $config['user_blog_seo'] && !$force_no_seo) { $url_data['page'] = $blog_categories[$category_id]['category_name']; } $url_data['c'] = $category_id; } // Add the blogstyle setting if required if (isset($_GET['blogstyle']) && !isset($url_data['blogstyle'])) { $url_data['blogstyle'] = request_var('blogstyle', ''); } // Handle the anchor if (isset($url_data['anchor'])) { $anchor = '#' . $url_data['anchor']; unset($url_data['anchor']); } else { if ($reply_id) { $anchor = '#r' . $reply_id; } } if (isset($config['user_blog_seo']) && $config['user_blog_seo'] && !$force_no_seo) { $title_match = '/([^a-zA-Z0-9\\s_])/'; // Replace HTML Entities, and non alphanumeric/space/underscore characters $replace_page = true; // match everything except the page if this is set to false if (!isset($url_data['page']) && $user_id !== false) { $username_check = '#&+/\\:?"<>%|'; if ($user_id == $user->data['user_id'] && !strpbrk($user->data['username'], $username_check)) { $url_data['page'] = urlencode($user->data['username']); } else { if (isset($extra_data['username']) && !strpbrk($extra_data['username'], $username_check)) { $url_data['page'] = urlencode($extra_data['username']); } else { if (class_exists('blog_data') && isset(blog_data::$user[$user_id]) && !strpbrk(blog_data::$user[$user_id]['username'], $username_check)) { $url_data['page'] = urlencode(blog_data::$user[$user_id]['username']); } else { $url_data['u'] = $user_id; } } } } else { if (isset($url_data['page']) && $user_id !== false) { $url_data['u'] = $user_id; } } if ($reply_id) { $url_data['r'] = $reply_id; if (!isset($url_data['mode'])) { if (class_exists('blog_data') && array_key_exists($reply_id, blog_data::$reply)) { $url_data['mode'] = utf8_clean_string(blog_data::$reply[$reply_id]['reply_subject']); } else { if (array_key_exists('reply_subject', $extra_data)) { $url_data['mode'] = utf8_clean_string($extra_data['reply_subject']); } } } } else { if ($blog_id) { $url_data['b'] = $blog_id; if (!isset($url_data['mode'])) { if (class_exists('blog_data') && array_key_exists($blog_id, blog_data::$blog)) { $url_data['mode'] = utf8_clean_string(blog_data::$blog[$blog_id]['blog_subject']); } else { if (array_key_exists('blog_subject', $extra_data)) { $url_data['mode'] = utf8_clean_string($extra_data['blog_subject']); } } } } } // Add style= to the url data if it is in there if (isset($_GET['style']) && !isset($url_data['style'])) { $url_data['style'] = request_var('style', ''); } // Add the Session ID if required. if ($_SID) { $url_data['sid'] = $_SID; } if (sizeof($url_data)) { foreach ($url_data as $name => $value) { if ($name == 'page' || $name == 'mode' || $value == '*skip*') { continue; } $extras .= '_' . url_replace($name) . '-' . url_replace($value); } } if (isset($url_data['page']) && $url_data['page']) { if (isset($url_data['mode']) && $url_data['mode']) { $url_data['mode'] = url_replace($url_data['mode']); //return $start_url . "blog/{$url_data['page']}/{$url_data['mode']}{$extras}{$anchor}"; return $start_url . "blog/{$url_data['page']}/{$url_data['mode']}{$extras}.html{$anchor}"; } else { if ($extras || $anchor) { //return $start_url . "blog/{$url_data['page']}/index{$extras}{$anchor}"; return $start_url . "blog/{$url_data['page']}/index{$extras}.html{$anchor}"; } else { //return $start_url . "blog/{$url_data['page']}"; return $start_url . "blog/{$url_data['page']}/"; } } } else { if (isset($url_data['mode']) && $url_data['mode']) { $url_data['mode'] = url_replace($url_data['mode']); //return $start_url . "blog/view/{$url_data['mode']}{$extras}{$anchor}"; return $start_url . "blog/view/{$url_data['mode']}{$extras}.html{$anchor}"; } else { if ($extras || $anchor) { //return $start_url . "blog/index{$extras}{$anchor}"; return $start_url . "blog/index{$extras}.html{$anchor}"; } else { return $start_url . 'blog/'; } } } } // No SEO Url's :( global $phpEx; // Do not add the sid multiple times unset($url_data['sid']); // add this stuff first $extras .= $user_id ? '&u=' . $user_id : (isset($url_data['u']) ? '&u=' . $url_data['u'] : ''); $extras .= $blog_id ? '&b=' . $blog_id : (isset($url_data['b']) ? '&b=' . $url_data['b'] : ''); $extras .= $reply_id ? '&r=' . $reply_id : (isset($url_data['r']) ? '&r=' . $url_data['r'] : ''); if (sizeof($url_data)) { foreach ($url_data as $name => $var) { // Do not add the blog/reply/user id to the url string, they've already been added if ($name == 'b' || $name == 'u' || $name == 'r' || $var == '*skip*') { continue; } $extras .= '&' . $name . '=' . $var; } } $extras = substr($extras, 5); // remove the first & return append_sid($start_url . 'blog.' . $phpEx, $extras) . $anchor; }
function print_blog($blog, $filters = array()) { global $page_vars; if (!$blog['active']) { print "<div class='blogbox blogbox_inactive'>"; print "<div class='blogbox_title'>"; print "<a href='" . linkto("blog_search.php", $page_vars, array("blog_id" => $blog['blog_id'])) . "'>" . $blog['title'] . "</a>"; print "</div>"; print "<p><i>This blog is inactive - it is no longer aggregated. <a href='" . linkto("manage_blogs.php", array(), array("workspace" => $filters['workspace'], "restore_blog_id" => $blog['blog_id'])) . "'>Click here</a> to restore it.</i>"; print "</div>"; return; } print "<div class='blogbox'>"; // title print "<div class='blogbox_title'>"; if ($filters['link']) { print "<a href='" . $blog['url'] . "'>" . $blog['title'] . "</a>"; } else { print "<a href='" . linkto("blog_search.php", $page_vars, array("blog_id" => $blog['blog_id'])) . "'>" . $blog['title'] . "</a>"; } print "</div>"; // thumbnail if ($blog['image']) { print "<div class='blogbox_thumbnail'>"; print "<img src='" . $blog['image'] . "' align='left'/>"; print "</div>"; } // byline print "<div class='blogbox_byline'>"; print connotea_link($blog['url']); if ($blog['incoming_bloglove']) { print print_rating($blog['incoming_bloglove']) . " other blogs recently<br/>"; } print "<a href='" . $blog['feed_url'] . "'>"; print "<img style='border: 0px;' src='images/feed.png' border='0' align='absmiddle'/> "; print "</a>"; print "<a href='" . $blog['url'] . "'>" . $blog['url'] . "</a>"; print "</div>"; // blog description print "<div class='blogbox_content'>"; print "<p>" . strip_tags(html_entity_decode($blog['description'])); print "</div>"; print "<div class='blogbox_footer'> </div>"; $tags_array = get_blog_categories($blog['blog_id']); $tags = array(); if ($filters['add_tag']) { # IN THE ADMIN INTERFACE print "<p><i>This blog is active - new posts will be aggregated. <a href='" . linkto("manage_blogs.php", array(), array("workspace" => $filters['workspace'], "remove_blog_id" => $blog['blog_id'])) . "'>Click here</a> to delete it.</i>"; # controls that allow you to add and remove tags foreach ($tags_array as $tag) { $id = $blog['blog_id'] . ":" . $tag; array_push($tags, "<a id='{$id}' onclick='switchClass(this);' class='tag_selected'>{$tag}</a>"); } print "<div class='tagbox'><p>Tags: " . implode(' ', $tags); $query = "SELECT DISTINCT tag FROM tags WHERE !ISNULL(blog_id) ORDER BY tag ASC"; $results = mysql_query($query); while ($row = mysql_fetch_assoc($results)) { $id = $blog['blog_id'] . ":" . $row['tag']; if (!in_array($row['tag'], $tags_array)) { if ($safe_category == $row['tag']) { $selected = "selected"; } printf(" <a id='{$id}' onclick='switchClass(this);' class='tag_select'>%s</a>", $row['tag']); } } $id = $blog['blog_id'] . ":custom"; print "<p>Create a custom tag? <input type='textbox' id='{$id}' onchange='addCustomTag(this);' value=''/>"; print "</div>"; } else { # NOT IN THE ADMIN INTERFACE $tags = array(); if ($filters['tagcloud']) { $popular_tags = get_tags_for_blogs(array($blog['blog_id']), 3); foreach ($popular_tags as $key => $val) { array_push($tags, "<a href='" . linkto("tag_search.php", $page_vars, array("tag" => $key)) . "'>{$key}</a>"); } } foreach ($tags_array as $tag) { array_push($tags, "<a href='" . linkto("blogs.php", $page_vars, array("category" => $tag)) . "'>{$tag}</a>"); } print "<div class='tagbox'>" . implode(' ', $tags) . "</div>"; } print "<div class='blogbox_footer'> </div>"; print "</div>"; }