风火家人开发记要

技术总结精华贴

Month: December 2011

CMS, 原创

codeigniter(CI)刷新页面新增空session数据解决方案codeigniter(CI) refurbish page new session data added resolvent

使用codeigniter(CI)开发网站,使用自带session时会出现写seesion失败,但数据库中添加空session,每次刷新页面都会新增。 这个问题产生是由于手册给到的帮助信息中创建session表的时候有个字段的长度不够造成的,只要修改这个长度就可以了, CREATE TABLE IF NOT EXISTS `ci_sessions` ( session_id varchar(40) DEFAULT ‘0’ NOT NULL, ip_address varchar(16) DEFAULT ‘0’ NOT NULL, user_agent varchar(50) NOT NULL, last_activity int(10) unsigned DEFAULT 0 NOT NULL, user_data text DEFAULT ” NOT NULL, PRIMARY KEY (session_id) ); 将user_agent varchar(50) NOT NULL,的字段长度改到255吧,50太少了,查看网站上,他至少也是60多个字符。use codeigniter(CI)to develop website, session writed failed,and session table of database be added empty session,every time you refurbish page. this is because you use the example of handbook about session,you need to change something. CREATE TABLE IF NOT EXISTS `ci_sessions` ( session_id varchar(40) DEFAULT ‘0’ NOT NULL, ip_address varchar(16) DEFAULT ‘0’ NOT NULL, user_agent varchar(50) NOT NULL, last_activity int(10) unsigned DEFAULT 0 NOT NULL, user_data text DEFAULT ” NOT NULL, PRIMARY KEY (session_id) ); change 50 to 255 in this string : user_agent varchar(50) NOT NULL.Hope it can help you. (1350)

查看全文
CMS, 原创

记事狗微薄同步到新浪一直40009 system error, does multipart has image 解决方案

记事狗同步新浪Error: 40009:Error: system error, does multipart has image?解决方案 如果你也在用记事狗,也在为同步新浪图片而大动肝火,不要着急了,我花了3天时间终于把这个问题搞定了,而你就不用那么费事费力去研究了,听我说说把, 经过一步一步测试,最终将问题定位到了 include/xwb/lib 下面的 oauth.class.php 这里面在处理图片的时候出现里错误,错误的行数是 510 多行左右,看下面代码 其实是个foreach 循环问题 foreach ($params as $parameter => $value) { if( ($parameter == ‘pic’ || $parameter == ‘image’) ){ if(is_string($value) && $value{0} == ‘@’) { $url = ltrim( $value , ‘@’ ); $ctx_userAgent = isset($_SERVER[‘HTTP_USER_AGENT’]) ? $_SERVER[‘HTTP_USER_AGENT’] : ‘Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 3.5.30729)’; if( version_compare(PHP_VERSION, ‘5.0.0’, ‘>=’) ){ $ctx_header = “Accept: *”.”/”.”*\r\nAccept-Language: zh-cn\r\nUser-Agent: {$ctx_userAgent}\r\n”; $ctx = stream_context_create(array(‘http’=>array(‘timeout’=>8,’method’=>’GET’,’header’=>$ctx_header))); $content = file_get_contents( $url, 0, $ctx); }else{ @ini_set(‘user_agent’, $ctx_userAgent); $content = file_get_contents( $url ); } $filename = reset( explode( ‘?’ , basename( $url ) )); $mime = OAuthUtil::get_image_mime($url); } elseif(is_array($value)) { $content = $value[2]; $filename = $value[1]; $mime = $value[0]; } //exit($content.’|’.$filename.’|’.$mine.’|’.$value); $multipartbody .= $MPboundary . “\r\n”; //$multipartbody .= ‘Content-Disposition: form-data; name=”‘.$parameter.'”; filename=”‘ . $filename . ‘”‘. “\r\n”; $multipartbody .= ‘Content-Disposition: form-data; name=”‘.$parameter.'”; filename=”‘ . $value . ‘”‘. “\r\n”; //$multi partbody .= ‘Content-Type: ‘. $mime . “\r\n\r\n”; $multipartbody .= ‘Content-Type: ‘. ‘multipart/form-data’ . “\r\n\r\n”; $multipartbody .= $content. “\r\n”; } else { $multipartbody .= $MPboundary . “\r\n”; $multipartbody .= ‘Content-Disposition: form-data; name=”‘.$parameter.”\”\r\n\r\n”; $multipartbody .= $value.”\r\n”; } } 只要将这部分用新浪api提供的里面的这个东西替换就可以了,下面是替换成的代码 foreach ($params as $parameter => $value) { //if( $parameter == ‘pic’ && $value{0} == ‘@’

查看全文