请知悉:本文最近一次更新为 11年 前,文中内容可能已经过时。

最近公司进行OA迁移,将OA从原windows的Apache迁移到linux下的Nginx环境。原本只是设想,经过我的尝试成功迁移,但是随后而来的一些BUG让人蛋疼。因为windows不区分大小写,linux下严格区分,国语windows的编码不是UTF-8,而linux却是UTF-8,由于环境不同导致的迁移后必定会出现BUG,今天,就叙述一下解决第一个BUG的过程-天气无法获取:
1.原OA的php文件是经过Zend加密的,通过火狐的http监控插件,我将出问题的文件定位到int/weather.php,解密该文件后发现了对weather.inc.php的引用(解密办法请自行查找),故继续进入weather.inc.php文件追查问题。
2.报错关键字为“无该城市的天气数据”,进入该文件后,定位到第75行,发现是判定城市ID的。
无该城市的天气数据示意图
无该城市的天气数据示意图
3.然后就向上,分别输出涉及变量,发现$CITY_ID为空。向上看发现是调用了$CITY_LIST[]数组,再看数组发现是对应城市名到ID的。看样子是城市名没有成功传递。
回头再看weather.php,发现有城市ID$WEATHER_CITY_ID的调用。所以考虑在这个文件写个ID对应城市名的数字对应一下,并且由于有汉字出现,所以将weather.php的格式改为ANSI。于是修改后的weather.php代码如下:

<?php
/*********************/
/* */
/* Version : 5.1.0 */
/* Author : RM */
/* Comment : 071223 */
/* */
/*********************/
include_once( "inc/auth.php" );
include_once( "inc/td_core.php" );
include_once( "inc/weather.inc.php" );
$SPL_ADD_IDNAME = array('54511' => '北京', '58367' => '上海', '54517' => '天津', '57516' => '重庆', '45005' => '香港', '45011' => '澳门', '50953' => '哈尔滨', '50745' => '齐齐哈尔', '54094' => '牡丹江', '50842' => '大庆', '50774' => '伊春', '50884' => '双鸭山', '50775' => '鹤岗', '50978' => '鸡西', '50873' => '佳木斯', '50971' => '七台河', '50468' => '黑河', '50853' => '绥化', '50442' => '大兴安岭', '54161' => '长春', '54172' => '吉林', '54371' => '白山', '50936' => '白城', '54157' => '四平', '50946' => '松原', '54260' => '辽源', '50945' => '延吉', '54363' => '通化', '54342' => '沈阳', '54662' => '大连', '54453' => '葫芦岛', '54660' => '旅顺', '54346' => '本溪', '54353' => '抚顺', '54249' => '铁岭', '54347' => '辽阳', '54471' => '营口', '54237' => '阜新', '54324' => '朝阳', '54337' => '锦州', '54497' => '丹东', '54339' => '鞍山', '54338' => '盘锦', '53463' => '呼和浩特', '54102' => '乌兰浩特', '53446' => '包头', '54218' => '赤峰', '50527' => '阿拉善左旗', '53512' => '乌海', '53543' => '鄂尔多斯', '54103' => '锡林浩特', '54135' => '通辽', '55135' => '集宁', '55136' => '临河', '55137' => '呼伦贝尔', '53698' => '石家庄', '54534' => '唐山', '54401' => '张家口', '54515' => '廊坊', '53798' => '邢台', '53892' => '邯郸', '54616' => '沧州', '54702' => '衡水', '54423' => '承德', '54602' => '保定', '54449' => '秦皇岛', '57083' => '郑州', '57091' => '开封', '57073' => '洛阳', '57171' => '平顶山', '53982' => '焦作', '53990' => '鹤壁', '53986' => '新乡', '53898' => '安阳', '54900' => '濮阳', '57089' => '许昌', '57186' => '漯河', '57051' => '三门峡', '57178' => '南阳', '58005' => '商丘', '57297' => '信阳', '57195' => '周口', '57290' => '驻马店', '57190' => '济源', '54823' => '济南', '54857' => '青岛', '54830' => '淄博', '54775' => '威海', '54938' => '临沂', '54765' => '烟台', '58024' => '枣庄', '54806' => '聊城', '54915' => '济宁', '54906' => '菏泽', '54827' => '泰安', '54945' => '日照', '54736' => '东营', '54714' => '德州', '54734' => '滨州', '54828' => '莱芜', '54843' => '潍坊', '53772' => '太原', '53782' => '阳泉', '53976' => '晋城', '53778' => '晋中', '53868' => '临汾', '53959' => '运城', '53882' => '长治', '53578' => '朔州', '53674' => '忻州', '53487' => '大同', '53579' => '吕梁', '58238' => '南京', '58357' => '苏州', '58356' => '南通', '58259' => '徐州', '58377' => '镇江', '58027' => '淮安', '58346' => '盐城', '58352' => '泰州', '58151' => '无锡', '58246' => '连云港', '58245' => '扬州', '58343' => '常州', '58131' => '宿迁', '58321' => '合肥', '58326' => '巢湖', '58221' => '蚌埠', '58424' => '安庆', '58311' => '六安', '58236' => '滁州', '58336' => '马鞍山', '58203' => '阜阳', '58204' => '亳州', '58205' => '黄山', '58433' => '宣城', '58429' => '铜陵', '58116' => '淮北', '58334' => '芜湖', '58122' => '宿州', '58224' => '淮南', '58427' => '池州', '57036' => '西安', '53955' => '韩城', '57245' => '安康', '57127' => '汉中', '57016' => '宝鸡', '57048' => '咸阳', '53646' => '榆林', '57045' => '渭南', '57143' => '商洛', '53947' => '铜川', '53845' => '延安', '53614' => '银川', '53817' => '固原', '53704' => '中卫', '53518' => '石嘴山', '53612' => '吴忠', '52889' => '兰州', '52896' => '白银', '53829' => '庆阳', '52533' => '酒泉', '57006' => '天水', '52679' => '武威', '52652' => '张掖', '50741' => '合作', '52984' => '临夏', '53915' => '平凉', '52995' => '定西', '52675' => '金昌', '52885' => '武都', '52866' => '西宁', '52754' => '海北', '52737' => '海西', '56065' => '黄南', '56043' => '果洛', '56029' => '玉树', '52875' => '海东', '52856' => '海南', '57494' => '武汉', '57461' => '宜昌', '57498' => '黄冈', '57447' => '恩施', '57476' => '荆州', '57362' => '神农架', '57256' => '十堰', '57590' => '咸宁', '57278' => '襄樊', '57482' => '孝感', '57381' => '随州', '58407' => '黄石', '57377' => '荆门', '57496' => '鄂州', '57397' => '天门', '57398' => '仙桃', '57399' => '潜江', '57687' => '长沙', '57766' => '邵阳', '57662' => '常德', '57972' => '郴州', '57649' => '吉首', '57780' => '株洲', '57763' => '娄底', '57773' => '湘潭', '57866' => '永州', '57585' => '岳阳', '57872' => '益阳', '57749' => '衡阳', '57771' => '怀化', '57558' => '黔阳', '57678' => '张家界', '58457' => '杭州', '58450' => '湖州', '58549' => '金华', '58563' => '宁波', '58646' => '丽水', '58453' => '绍兴', '58633' => '衢州', '58452' => '嘉兴', '58660' => '台州', '58477' => '舟山', '58659' => '温州', '58606' => '南昌', '57786' => '萍乡', '58502' => '九江', '58637' => '上饶', '58617' => '抚州', '57799' => '吉安', '58627' => '鹰潭', '57793' => '宜春', '57796' => '新余', '58527' => '景德镇', '57993' => '赣州', '58847' => '福州', '59134' => '厦门', '58927' => '龙岩', '58834' => '南平', '58846' => '宁德', '58946' => '莆田', '59137' => '泉州', '58828' => '三明', '59126' => '漳州', '57816' => '贵阳', '57806' => '安顺', '57609' => '黔西', '57713' => '遵义', '56693' => '铜仁', '57707' => '六盘水', '57825' => '毕节', '57827' => '凯里', '57826' => '都匀', '56294' => '成都', '57602' => '泸州', '57504' => '内江', '56571' => '凉山', '56171' => '阿坝', '57313' => '巴中', '57206' => '广元', '56386' => '乐山', '56196' => '绵阳', '56198' => '德阳', '56666' => '攀枝花', '56287' => '雅安', '56492' => '宜宾', '56396' => '自贡', '56146' => '甘孜', '57328' => '达州', '56298' => '资阳', '57415' => '广安', '57405' => '遂宁', '56391' => '眉山', '57411' => '南充', '59287' => '广州', '59493' => '深圳', '59312' => '潮州', '59082' => '韶关', '59658' => '湛江', '59298' => '惠州', '59280' => '清远', '59289' => '东莞', '59473' => '江门', '59659' => '茂名', '59278' => '肇庆', '59501' => '汕尾', '59293' => '河源', '59315' => '揭阳', '59117' => '梅州', '59485' => '中山', '59269' => '德庆', '59663' => '阳江', '59471' => '云浮', '59488' => '珠海', '59316' => '汕头', '59276' => '佛山', '59432' => '南宁', '57957' => '桂林', '59051' => '柳州', '59046' => '梧州', '59265' => '玉林', '59453' => '贺州', '59254' => '钦州', '59065' => '贵港', '59632' => '防城港', '59249' => '百色', '59635' => '北海', '59211' => '河池', '59023' => '来宾', '59425' => '崇左', '56778' => '昆明', '56748' => '保山', '56768' => '楚雄', '56844' => '德宏', '56975' => '红河', '56951' => '临沧', '56533' => '怒江', '56783' => '曲靖', '56994' => '文山', '56875' => '玉溪', '56586' => '昭通', '56651' => '丽江', '56751' => '大理', '56752' => '普洱', '56753' => '景洪', '56754' => '中甸', '59758' => '海口', '59948' => '三亚', '59845' => '儋州', '59757' => '琼山', '59941' => '通什', '59856' => '文昌', '59857' => '东方', '59858' => '临高', '59859' => '澄迈', '59860' => '昌江', '59861' => '白沙', '59862' => '琼中', '59863' => '定安', '59864' => '屯昌', '59865' => '琼海', '59867' => '保亭', '59868' => '万宁', '59869' => '陵水', '59870' => '西沙', '59873' => '南沙岛', '59876' => '乐东', '51463' => '乌鲁木齐', '51076' => '阿勒泰', '51628' => '阿克苏', '51368' => '昌吉', '52203' => '哈密', '51828' => '和田', '51709' => '喀什', '51243' => '克拉玛依', '51356' => '石河子', '51133' => '塔城', '51656' => '库尔勒', '51573' => '吐鲁番', '51531' => '伊宁', '51535' => '博乐', '51538' => '阿拉尔', '51539' => '阿图什', '55591' => '拉萨', '55437' => '阿里', '56137' => '昌都', '55299' => '那曲', '55578' => '日喀则', '55598' => '山南', '56312' => '林芝', '58968' => '台北', '59356' => '高雄', '59357' => '台南', '59358' => '台中', '59359' => '桃园', '59360' => '新竹', '59361' => '宜兰', '59363' => '嘉义', '59365' => '花莲', '59366' => '台东 ');
if ( $UPDATE == "1" )
{
$query = "update USER set WEATHER_CITY='".$WEATHER_CITY_ID."' where USER_ID='{$LOGIN_USER_ID}'";
exequery( $connection, $query );
}
$WEATHER_CITY = $SPL_ADD_IDNAME[$WEATHER_CITY_ID];
$RESULT = cache_weather( $WEATHER_CITY);
ob_end_clean( );
if ( $RESULT !== TRUE )
{
echo "error:".$RESULT;
exit( );
}
tdoa_weather( $WEATHER_CITY, $VIEW );

4.这个时候,发现问题已经解决。

PS:遇到这样的问题,先从提示信息下手,不知道怎么调出变量就直接把变量放提示信息里一并输出来看。如果遇到转码问题,可以通过

$HTML=mb_convert_encoding($HTML,"GBK","UTF-8");

或者

$WEATHER_CITY=iconv('GB2312','UTF-8',$WEATHER_CITY);

这样的方式转码了试试看,linux下都是UTF-8,有时极有可能会因为编码问题导致异常或者BUG。


如您从本文得到了有价值的信息或帮助,请考虑扫描文末二维码捐赠和鼓励。

尊重他人劳动成果。转载请务必附上原文链接,我将感激不尽。


与《通达office anywhere2010-windows迁移Nginx天气无法获取的解决过程》相关的博文:


留言

avatar
😀
😀😁😂😅😭🤭😋😘🤔😰😱🤪💪👍👎🤝🌹👌