Joomla! 1.5中文搜索BUG修正

在 Joomla!系统自带搜索对于中文关键词两个问题的解决 文章中说明了如何解决Joomla!中文搜索的两个BUG,

1、对于中文关键词我们通常是两个字,比如”插件”,这样的关键词的长度是2,而Joomla!查询的关键词限制长度是3以上。

2、对于一些中文关键词,如果开启了sef,就会导致搜索不到结果。

除了这两个问题外,还有一个棘手的问题,就是如果查询关键词为中文,涉及到翻页的情况下(SEF开启,没测试过未开启状态),是无法翻页的,你可以看到关键词都成了乱码,实际上中文字中的丢掉了一些字节。经过努力,才定位错误原来发生在 /libraries/joomla/eviroments/uri.php 的_PARSEURL函数中,函数的代码如下:

function _parseURL($uri)

{

$parts = array();

if (version_compare( phpversion(), ‘4.4′ ) < 0)

{

$regex = “<^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?>”;

$matches = array();

preg_match($regex, $uri, $matches, PREG_OFFSET_CAPTURE);

$authority = @$matches[4][0];

if (strpos($authority, ‘@’) !== false) {

$authority = explode(’@', $authority);

@list($parts['user'], $parts['pass']) = explode(’:', $authority[0]);

$authority = $authority[1];

}

if (strpos($authority, ‘:’) !== false) {

$authority = explode(’:', $authority);

$parts['host'] = $authority[0];

$parts['port'] = $authority[1];

} else {

$parts['host'] = $authority;

}

$parts['scheme'] = @$matches[2][0];

$parts['path'] = @$matches[5][0];

$parts['query'] = @$matches[7][0];

$parts['fragment'] = @$matches[9][0];

}

else

{

$parts = @parse_url($uri);

}

return $parts;

}

这个函数,对于我的php版本,显然会走这个分支 @parse_url($uri) ,查了一下parse_url函数的源码,的确是会吃掉中文utf-8中的字节,即使经过urlencode以后也不行。没办法,只好直接采用低版本分支,将php版本判断部分去掉。

function _parseURL($uri)

{

$parts = array();

//if (version_compare( phpversion(), ‘4.4′ ) < 0)

//{

$regex = “<^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?>”;

$matches = array();

preg_match($regex, $uri, $matches, PREG_OFFSET_CAPTURE);

$authority = @$matches[4][0];

if (strpos($authority, ‘@’) !== false) {

$authority = explode(’@', $authority);

@list($parts['user'], $parts['pass']) = explode(’:', $authority[0]);

$authority = $authority[1];

}

if (strpos($authority, ‘:’) !== false) {

$authority = explode(’:', $authority);

$parts['host'] = $authority[0];

$parts['port'] = $authority[1];

} else {

$parts['host'] = $authority;

}

$parts['scheme'] = @$matches[2][0];

$parts['path'] = @$matches[5][0];

$parts['query'] = @$matches[7][0];

$parts['fragment'] = @$matches[9][0];

//}

//else

//{

// $parts = @parse_url($uri);

//}

return $parts;

}

这样就好啦!目前我还没发现带来的其他问题,也就是效率稍低一点吧。不过相对于Joomla!那么低效率的数据库查询,这也不算什么啦。

Joomla! 1.5中文搜索BUG修正.

Rating: 0.0/10 (0 votes cast)

Ryan Reynolds:Celebrity Workout

ryan reynolds

Probably one of the fittest bodies in Hollywood is that of Ryan Reynolds.

Ryan Reynolds made his first real appearance in the popular movie Van Wilder, where he showed off his six pack, and fitly toned body. However, in 2003-2004, Ryan Reynolds went through an amazing transformation in preparation for his role in the movie Blade Trinity. This transformation is what really got Ryan Reynolds the attention in the health and fitness industry. So, what did Ryan Reynolds do In preparation to get his hot body ripped and ready for Blade Trinity? Ryan Reynolds managed to shed his body fat from 11% to only 3%, on top of gaining 20 pounds of muscle mass, all within a time period of about 5 months. Now, you ask, how did he do it?

First off, Ryan Reynolds was given a specific diet. In his own words he says, “I ate something pretty much every 2-3 hours, never “stuffing” myself, but never letting myself get hungry.” He also drank a large amount of water continually throughout the day.

The Ryan Reynolds Diet:

Breakfast: 2 eggs, some “good” fat like a spoon of almond butter or slice of avocado, and 1 cup of oatmeal with applesauce

Midmorning snack: protein bar

Lunch: albacore tuna wrap or chicken and salad

Mid-afternoon snack: protein shake (whey and water), protein bar, or apple and almonds

Dinner: broiled fish or chicken, brown rice, vegetables, and salad

Evening Snack: protein shake

Ryan Reynolds ate a protein carb mix every 2 hours, resulting in 8-10 small meals a day. Most of his carbohydrates he ate post-workout and never after 8:00pm. The carbs during the day kept his blood sugar levels even, and gave him the right amount of energy to get him through the intense workouts.

The Ryan Reynolds Workout:

Guided by personal trainer Darren Chapman, (both for Ryan Reynolds, and Jessica Biel) he performed daily workouts for 2-3 hours a day.

He would start with about 500-1000 sit ups, because this was very meditative for him. It didn’t matter when they were done, but he found it most beneficial at the beginning of the workout. The lower abs are the hardest muscle to develop, so Ryan did a lot of leg lifts with both the exercise ball, and weights, to focus on these muscles.

Ryan Reynolds would then do heavy weights focusing on one body part a day. It would look something like this: Chest day 1, Back day 2, Shoulder day 3, Legs day 4, with arms mixed in, and a constant rotation of these every day.

Ryan Reynolds Supplement Intake:

Ryan went on Creatine to gain more muscle mass, and also took supplements including L-glutamine, conjugated linoleic acid (CLA), whey, and a multivitamin.

Ryan Reynolds notes how important diet played a role in his transformation. Ryan said that 80% of it was based on his diet, when most people believe the workout to be the most vital element. However, 80% of building muscle is eating the right diet. Making sure he had enough calories to gain mass, but not fat, and eating a large amount of protein and carbs was Ryan Reynolds main focus.

So implementing a specific diet plan and starting your own workout routine can help you on your way to an overall better physique. You may not end up looking like Ryan Reynolds, but you can easily get on the right track to a fit and healthy body.

Ryan Reynolds:Celebrity Workout | Xeropoint Fitness Blog|Best Home Workout

Rating: 10.0/10 (1 vote cast)

【四川512地震周年祭】《悲中行》08年四川高考满分作文

2008年四川高考满分作文——《悲中行》

戊子岁,四月初八。川静其波,鸟罢其鸣。一场无情的天灾袭来,举国恸哭。在灾难面

前,我们选择坚强;在悲痛中,我们选择坚强。汶川坚强,四川坚强,中国坚强!因为

坚强,我们不怕灾难;因为坚强,我们明天更美好!

――――序

汶水东流不复西,神仙难改地震袭。

川蜀儿女多苦难,一片荒城尽眼底。

映现当年唐山景,尽是残垣与断壁。

秀丽河山浩劫后,昨日今朝各两异。

都道零八年岁好,为何灾难紧相逼。

江山如画景色美,怎奈苍天生妒忌。

北国刚受冰冻灾,天府又遭夷平地。

川静其波鸟罢鸣,齐哀满目皆疮痍。

江天五月渐阴沉,满腔悲痛灰色弥。

油绿麦田无人收,万千苍生宿路隅。

平生有泪不轻弹,今朝闻此泪如泥。

武候诸葛若有知,不堪目视亦掩泣。

彭祖寿延八百载,可知人命仅须臾。

州州郡郡华夏土,一砖一瓦似金玉。

金玉散去不足惜,金玉怎比万事吉。

花儿凋谢来年开,来年风景更旖旎。

茂年男儿体健壮,安能袖手闻羌笛。

理会百姓疾与苦,血汗合流同舟济。

绵薄微力不足道,奇迹因爱八方聚。

竹丝管弦为君鸣,可敬可赞可歌泣。

卧薪含悲建家园,蜀山青青蜀水碧。

龙的传人谁可胜,只手亦有撑天力。

汉羌一家爱无疆,我齿你唇永相依。

旺兴岁月定轮回,红霞当空雄鸡啼。

红烛数盏列堂前,潜心默祈哀思寄。

白云苍狗命难料,生者奋进逝者息。

青史铭刻五一二,永记今朝万人罹。

川蜀儿女多坚强,还把灾难视蝼蚁。

立我于高山之上兮,眺望远方。惟见山河齐悲兮,黯然神伤。

立我于高山之上兮,眺望远方。还看万众一心兮,不屈脊梁。

立我于高山之上兮,展望悲中奋起兮。多难兴邦,中华坚强!

说明:这首诗是今年四川的高考满分作文,今年四川以“坚强”为话题,写一篇文体不

限的文章。该考生以歌行体和楚辞体写汶川地震,并且这是一首藏头诗,第一排下来分

别是地震灾区的地名,可见其才华横溢。

【四川512地震周年祭】《悲中行》08年四川高考满分作文 - 未名空间(mitbbs.com).

Rating: 9.0/10 (1 vote cast)

The Official Palm Blog: Got opinions? Become a Real Reviewer and get a new phone courtesy of Palm

Got opinions? Become a Real Reviewer and get a new phone courtesy of Palm

Are your Facebook updates all about your experience with your phone? Do you know what “FP” means? And are your blog comments a bit more substantive than that? If you can tweet your opinions about Palm phones in 140 characters or less, we want to hear from you. Heck, now that all of Shakespeare’s plays have been condensed for Twitter, it should be a piece of cake to tweet your nuanced thoughts about your favorite phone features.

We’re looking for a few “Real Reviewers” to share their opinions about Palm phones across the blogosphere, social networks and beyond. If you’re selected as a Real Reviewer, we’ll provide you with a current-model phone and data-plan service for six months. We’ll expect you to regularly share your thoughts about your experiences with your phone on whatever blogs and social networks you frequent but you’re already doing that, right?. We might even invite you to guest blog about your experiences right here on Palm’s blog or host a discussion board on our Facebook page.

What’s the catch? There’s really just one: be yourself. Whether you’re a fanboy or a skeptic, we want to hear from you.

Ready to become a Real Reviewer? Apply here by answering a few questions about yourself. We’re looking for a mix of Palm veterans and newcomers, from all walks of life. There are a couple of restrictions, though: You must be a U.S. resident and at least 18 years old.

If you’re interested, apply now — we’ll notify selected Real Reviewers on May 8.

Jon Zilber

The Official Palm Blog: Got opinions? Become a Real Reviewer and get a new phone courtesy of Palm.

Rating: 6.0/10 (1 vote cast)

梦与诗

- 胡适

都是平常影象

偶然涌到梦中来

变幻出多少新奇花样

都是平常情感

都是平常言语

偶然碰着个诗人

变幻出多少新奇诗句

醉过才知酒浓

爱过才知情重 ——

你不能做我的诗

正如我不能做你的梦

“醉过方知酒浓,爱过方知情重”的出处及原文?_百度知道.

Rating: 9.0/10 (1 vote cast)

【让13亿多人笑死的央视现场直播】

PART 1:

老公比画老婆猜…

老公根据图板比划说:“三国演义中关羽骑的是什么马?”老婆犹豫。

老公边比画边提示:“再想想,这马吕布也曾经骑过。”

老婆突然大喊:“是貂禅!”

老公大怒:“你傻啊,我说的是白天骑的!”

(李咏当时笑翻在地……)

PART 2:

一对夫妻,猜颜色,老公比划老婆猜。大屏幕上跳出‘黄色’一词。

……老公不断比划(规则是不许言语),老婆无法理解老公的用意,怎么也猜不出……

老公急了,于是……老公描述:“李咏的内衣!”

老婆:“黄色!”

全场倒……???(怎么知道猜颜色?)

(当天李咏穿着西服,内穿略显黄色的衬衫)

PART 3:

大屏幕上跳出一个‘醋’字,老公提示老婆猜。

老公:“女人最喜欢吃男人的什么呀?”

老婆(兴高采烈、不加思索地):“豆腐”!!

全场倒……

(李咏:哇噻… …)

PART 4:

女的比划,男的猜,题板是‘宋庆龄’。

女的说:“是个女的,很漂亮!国母,她的姓是唐朝后面的那个朝代…”

男的脱口而出:“宋祖英!”

全场哗然……

(李咏:“这…这玩笑开的有点大…大了!”)

PART 5:

一对夫妻,猜食品名称,老婆比划老公猜。大屏幕上跳出‘馒头’一词

老婆描述:“圆圆的,白白的,能吃的”

老公:“……”

老婆继续描述:“就是白白的,软软的,你昨天晚上还吃来着!”

老公突然明白了什么似的,脱口而出:“mimi!”

(全场及李咏当场全部笑趴下……)

Rating: 7.0/10 (1 vote cast)

Hard Core - Exercises to Strengthen Your Abs For Better Performance

Core Set

1. Standard Crunch - Think about a string attached to your belly button & running through your body pulling your stomach towards the floor.

2. Knee-up crunches - Focus on keeping the small of your back against the floor even throughout the range of motion. SLOOOW. :)

3. Hip lifts - Keep your legs straight and don’t let them rock back as your lift your hips. YES - I’m pushing down w/ my hands so I could hold this forever for the camera, but you should put your palms facing up! :) These are tough… don’t speed through them.

4. Oblique crunches - You should feel your ribs pressing pinching into your side. Try not to fold forward, but rather bend up trying to get your elbow to touch your feet.

5. Side Plank Dips - Keep your body in a straight line (one plane) and keep the movement smooth and slow. Your hips should just touch (but not rest on!) the ground.

6. Oblique Leg Extensions - This not only works your obliques, but should also engage your piriformis & hip flexor as well. Don’t let your leg touch the ground, and when the leg is fully extended your butt should be tightly squeezed rotating your leg out ever so slightly (this is the piriformis part).

7. Supermans - Each side counts as 1/2 of a rep. Your stomach muscles should be engaged when you lift up. Think about your arm and leg not only being pulled up, but also out. Hold it at the top for 2 seconds.

8. Bridged Leg Lifts - Each leg counts as 1/2 of a rep. Keep your butt down. You don’t need to lift your legs super high.

9. Pushups - Keep your head raised and looking forward, and your body in a perfect horizontal plane. Your elbows should bend back, not out to the side.

10, 11, 12. Repeat steps 4, 5, and 6, but do the other side.

13.  Heel Touches - Each heel touch counts as 1/2 of a rep. Keep your shoulder blades off the ground, remember to breathe, and make sure your feet are far enough away from you that you have to really reach to touch the heel.

14. Bicycle Crunches - Each leg counts as 1/2 of a rep. Each twist w/ leg extension should take you long enough to say “one one thousand” to yourself, no faster. Try to keep your shoulder blades off the ground.

15. Half Up Twists - Sit up, put your hands on top of your knees and then lean back until your arms are straight. Cross your arms in front of you (each hand holding an elbow) and start twisting! Each side counts as 1/2 of a rep.

http://www.beginnertriathlete.com/cms/article-detail.asp?articleid=486

Rating: 9.5/10 (2 votes cast)

Itune Install Error - Simple Solution

I think I am not the only poor soul to meet this problem. OK, if you have seen

There is a problem with this windows Installer package,
A program run as part of the setup did not finish as
expected. Contact your support personnel or package
vendor.

then, you know what I am talking about. After downloading the Apple Itune package, I just can not install it. So stupid. Quick way to fix:

Control Panel -> Uninstall your QuickTime.

Yes, unintall your QuickTime not the Itune. Then you give it shot, you now should be able to install the new version of Itune.

Rating: 5.0/10 (1 vote cast)

C# delegate 委托变量的用法

using System;

//C#中的委托类似于C或C++中的函数指针,但两者有本质区别:C或C++不是类型安全的,但C#中的委托是面向对象的,而且是类型安全的。
//从技术角度来讲==>委托是一个引用类型,用来封装带有特定签名和返回类型的方法

namespace qinmi
{
public delegate int mydelegateTest(int i, int j);//声明一个委托
class calculate
{
public static int add(int i, int j)
{
return i + j;
}
public static int minus(int i, int j)
{
return i - j;
}
}

class test
{
static void Main(string[] args)
{
mydelegateTest delegatehe = new mydelegateTest(calculate.add);//声明委托实例,并用calculate.add对其实例化,实际就是将委托和方法连接起来
int he = delegatehe(100, 9);//开始调用委托,就像是使用静态成员方法calculate.add(int i,int j)一样
Console.WriteLine(”方法add的结果:{0}”, he);

mydelegateTest delegatecha = new mydelegateTest(calculate.minus);
int cha = delegatecha(100, 9);
Console.WriteLine(”方法minus的结果:{0}”, cha);
Console.ReadKey();
}
}
}

一点心得:感觉NET比ASP多了点东西,编程思想虽然说是面向对象,不过最基本的还是一个逻辑在里面,多了的一些东西其实也就是把一些东西给封装了起来,调用就更加方便了,列给级别先,从大到小:命名空间->委托->方法->属性…大致就这样

原文:
Rating: 4.0/10 (1 vote cast)

java的hashCode方法

首先,想要明白hashCode的作用,你必须要先知道Java中的集合。总的来说,Java中的集合(Collection)有两类,一类是List,再有一类是Set。你知道它们的区别吗?前者集合内的元素是有序的,元素可以重复;后者元素无序,但元素不可重复。那 么这里就有一个比较严重的问题了:要想保证元素不重复,可两个元素是否重复应该依据什么来判断呢?这就是Object.equals方法了。但是,如果每 增加一个元素就检查一次,那么当元素很多时,后添加到集合中的元素比较的次数就非常多了。也就是说,如果集合中现在已经有1000个元素,那么第1001 个元素加入集合时,它就要调用1000次equals方法。这显然会大大降低效率。     于是,Java采用了哈希表的原理。哈希算法也称为散列算法,是将数据依特定算法直接指定到一个地址上。如果详细讲解哈希算法,那需要更多的文章篇幅,我 在这里就不介绍了。初学者可以这样理解,hashCode方法实际上返回的就是对象存储的物理地址(实际上并不是真正的在内存的物理地址,不过可以这样理 解)。     这样一来,当集合要添加新的元素时,先调用这个元素的hashCode方法,就一下子能定 位到它应该放置的物理位置上。如果这个位置上没有元素,它就可以直接存储在这个位置上,不用再进行任何比较了;如果这个位置上已经有元素了,就调用它的 equals方法与新元素进行比较,相同的话就不存了,不相同就散列其它的地址。所以这里存在一个冲突解决的问题。这样一来实际调用equals方法的次数就大大降低了,几乎只需要一两次。     所以,

Java对于eqauls方法和hashCode方法是这样规定的:

1、如果两个对象相同,那么它们的hashCode值一定要相同;

2、如果两个对象的hashCode相同,它们并不一定相同     上面说的对象相同指的是用eqauls方法比较。 你当然可以不按要求去做了,但你会发现,相同的对象可以出现在Set集合中。同时,增加新元素的效率会大大下降。

如果你改写了equal()方法,令两个实际不是一个对象的两个实例在逻辑上相等了,但是hashcode却是不等。

所以要记得改写hashcode。

不改写会带来什么后果呢?当然,比如你在用hashmap,hashtable之类的设计hashcode的类的时候,就会出麻烦了。

至于如何改写一个hashcode,这就有好有坏了,看各人的功底了。现在还有专门的人在研究优秀的hash算法。

也就是说 List 是一个有序的、可重复的对象容器接口,Set是一个无序的、不可重复的对象容器接口 。后面都讲了 Set 是如何实现不重复的 :为了避免多次重复的使用 equal 方法带来的系统负担 ,set 首先调用hashCode 方法来检测 是否被占用 如果被占用 然后调用 equal 方法判断被占用的是否相同

选自:

http://hi.baidu.com/platon/blog/item/3793bb0edd399ee437d122e1.html/cmtid/917a247fe974960e29388a6a

Rating: 4.0/10 (1 vote cast)