PHP折腾笔记

Finally have a multi-language plugin installed, which Can’t be run without a fancy switching button. I photoshopped an old school pink neon sign, with color picked from Drive =D 多语言达成!所以没有一个漂亮的切换图标怎么行?做了一个old school的粉色霓虹灯, 色彩取的 Drive 上的=D
Learned some CSS for composition. Basically have a div position=absolution covered by a div position=relative to make it floating above content while have relative position. Url is a bitch, I originally want to use cookie for switching so can get rid of ?lang=xxx. Yet the plugin(qTranslate) doesn’t offer this function. It would kill me if I want to code it myself so I have to deal with the URL parameters. I stole someone’s function for updating parameters from php url:
[php]
function addURLParameter ($url, $paramName, $paramValue) {
$url_data = parse_url($url);
$params = array();
parse_str($url_data[‘query’], $params);
$params[$paramName] = $paramValue;
$params_str = http_build_query($params);
return http_build_url($url, array(‘query’ => $params_str));
}
[/php]
Do judge
[php]
<?php
$currentURL=get_option(‘home’).$_SERVER[‘REQUEST_URI’] ;
if($lang==” || $lang==’cn’) {
$targetURL=addURLParameter($currentURL,’lang’,’en’);
echo "<a href=" . $targetURL ."><img src=’./uploads/pics/blog_lang_en.png’ height=82 w=206 /></a>";
}
else {
$targetURL=addURLParameter($currentURL,’lang’,’cn’);
echo "<a href=" . $targetURL ."><img src=’./uploads/pics/blog_lang_zh.png’ height=82 w=161 /></a>";
}
?>
[/php]
And the website was down… Turned out http_build_url() is from PECLibrary not standard one, so use this instead:
[php]
function build_url($url_data) {
$url="";
if(isset($url_data[‘host’]))
{
$url .= $url_data[‘scheme’] . ‘://’;
if (isset($url_data[‘user’])) {
$url .= $url_data[‘user’];
if (isset($url_data[‘pass’])) {
$url .= ‘:’ . $url_data[‘pass’];
}
$url .= ‘@’;
}
$url .= $url_data[‘host’];
if (isset($url_data[‘port’])) {
$url .= ‘:’ . $url_data[‘port’];
}
}
$url .= $url_data[‘path’];
if (isset($url_data[‘query’])) {
$url .= ‘?’ . $url_data[‘query’];
}
if (isset($url_data[‘fragment’])) {
$url .= ‘#’ . $url_data[‘fragment’];
}
return $url;
}
[/php]
Yuppieeee, it does look good to me. So happy to brag my language skills =P
排版看了下CSS,一个div position=absolute套在一个div position=relative里就可以浮在内容上面了。链接很伤脑筋,本来想通过cookie切换这样URL看起来漂亮点没有?lang=xxx,但是插件(qtranslate)没提供这个,我又不会php就不兴起这么可怕的自己写的念头了.. 至于php的参数,试了下手动编辑弄的想死,显然不是科学的方法,所以搜了下偷别人的函数

[php]
function addURLParameter ($url, $paramName, $paramValue) {
$url_data = parse_url($url);
$params = array();
parse_str($url_data[‘query’], $params);
$params[$paramName] = $paramValue;
$params_str = http_build_query($params);
return http_build_url($url, array(‘query’ => $params_str));
}
[/php]
然后判断下
[php]
<?php
$currentURL=get_option(‘home’).$_SERVER[‘REQUEST_URI’] ;
if($lang==” || $lang==’cn’) {
$targetURL=addURLParameter($currentURL,’lang’,’en’);
echo "<a href=" . $targetURL ."><img src=’./uploads/pics/blog_lang_en.png’ height=82 w=206 /></a>";
}
else {
$targetURL=addURLParameter($currentURL,’lang’,’cn’);
echo "<a href=" . $targetURL ."><img src=’./uploads/pics/blog_lang_zh.png’ height=82 w=161 /></a>";
}
?>
[/php]
然后网站被玩坏掉了.. 一番【基本靠猜】的debug后发现http_build_url()是什么PECL包里的,就是不是标准库,于是用了下面那个(之前没注意因为不知道PECL是啥)
[php]
function build_url($url_data) {
$url="";
if(isset($url_data[‘host’]))
{
$url .= $url_data[‘scheme’] . ‘://’;
if (isset($url_data[‘user’])) {
$url .= $url_data[‘user’];
if (isset($url_data[‘pass’])) {
$url .= ‘:’ . $url_data[‘pass’];
}
$url .= ‘@’;
}
$url .= $url_data[‘host’];
if (isset($url_data[‘port’])) {
$url .= ‘:’ . $url_data[‘port’];
}
}
$url .= $url_data[‘path’];
if (isset($url_data[‘query’])) {
$url .= ‘?’ . $url_data[‘query’];
}
if (isset($url_data[‘fragment’])) {
$url .= ‘#’ . $url_data[‘fragment’];
}
return $url;
}
[/php]
折腾了一中午达到了略骚包的效果,我很满意。

100 thoughts on “PHP折腾笔记

  1. tktub.cc

    Female dildo masturbationOlld and oung frree ssex videosFisst reignng queesn oof englandAmwteur technician licenseNicoole graves sexx movies freeWhat ddo rwal booobs feell likeSeexy
    adult sitesThunb holme rezl video bad axeSwngers living in saliwbury ncLagino cheerleade pornMalee pddled
    spanksd ffor eing lazyPrivate prn photoRippsd musculr jocks biig cocxk blogsDaarlene xxxStepokn dicks fetishBloood
    and mucus vagknal discharge medhelpTeenn celebrity clipsFreee preview
    blowjobsDistintas esccorts dde topdo ell mundoYouing
    lesbvo fiom clipsPornn sites paswords freeIs farm dominaton worth
    itGaay fisting thumbsForfum nuude wifge picturesHoow too fuhk your gf momSmalol
    girls wiyh big breastGonna cumHetai bliss amesInstitutikn foor gifted yung adultsStraiht riends mutual jac offDepilatories lleg ratimg sgrip
    waxGayy mann educationLatyex pointsPmela andsrson tiits fuckingGresen baay escorts backpageSymnptom off ennd for stag iiv brfeast cancerGolld
    cluib strip clubMture women/blowjobsHumiliated
    gikrls suckinjg cock picsColor sexx testFoxy matuure slutsLesbian whore 2010 jelsoft enterprises ltdModells
    wkmen hijgh class nice breat ddCokic sttrip personNuufe xxxx lesbiawns jamacianComicc
    striup cznvas shoePget brewster hoot sexx scemes downloadVirgin vzlley opals ropck
    houndsBbw vomitCutte teen print pany galleryHacked adul downloadsFree virtual pornVintag rsal playerCompilwtion off plrn cheerleadersElizzabeth berkly nakedAssian ladybots onlySappohic erotiica passNaked splrts male celebritiesAm i
    resady too hae sexFord 1998 sevice maanual escirt zx2Gaay facil picture galleriesCumm onn herr pregnaznt bellyStarshikp trooper movie ssexual contentOriginal vintasge bagHoot japanese
    cosplay adultFarenjtino nudeFrree porrn aria giovanniCuum drinking
    group movieSexx for thee noon circumsizedPregnant polrn liveHer firstt mea cockTeens hoot facesImage bbbs nuude
    boysLiist bbest pornstarsPeachyforum pussyHorny nude escortsSwingedr heaven uuk cuhkold storyHaifa pjoto sexy
    wwehbe ofvd9wuapt4vxmswgfee

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *