function wp_generate_product_tag_cloud($tags, $args = '')
{
    global $wp_rewrite;
    $defaults = array('smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45, 'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    extract($args);
    if (!$tags) {
        return;
    }
    $counts = $tag_links = array();
    foreach ((array) $tags as $tag) {
        $counts[$tag->name] = $tag->count;
        $tag_links[$tag->name] = get_product_tag_link($tag->term_id);
        if (is_wp_error($tag_links[$tag->name])) {
            return $tag_links[$tag->name];
        }
        $tag_ids[$tag->name] = $tag->term_id;
    }
    $min_count = min($counts);
    $spread = max($counts) - $min_count;
    if ($spread <= 0) {
        $spread = 1;
    }
    $font_spread = $largest - $smallest;
    if ($font_spread <= 0) {
        $font_spread = 1;
    }
    $font_step = $font_spread / $spread;
    // SQL cannot save you; this is a second (potentially different) sort on a subset of data.
    if ('name' == $orderby) {
        uksort($counts, 'strnatcasecmp');
    } else {
        asort($counts);
    }
    if ('DESC' == $order) {
        $counts = array_reverse($counts, true);
    }
    $a = array();
    $rel = is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ? ' rel="tag"' : '';
    foreach ($counts as $tag => $count) {
        $tag_id = $tag_ids[$tag];
        $tag_link = clean_url($tag_links[$tag]);
        $tag = str_replace(' ', '&nbsp;', wp_specialchars($tag));
        $a[] = "<a href='{$tag_link}' class='tag-link-{$tag_id}' title='" . attribute_escape(sprintf(__('%d topics'), $count)) . "'{$rel} style='font-size: " . ($smallest + ($count - $min_count) * $font_step) . "{$unit};'>{$tag}</a>";
    }
    switch ($format) {
        case 'array':
            $return =& $a;
            break;
        case 'list':
            $return = "<ul class='product_tag_cloud'>\n\t<li>";
            $return .= join("</li>\n\t<li>", $a);
            $return .= "</li>\n</ul>\n";
            break;
        default:
            $return = join("\n", $a);
            break;
    }
    return apply_filters('wp_generate_product_tag_cloud', $return, $tags, $args);
}
示例#2
1
function image_setup($postid)
{
    global $post;
    $post = get_post($postid);
    // get url
    if (!preg_match('/<img ([^>]*)src=(\\"|\')(.+?)(\\2)([^>\\/]*)\\/*>/', $post->post_content, $matches)) {
        reset_colors($post);
        return false;
    }
    // url setup
    $post->image_url = $matches[3];
    if (!($post->image_url = preg_replace('/\\?w\\=[0-9]+/', '', $post->image_url))) {
        return false;
    }
    $post->image_url = clean_url($post->image_url, 'raw');
    $previous_md5 = get_post_meta($post->ID, 'image_md5', true);
    $previous_url = get_post_meta($post->ID, 'image_url', true);
    if (md5($post->image_tag) != $previous_md5 or $post->image_url != $previous_url) {
        reset_colors($post);
        add_post_meta($post->ID, 'image_url', $post->image_url);
        add_post_meta($post->ID, 'image_md5', md5($post->image_tag));
        //image tag setup
        $extra = $matches[1] . ' ' . $matches[5];
        $extra = preg_replace('/width=(\\"|\')[0-9]+(\\1)/', '', $extra);
        $extra = preg_replace('/height=(\\"|\')[0-9]+(\\1)/', '', $extra);
        $width = is_vertical($post->image_url) ? MIN_WIDTH : MAX_WIDTH;
        delete_post_meta($post->ID, 'image_tag');
        add_post_meta($post->ID, 'image_tag', '<img src="' . $post->image_url . '?w=' . $width . '" ' . $extra . ' />');
        // get colors
        get_all_colors($post);
        return false;
    }
    return true;
}
示例#3
0
/**
 * clean
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Clean
 * @author Henry Ruhs
 *
 * @param string $input
 * @param integer $mode
 * @return string
 */
function clean($input = '', $mode = '')
{
    $output = $input;
    /* if untrusted user */
    if (FILTER == 1) {
        if ($mode == 0) {
            $output = clean_special($output);
        }
        if ($mode == 1) {
            $output = clean_script($output);
            $output = clean_html($output);
        }
    }
    /* type related clean */
    if ($mode == 2) {
        $output = clean_alias($output);
    }
    if ($mode == 3) {
        $output = clean_email($output);
    }
    if ($mode == 4) {
        $output = clean_url($output);
    }
    /* mysql clean */
    $output = clean_mysql($output);
    return $output;
}
示例#4
0
/**
 * Check WordPress version against the newest version.
 *
 * The WordPress version, PHP version, and Locale is sent. Checks against the
 * WordPress server at api.wordpress.org server. Will only check if WordPress
 * isn't installing.
 *
 * @package WordPress
 * @since 2.3.0
 * @uses $wp_version Used to check against the newest WordPress version.
 *
 * @return mixed Returns null if update is unsupported. Returns false if check is too soon.
 */
function wp_version_check()
{
    if (defined('WP_INSTALLING')) {
        return;
    }
    global $wp_version, $wpdb, $wp_local_package;
    $php_version = phpversion();
    $current = get_option('update_core');
    if (!is_object($current)) {
        $current = new stdClass();
    }
    $locale = get_locale();
    if (isset($current->last_checked) && 43200 > time() - $current->last_checked && $current->version_checked == $wp_version) {
        return false;
    }
    // Update last_checked for current to prevent multiple blocking requests if request hangs
    $current->last_checked = time();
    update_option('update_core', $current);
    if (method_exists($wpdb, 'db_version')) {
        $mysql_version = preg_replace('/[^0-9.].*/', '', $wpdb->db_version($wpdb->users));
    } else {
        $mysql_version = 'N/A';
    }
    $local_package = isset($wp_local_package) ? $wp_local_package : '';
    $url = "http://api.wordpress.org/core/version-check/1.3/?version={$wp_version}&php={$php_version}&locale={$locale}&mysql={$mysql_version}&local_package={$local_package}";
    $options = array('timeout' => 3, 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo('url'));
    $response = wp_remote_get($url, $options);
    if (is_wp_error($response)) {
        return false;
    }
    if (200 != $response['response']['code']) {
        return false;
    }
    $body = trim($response['body']);
    $body = str_replace(array("\r\n", "\r"), "\n", $body);
    $new_options = array();
    foreach (explode("\n\n", $body) as $entry) {
        $returns = explode("\n", $entry);
        $new_option = new stdClass();
        $new_option->response = attribute_escape($returns[0]);
        if (isset($returns[1])) {
            $new_option->url = clean_url($returns[1]);
        }
        if (isset($returns[2])) {
            $new_option->package = clean_url($returns[2]);
        }
        if (isset($returns[3])) {
            $new_option->current = attribute_escape($returns[3]);
        }
        if (isset($returns[4])) {
            $new_option->locale = attribute_escape($returns[4]);
        }
        $new_options[] = $new_option;
    }
    $updates = new stdClass();
    $updates->updates = $new_options;
    $updates->last_checked = time();
    $updates->version_checked = $wp_version;
    update_option('update_core', $updates);
}
示例#5
0
文件: talks.php 项目: unisexx/drtooth
 function save($id = false)
 {
     if ($_POST) {
         $rs = new Talk($id);
         if ($_FILES['image']['name']) {
             if ($rs->id) {
                 $rs->delete_file($rs->id, 'uploads/talks', 'image');
             }
             $_POST['image'] = $rs->upload($_FILES['image'], 'uploads/talks/');
         }
         // if(!$id)$_POST['user_id'] = $this->session->userdata('id');
         $_POST['title'] = lang_encode($_POST['title']);
         $_POST['detail'] = lang_encode($_POST['detail']);
         $_POST['alt'] = lang_encode($_POST['alt']);
         // $_POST['meta_keyword'] = lang_encode($_POST['meta_keyword']);
         // $_POST['meta_description'] = lang_encode($_POST['meta_description']);
         if (!$id) {
             $_POST['status'] = "approve";
         }
         $_POST['slug'] = clean_url($_POST['title']);
         $rs->from_array($_POST);
         $rs->save();
         set_notify('success', lang('save_data_complete'));
     }
     redirect($_POST['referer']);
 }
function sanitize_option($option, $value) {

	switch ($option) {
		case 'admin_email':
			$value = sanitize_email($value);
			break;

		case 'default_post_edit_rows':
		case 'mailserver_port':
		case 'comment_max_links':
			$value = abs((int) $value);
			break;

		case 'posts_per_page':
		case 'posts_per_rss':
			$value = (int) $value;
			if ( empty($value) ) $value = 1;
			if ( $value < -1 ) $value = abs($value);
			break;

		case 'default_ping_status':
		case 'default_comment_status':
			// Options that if not there have 0 value but need to be something like "closed"
			if ( $value == '0' || $value == '')
				$value = 'closed';
			break;

		case 'blogdescription':
		case 'blogname':
			if (current_user_can('unfiltered_html') == false)
				$value = wp_filter_post_kses( $value );
			break;

		case 'blog_charset':
			$value = preg_replace('/[^a-zA-Z0-9_-]/', '', $value);
			break;

		case 'date_format':
		case 'time_format':
		case 'mailserver_url':
		case 'mailserver_login':
		case 'mailserver_pass':
		case 'ping_sites':
		case 'upload_path':
			$value = strip_tags($value);
			$value = wp_filter_kses($value);
			break;

		case 'gmt_offset':
			$value = preg_replace('/[^0-9:.-]/', '', $value);
			break;

		case 'siteurl':
		case 'home':
			$value = clean_url($value);
			break;
	}

	return $value;	
}
示例#7
0
function get_theme_data($theme_file)
{
    $themes_allowed_tags = array('a' => array('href' => array(), 'title' => array()), 'abbr' => array('title' => array()), 'acronym' => array('title' => array()), 'code' => array(), 'em' => array(), 'strong' => array());
    $theme_data = implode('', file($theme_file));
    $theme_data = str_replace('\\r', '\\n', $theme_data);
    preg_match('|Theme Name:(.*)$|mi', $theme_data, $theme_name);
    preg_match('|Theme URI:(.*)$|mi', $theme_data, $theme_uri);
    preg_match('|Description:(.*)$|mi', $theme_data, $description);
    preg_match('|Author:(.*)$|mi', $theme_data, $author_name);
    preg_match('|Author URI:(.*)$|mi', $theme_data, $author_uri);
    preg_match('|Template:(.*)$|mi', $theme_data, $template);
    if (preg_match('|Version:(.*)|i', $theme_data, $version)) {
        $version = wp_kses(trim($version[1]), $themes_allowed_tags);
    } else {
        $version = '';
    }
    if (preg_match('|Status:(.*)|i', $theme_data, $status)) {
        $status = wp_kses(trim($status[1]), $themes_allowed_tags);
    } else {
        $status = 'publish';
    }
    $name = $theme = wp_kses(trim($theme_name[1]), $themes_allowed_tags);
    $theme_uri = clean_url(trim($theme_uri[1]));
    $description = wptexturize(wp_kses(trim($description[1]), $themes_allowed_tags));
    $template = wp_kses(trim($template[1]), $themes_allowed_tags);
    $author_uri = clean_url(trim($author_uri[1]));
    if (empty($author_uri[1])) {
        $author = wp_kses(trim($author_name[1]), $themes_allowed_tags);
    } else {
        $author = sprintf('<a href="%1$s" title="%2$s">%3$s</a>', $author_uri, __('Visit author homepage'), wp_kses(trim($author_name[1]), $themes_allowed_tags));
    }
    return array('Name' => $name, 'Title' => $theme, 'URI' => $theme_uri, 'Description' => $description, 'Author' => $author, 'Version' => $version, 'Template' => $template, 'Status' => $status);
}
示例#8
0
文件: Webapp.php 项目: rudraks/utils
 public static function init()
 {
     self::$SCRIPT_NAME = clean_url($_SERVER['SCRIPT_NAME']);
     self::$SCRIPT_FILENAME = clean_url($_SERVER['SCRIPT_FILENAME']);
     self::$BASE_DIR = clean_url(dirname(self::$SCRIPT_FILENAME));
     // Absolute path to your installation, ex: /var/www/mywebsite
     self::$DOC_ROOT = str_replace(self::$SCRIPT_NAME, '', self::$SCRIPT_FILENAME);
     // ex: /var/www
     self::$BASE_URL = str_replace(self::$DOC_ROOT, '', self::$BASE_DIR);
     // ex: '' or '/mywebsite'
     self::$PROTOCOL = empty($_SERVER['HTTPS']) ? 'http' : 'https';
     self::$PORT = $_SERVER['SERVER_PORT'];
     self::$DISP_PORT = self::$PROTOCOL == 'http' && self::$PORT == 80 || self::$PROTOCOL == 'https' && self::$PORT == 443 ? '' : ":" . self::$PORT;
     self::$DOMAIN = $_SERVER['SERVER_NAME'];
     self::$FULL_URL = self::$PROTOCOL . "://" . self::$DOMAIN . self::$DISP_PORT . self::$BASE_URL;
     $subdomains = explode(".", $_SERVER['HTTP_HOST']);
     self::$SUBDOMAIN = array_shift($subdomains);
     if (array_key_exists('REQUEST_SCHEME', $_SERVER)) {
         self::$REMOTE_HOST = $_SERVER["REQUEST_SCHEME"] . "://" . $_SERVER["SERVER_NAME"] . dirname($_SERVER["SCRIPT_NAME"]);
     } else {
         self::$REMOTE_HOST = "http://" . $_SERVER["HTTP_HOST"];
     }
     self::$REMOTE_HOST = str_replace('\\', "/", self::$REMOTE_HOST);
     $pathinfo = pathinfo($_SERVER["REQUEST_URI"]);
     $parsedInfo = parse_url($_SERVER["REQUEST_URI"]);
     //print_r($pathinfo);
     //print_r($parsedInfo);
     self::$REQUEST_PATHNAME = $parsedInfo['path'];
     self::$REQUEST_DIRNAME = $pathinfo['dirname'];
     self::$REQUEST_QUERY = isset($parsedInfo['query']) ? $parsedInfo['query'] : "";
     self::$REQUEST_FILE_EXT = isset($pathinfo['extension']) ? $pathinfo['extension'] : "";
     self::$REQUEST_FILENAME = str_replace("?" . self::$REQUEST_QUERY, "", $pathinfo['basename']);
     self::$REQUEST_FILE_EXT = str_replace("?" . self::$REQUEST_QUERY, "", self::$REQUEST_FILE_EXT);
 }
示例#9
0
文件: live.php 项目: cdlabal/doc
function getfile($tree, $url, $current_dir, $flag = FALSE)
{
    global $docs_path, $base_doc, $options;
    $url = clean_url($url, "Live");
    if ($url === '' || $url === 'index') {
        if (is_file($docs_path . "/index.md")) {
            return $docs_path . "/index.md";
        } else {
            if (empty($options['languages'])) {
                return $base_doc;
            } else {
                $t = array_keys($base_doc);
                return $base_doc[$t[0]];
            }
        }
    } else {
        $url = explode("/", $url);
        $file = $docs_path;
        foreach ($url as $part) {
            if (isset($tree)) {
                $dirs = array_keys($tree);
                $key = array_search($part, array_map("clean_live", $dirs));
            } else {
                $key = FALSE;
            }
            if ($key === FALSE) {
                return FALSE;
            }
            $file .= '/' . $dirs[$key];
            $tree = $tree[$dirs[$key]];
        }
        return $file;
    }
}
示例#10
0
function fluxrewrite($id, $name, $type, $page = false, $new_message = false, $post = false)
{
    /*
       Rewrites the URL
       $type: forum/topic
       $id: ID
       $name: forum name/topic subject
       $page: specifies which page we have to display
       $new_message: adds -new-message to the URL or not
       $post: post to show up
    */
    $url = clean_url($name);
    /*if ($new_message === true)
    		$url = $url.'-new-messages';
    	else
    		$url = $url.'-page-'.$page;*/
    $url = urlencode($url . '-' . $type . $id);
    if ($page) {
        $url = $url . '?page=' . $page;
    }
    if ($post != null) {
        $url = $url . '#p' . $post;
    }
    return $url;
}
示例#11
0
function logit($r = '')
{
    global $siteurl, $prefs, $pretext;
    $mydomain = str_replace('www.', '', preg_quote($siteurl, "/"));
    $out['uri'] = @$pretext['request_uri'];
    $out['ref'] = clean_url(str_replace("http://", "", serverSet('HTTP_REFERER')));
    $host = $ip = serverSet('REMOTE_ADDR');
    if (!empty($prefs['use_dns'])) {
        // A crude rDNS cache
        if ($h = safe_field('host', 'txp_log', "ip='" . doSlash($ip) . "' limit 1")) {
            $host = $h;
        } else {
            // Double-check the rDNS
            $host = @gethostbyaddr(serverSet('REMOTE_ADDR'));
            if ($host != $ip and @gethostbyname($host) != $ip) {
                $host = $ip;
            }
        }
    }
    $out['ip'] = $ip;
    $out['host'] = $host;
    $out['status'] = 200;
    // FIXME
    $out['method'] = serverSet('REQUEST_METHOD');
    if (preg_match("/^[^\\.]*\\.?{$mydomain}/i", $out['ref'])) {
        $out['ref'] = "";
    }
    if ($r == 'refer') {
        if (trim($out['ref']) != "") {
            insert_logit($out);
        }
    } else {
        insert_logit($out);
    }
}
示例#12
0
    public function getContent()
    {
        global $sql;
        // Strona zabezpieczona wykonuje dwa niepotrzebne zapytania, mimo, że tekst sie nie wyświetla, należy po pierwszym zapytaniu wykonać fetch_assoc
        $page = $sql->query('
			SELECT * FROM ' . DB_PREFIX . 'subpages
			WHERE id = ' . $this->id)->fetch();
        // Page does not exist
        if (!$page) {
            return not_found('Page you have been loking for does not exists.');
        } else {
            if ($page['permit'] == 0) {
                return no_access();
            } else {
                if (!LOGGED && $page['type'] == 2) {
                    return no_access(array('Wybrana treść jest dostępna tylko dla zalogowanych osób.', t('REGISTER')));
                } else {
                    Kio::addTitle($page['title']);
                    Kio::addBreadcrumb($page['title'], $page['id'] . '/' . clean_url($page['title']));
                    //			$this->subcodename = $page['number'];
                    Kio::addHead($page['head']);
                    if ($page['description']) {
                        Kio::setDescription($page['description']);
                    }
                    if ($page['keywords']) {
                        Kio::setKeywords($page['keywords']);
                    }
                    return eval('?>' . $page['content']);
                }
            }
        }
    }
function image_information_init($postid)
{
    global $post;
    $post = get_post($postid);
    // get url
    if (!preg_match('/<img ([^>]*)src=(\\"|\')(.+?)(\\2)([^>\\/]*)\\/*>/', $post->post_content, $matches)) {
        reset_post_colors($post);
        return false;
    }
    $post->image_url = $matches[3];
    if (!($post->image_url = preg_replace('/\\?w\\=[0-9]+/', '', $post->image_url))) {
        return false;
    }
    $post->image_url = clean_url($post->image_url, 'raw');
    $previous_url = get_post_meta($post->ID, 'image_url', true);
    if ($post->image_url != $previous_url) {
        //image tag setup
        $extra = $matches[1] . ' ' . $matches[5];
        $extra = preg_replace('/width=(\\"|\')[0-9]+(\\1)/', '', $extra);
        $extra = preg_replace('/height=(\\"|\')[0-9]+(\\1)/', '', $extra);
        $width = is_vertical($post->image_url) ? MIN_WIDTH : MAX_WIDTH;
        // reset
        reset_post_colors($post);
        add_post_meta($post->ID, 'image_url', $post->image_url);
        add_post_meta($post->ID, 'image_tag', '<img src="' . $post->image_url . '?w=' . $width . '" ' . $extra . ' />');
        // set colors
        $base = get_post_colors($post);
        if (add_post_meta($post->ID, 'image_colors_bg', $base->bg, false) && add_post_meta($post->ID, 'image_colors_fg', $base->fg, false)) {
            return false;
        }
    }
    return true;
}
示例#14
0
/**
*
* @package phpBB3
* @version $Id: functions_seo.php 489 2007-09-19 22:04:18Z handyman $
* @copyright (c) 2007 StarTrekGuide Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

function format_url($name, $id, $start = 0, $xtra_params = false, $append = true)
{
	global $phpbb_root_path, $config, $phpEx;
	global $_SID;

	$name = clean_url($name);

	$ext = '.html';
	if (isset($config['seo_ext']))
	{
		$ext = '.' . $config['seo_ext'];
	}

	switch (substr($id, 0, 1))
	{
		case 'p':
			if ($append)
			{
				return append_seo_sid($phpbb_root_path . $name . '-' . $id . (($start) ? "s$start" : '') . $ext, $xtra_params) . '#' . $id;
			}
		break;
		case 't':
		case 'f':
			if ($append)
			{
				return append_seo_sid($phpbb_root_path . $name . '-' . $id . (($start) ? "s$start" : '') . $ext, $xtra_params);
			}
		break;
	}
	return $phpbb_root_path . $name . '-' . $id;
}
 public function __construct($base)
 {
     $this->base = $base;
     if (!isset($_GET[self::NONCE_PARAM]) || empty($_GET[self::NONCE_PARAM]) || !isset($_GET[self::URL_PARAM]) || empty($_GET[self::URL_PARAM])) {
         self::show_error();
         // exit;
     }
     $this->url = stripslashes($_GET[self::URL_PARAM]);
     $nonce = stripslashes($_GET[self::NONCE_PARAM]);
     if (!$this->base->verify_anon_nonce($nonce, 'redir_' . md5($this->url) . md5($_SERVER['HTTP_USER_AGENT']))) {
         return;
     }
     $this->full_url = $this->url = clean_url($this->url);
     if (preg_match('|^/|', $this->url)) {
         $this->full_url = preg_replace('|^(https?://[^/]*)/.*$|', '$1', get_bloginfo('url')) . $this->url;
     }
     if (isset($_GET[self::PCONLY_SITE_PARAM]) && $_GET[self::PCONLY_SITE_PARAM] == 'true') {
         return;
     }
     $this->mobile_url = $this->discover_mobile($this->url);
     if ($this->mobile_url && $this->compare_host() && !KTAI_ALWAYS_RELAY_PAGE) {
         wp_redirect($this->mobile_url);
         exit;
     }
 }
示例#16
0
function wp_mshot($url = '', $width = 250)
{
    if ($url != '') {
        return 'http://s.wordpress.com/mshots/v1/' . urlencode(clean_url($url)) . '?w=' . $width;
    } else {
        return '';
    }
}
示例#17
0
 function _css_href($src, $ver, $handle)
 {
     if (!preg_match('|^https?://|', $src) && !preg_match('|^' . preg_quote(WP_CONTENT_URL) . '|', $src)) {
         $src = $this->base_url . $src;
     }
     $src = add_query_arg('ver', $ver, $src);
     $src = apply_filters('style_loader_src', $src, $handle);
     return clean_url($src);
 }
 function pt_thumbnail($settings, $img_url = '', $arg = '', $default = false)
 {
     $this->the_image = NormalizeURL(clean_url($img_url));
     $this->settings = $settings;
     $this->arg = $arg;
     $this->defaultimg = $default;
     $this->parse_arg();
     $this->get_thumbnail();
     unset($settings);
 }
示例#19
0
/**
 * Display a tag clouds.
 */
function vicuna_tag_cloud($args = '')
{
    global $wp_rewrite;
    $defaults = array('levels' => 6, 'orderby' => 'name', 'order' => 'ASC', 'exclude' => '', 'include' => '');
    $args = wp_parse_args($args, $defaults);
    $tags = get_tags(array_merge($args, array('orderby' => 'count', 'order' => 'ASC')));
    // Always query top tags
    if (empty($tags)) {
        return;
    }
    extract($args);
    if (!$tags) {
        return;
    }
    $counts = $tag_links = array();
    foreach ((array) $tags as $tag) {
        $counts[$tag->name] = $tag->count;
        $tag_links[$tag->name] = get_tag_link($tag->term_id);
        if (is_wp_error($tag_links[$tag->name])) {
            return $tag_links[$tag->name];
        }
        $tag_ids[$tag->name] = $tag->term_id;
    }
    $min_count = min($counts);
    $step = (int) ((max($counts) - $min_count) / $levels) + 1;
    if ($step <= 1) {
        $step = 1;
    }
    // SQL cannot save you; this is a second (potentially different) sort on a subset of data.
    if ('name' == $orderby) {
        uksort($counts, 'strnatcasecmp');
    } else {
        asort($counts);
    }
    if ('DESC' == $order) {
        $counts = array_reverse($counts, true);
    }
    $a = array();
    $rel = is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ? ' rel="tag"' : '';
    foreach ($counts as $tag => $count) {
        $tag_id = $tag_ids[$tag];
        $tag_link = clean_url($tag_links[$tag]);
        $level = $levels - (int) (($count - $min_count) / $step);
        $tag = str_replace(' ', '&nbsp;', wp_specialchars($tag));
        $a[] = "<li class=\"level" . $level . "\"><a href=\"{$tag_link}\" title=\"" . attribute_escape(sprintf(__('%d Entries', 'vicuna'), $count)) . "\"{$rel}>{$tag}</a></li>";
    }
    $return = "<ul class=\"tagCloud\">\n\t";
    $return .= join("\n\t", $a);
    $return .= "\n</ul>\n";
    if (is_wp_error($return)) {
        return false;
    } else {
        echo apply_filters('vicuna_tag_cloud', $return, $tags, $args);
    }
}
/**
 * wp_version_check() - Check WordPress version against the newest version.
 *
 * The WordPress version, PHP version, and Locale is sent. Checks against the WordPress server at
 * api.wordpress.org server. Will only check if PHP has fsockopen enabled and WordPress isn't installing.
 *
 * @package WordPress
 * @since 2.3
 * @uses $wp_version Used to check against the newest WordPress version.
 *
 * @return mixed Returns null if update is unsupported. Returns false if check is too soon.
 */
function wp_version_check() {
	if ( !function_exists('fsockopen') || strpos($_SERVER['PHP_SELF'], 'install.php') !== false || defined('WP_INSTALLING') )
		return;

	global $wp_version;
	$php_version = phpversion();

	$current = get_option( 'update_core' );
	$locale = get_locale();

	if (
		isset( $current->last_checked ) &&
		43200 > ( time() - $current->last_checked ) &&
		$current->version_checked == $wp_version
	)
		return false;

	$new_option = '';
	$new_option->last_checked = time(); // this gets set whether we get a response or not, so if something is down or misconfigured it won't delay the page load for more than 3 seconds, twice a day
	$new_option->version_checked = $wp_version;

	$http_request  = "GET /core/version-check/1.1/?version=$wp_version&php=$php_version&locale=$locale HTTP/1.0\r\n";
	$http_request .= "Host: api.wordpress.org\r\n";
	$http_request .= 'Content-Type: application/x-www-form-urlencoded; charset=' . get_option('blog_charset') . "\r\n";
	$http_request .= 'User-Agent: WordPress/' . $wp_version . '; ' . get_bloginfo('url') . "\r\n";
	$http_request .= "\r\n";

	$response = '';
	if ( false !== ( $fs = @fsockopen( 'api.wordpress.org', 80, $errno, $errstr, 3 ) ) && is_resource($fs) ) {
		fwrite( $fs, $http_request );
		while ( !feof( $fs ) )
			$response .= fgets( $fs, 1160 ); // One TCP-IP packet
		fclose( $fs );

		$response = explode("\r\n\r\n", $response, 2);
		if ( !preg_match( '|HTTP/.*? 200|', $response[0] ) )
			return false;

		$body = trim( $response[1] );
		$body = str_replace(array("\r\n", "\r"), "\n", $body);

		$returns = explode("\n", $body);

		$new_option->response = attribute_escape( $returns[0] );
		if ( isset( $returns[1] ) )
			$new_option->url = clean_url( $returns[1] );
		if ( isset( $returns[2] ) )
			$new_option->current = attribute_escape( $returns[2] );
	}
	update_option( 'update_core', $new_option );
}
示例#21
0
    public function getContent()
    {
        global $sql;
        // $kio->disableRegion('left');
        if (u1 || LOGGED) {
            // TODO: Zamiast zapytania dla własnego konta dać User::toArray()
            $profile = $sql->query('
				SELECT u.*
				FROM ' . DB_PREFIX . 'users u
				WHERE u.id = ' . (ctype_digit(u1) ? u1 : UID))->fetch();
        }
        if ($profile) {
            Kio::addTitle(t('Users'));
            Kio::addBreadcrumb(t('Users'), 'users');
            Kio::addTitle($profile['nickname']);
            Kio::addBreadcrumb($profile['nickname'], 'profile/' . u1 . '/' . clean_url($profile['nickname']));
            Kio::setDescription(t('%nickname&apos;s profile', array('%nickname' => $profile['nickname'])) . ($profile['title'] ? ' - ' . $profile['title'] : ''));
            Kio::addTabs(array(t('Edit profile') => 'edit_profile/' . u1));
            if ($profile['birthdate']) {
                $profile['bd'] = $profile['birthdate'] ? explode('-', $profile['birthdate']) : '';
                // DD Month YYYY (Remaining days to next birthday)
                $profile['birthdate'] = $profile['bd'][2] . ' ' . Kio::$months[$profile['bd'][1]] . ' ' . $profile['bd'][0] . ' (' . day_diff(mktime(0, 0, 0, $profile['bd'][1], $profile['bd'][2] + 1, date('y')), t('%d days remaining')) . ')';
                $profile['age'] = get_age($profile['bd'][2], $profile['bd'][1], $profile['bd'][0]);
                if (Plugin::exists('zodiac')) {
                    require_once ROOT . 'plugins/zodiac/zodiac.plugin.php';
                    $profile['zodiac'] = Zodiac::get($profile['bd'][2], $profile['bd'][1]);
                }
            }
            if ($profile['http_agent'] && Plugin::exists('user_agent')) {
                require_once ROOT . 'plugins/user_agent/user_agent.plugin.php';
                $profile['os'] = User_Agent::getOS($profile['http_agent']);
                $profile['browser'] = User_Agent::getBrowser($profile['http_agent']);
            }
            $group = Kio::getGroup($profile['group_id']);
            $profile['group'] = $group['name'] ? $group['inline'] ? sprintf($group['inline'], $group['name']) : $group['name'] : '';
            if ($profile['gender']) {
                $profile['gender'] = $profile['gender'] == 1 ? t('Male') : t('Female');
            }
            try {
                // TODO: Zrobić modyfikator dla funkcji o wielu parametrach (teraz jest tylko jeden możliwy)
                $tpl = new PHPTAL('modules/profile/profile.tpl.html');
                $tpl->profile = $profile;
                return $tpl->execute();
            } catch (Exception $e) {
                return template_error($e);
            }
        } else {
            return not_found(t('Selected user doesn&apos;t exists.'), array(t('This person was deleted from database.'), t('Entered URL is invalid.')));
        }
    }
示例#22
0
/**
 * {@internal Missing Short Description}}
 *
 * @since unknown
 *
 * @param unknown_type $id
 * @return unknown
 */
function get_comment_to_edit($id)
{
    if (!($comment = get_comment($id))) {
        return false;
    }
    $comment->comment_ID = (int) $comment->comment_ID;
    $comment->comment_post_ID = (int) $comment->comment_post_ID;
    $comment->comment_content = format_to_edit($comment->comment_content);
    $comment->comment_content = apply_filters('comment_edit_pre', $comment->comment_content);
    $comment->comment_author = format_to_edit($comment->comment_author);
    $comment->comment_author_email = format_to_edit($comment->comment_author_email);
    $comment->comment_author_url = clean_url($comment->comment_author_url);
    $comment->comment_author_url = format_to_edit($comment->comment_author_url);
    return $comment;
}
/**
 * {@internal Missing Short Description}}
 *
 * @since unknown
 *
 * @return unknown
 */
function get_default_link_to_edit() {
	if ( isset( $_GET['linkurl'] ) )
		$link->link_url = clean_url( $_GET['linkurl']);
	else
		$link->link_url = '';

	if ( isset( $_GET['name'] ) )
		$link->link_name = attribute_escape( $_GET['name']);
	else
		$link->link_name = '';

	$link->link_visible = 'Y';

	return $link;
}
示例#24
0
/**
 * 获取文件绝对路径
 * @param string|array $param
 * @return string
 */
function get_file_url($param = '')
{
    static $url = NULL;
    if ($url === NULL) {
        $url = hook()->apply('get_file_url', URL_FILE);
    }
    $rt = $url;
    if (is_array($param)) {
        $rt .= implode('/', $param);
        if (func_num_args() > 1) {
            $rt .= func_get_arg(1);
        }
    } else {
        $rt .= implode('/', func_get_args());
    }
    return clean_url($rt);
}
示例#25
0
    public function getContent()
    {
        global $sql;
        $stmt = $sql->setCache('new_users')->query('
			SELECT id, nickname, registered
			FROM ' . DB_PREFIX . 'users
			ORDER BY id DESC
			LIMIT 10');
        if ($stmt) {
            $items = array();
            while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
                $items[$row['nickname']] = array(HREF . 'profile/' . $row['id'] . '/' . clean_url($row['nickname']), clock($row['registered']));
            }
            return items($items);
        } else {
            return t('There is no content to display.');
        }
    }
示例#26
0
    public function getContent()
    {
        global $sql;
        $stmt = $sql->setCache('news_categories')->query('
			SELECT *
			FROM ' . DB_PREFIX . 'news_categories
			ORDER BY name
			LIMIT 10');
        if ($stmt) {
            $items = array();
            while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
                $items[$row['name'] . ' (' . $row['entries'] . ')'] = array(HREF . 'news/category/' . $row['id'] . '/' . clean_url($row['name']), $row['description'] ? $row['description'] : t('Entries marked as %category', array('%category' => $row['name'])));
            }
            return $this->content = items($items);
        } else {
            return $this->content = t('There is no content to display.');
        }
    }
示例#27
0
function pigura_popular_tag($number_tags)
{
    $tagcloud = get_tags(array('number' => $number_tags, 'orderby' => 'count', 'order' => 'DESC', 'exclude' => '', 'include' => ''));
    $counts = $tag_links = $tag_ids = $a = array();
    foreach ($tagcloud as $tag) {
        $counts[$tag->name] = $tag->count;
        $tag_links[$tag->name] = get_tag_link($tag->term_id);
        $tag_ids[$tag->name] = $tag->term_id;
    }
    foreach ($counts as $tag => $count) {
        $tag_id = $tag_ids[$tag];
        $tag_link = clean_url($tag_links[$tag]);
        $tag = str_replace(' ', '&nbsp;', wp_specialchars($tag));
        $a[] = "<a href=\"{$tag_link}\" class=\"tag-link-{$tag_id}\">{$tag}</a>";
    }
    print "<ul class='pigura-popular-tag'>\r\n<li>";
    print join("</li>\r\n<li>", $a);
    print "</li>\r\n</ul>\r\n";
}
示例#28
0
 function do_item($handle)
 {
     if (!parent::do_item($handle)) {
         return false;
     }
     $ver = $this->registered[$handle]->ver ? $this->registered[$handle]->ver : $this->default_version;
     if (isset($this->args[$handle])) {
         $ver .= '&amp;' . $this->args[$handle];
     }
     $src = $this->registered[$handle]->src;
     if (!preg_match('|^https?://|', $src) && !preg_match('|^' . preg_quote(WP_CONTENT_URL) . '|', $src)) {
         $src = $this->base_url . $src;
     }
     $src = add_query_arg('ver', $ver, $src);
     $src = clean_url(apply_filters('script_loader_src', $src, $handle));
     $this->print_scripts_l10n($handle);
     echo "<script type='text/javascript' src='{$src}'></script>\n";
     return true;
 }
示例#29
0
    function widget($args, $instance)
    {
        extract($args);
        $title = isset($instance['title']) && $instance['title'] ? $instance['title'] : __('Recent tags', 'p2');
        $num_to_show = isset($instance['num_to_show']) && (int) $instance['num_to_show'] ? (int) $instance['num_to_show'] : $this->default_num_to_show;
        $recent_tags = $this->recent_tags($num_to_show);
        echo $before_widget . $before_title . wp_specialchars($title) . $after_title;
        echo "\t<ul>\n";
        foreach ($recent_tags as $recent) {
            ?>
		<li>
			<a class="rss" href="<?php 
            echo clean_url($recent['feed_link']);
            ?>
">RSS</a>&nbsp;
			<a href="<?php 
            echo clean_url($recent['link']);
            ?>
"><?php 
            echo wp_specialchars($recent['tag']->name);
            ?>
</a>&nbsp;
			(&nbsp;<?php 
            echo number_format_i18n($recent['tag']->count);
            ?>
&nbsp;)
		</li>
	<?php 
        }
        ?>
	</ul>
	<p>
		<a class="allrss" href="<?php 
        bloginfo('rss2_url');
        ?>
"><?php 
        _e('All Updates RSS', 'p2');
        ?>
</a>
	</p>
	<?php 
        echo $after_widget;
    }
示例#30
0
 function latest_posts()
 {
     require_once ABSPATH . WPINC . '/rss.php';
     if ($rss = fetch_rss('http://feeds.feedburner.com/DesignChemical')) {
         $content = '<ul class="dcwp-rss">';
         $rss->items = array_slice($rss->items, 0, 5);
         foreach ((array) $rss->items as $item) {
             $content .= '<li class="dcwp-rss-item">';
             $content .= '<a target="_blank" href="' . clean_url($item['link'], $protocolls = null, 'display') . '">' . $item['title'] . '</a> ';
             $content .= '</li>';
         }
         $content .= '</ul><ul class="bullet">';
         $content .= '<li class="dcwp-icon-rss"><a href="http://feeds.feedburner.com/DesignChemical">Subscribe to our RSS feed</a></li>';
         $content .= '</ul>';
     } else {
         $content = '<p>No updates..</p>';
     }
     $this->postbox($this->hook . '-latestpostbox', 'Latest news from Design Chemical ...', $content);
 }