风火家人开发记要

技术总结精华贴

Month: January 2019

原创, 服务器

nginx服务器upstream timed out (110: Connection timed out)以及recv() failed (104: Connection reset by peer)解决方法

upstream timed out (110: Connection timed out) while reading response header from upstream 修改 nginx.conf 或者自定义的 如 vhost/blog.windigniter.com.conf   location / { root /data/www/blog.windigniter.com; index index.php index.html index.htm; if (!-e $request_filename){ rewrite ^(.+)$ /index.php last; } proxy_read_timeout 150; } location ~ \.php$ { root /data/www/blog.windigniter.com; fastcgi_read_timeout 150; fastcgi_pass windigniter; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name; } fastcgi_pass windigniter; 的配置是根据自己定义的 upstream来决定的,如下面2所示 2. recv() failed (104: Connection reset by peer) while reading response header from upstream 修改 nginx.conf upstream windigniter { server 127.0.0.1:9000 weight=1 max_fails=60 fail_timeout=30; } 经过以上 添加 添加粗体部分的内容就可以解决,110 Connection time out 和 104 Connection reset by peer 的问题了,上次在公司处理2的时候虽然已经重启了,但还是过了几分钟才生效,未查明原因。   (234)

查看全文
PHP, 原创,

PHPOffice\PHPPresentation 使用Placeholder添加sldNum页码设置字体和页码位置BUG修复以及无法显示页码问题

被PHPPresentation的页码设置折腾了好几天,一直以为是自己的代码写的有问题,先说说目前我遇到的BUG 1.在Master或Slide中设置的Placeholder页码位置和大小无效,生成的PPT Placeholder始终在左上角0,0的位置。 2.为Placeholder设置的字体属性不生效,比如大小,居中等。 3.设置垂直居中需要不可以使用fontAlgn,不生效。 以下是解决方法: 修改文件 PHPOffice/PHPPresentation/src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php 找到方法名 protected function writeShapeText(XMLWriter $objWriter, RichText $shape, $shapeId) 1.注释代码 1)找到代码 if (!$shape->isPlaceholder()) { // p:sp\p:spPr\a:xfrm 将if一行注释 这里是设置RichText的相关位置的,注释掉就可以将位置信息应用给Placeholder,否则位置在0,0 //if (!$shape->isPlaceholder()) { // p:sp\p:spPr\a:xfrm … //} 2)找到代码 if (!$shape->isPlaceholder()) { $verticalAlign = $shape->getActiveParagraph()->getAlignment()->getVertical(); 将if一行注释 这里设置的垂直居中,如果不注释掉垂直方向无法设置位置,文字只在顶部 //if (!$shape->isPlaceholder()) { $verticalAlign = $shape->getActiveParagraph()->getAlignment()->getVertical(); … //} 2.添加代码 1)找到代码 if ($shape->isPlaceholder() && ($shape->getPlaceholder()->getType() == Placeholder::PH_TYPE_SLIDENUM || $shape->getPlaceholder()->getType() == Placeholder::PH_TYPE_DATETIME) ) { $objWriter->startElement(‘a:p’); 在其后添加下面代码,主要是水平居中,margin值得设置等等 //TODO 此处为chenxue4076@163.com手动添加,为了是页码也能够使用到样式 //TODO 1添加排版信息 $paragraph =$shape->getActiveParagraph()->getAlignment(); //a:pPr $objWriter->startElement(‘a:pPr’); $objWriter->writeAttribute(‘algn’, $paragraph->getHorizontal()); $objWriter->writeAttribute(‘fontAlgn’, $paragraph->getVertical()); $objWriter->writeAttribute(‘marL’, CommonDrawing::pixelsToEmu($paragraph->getMarginLeft())); $objWriter->writeAttribute(‘marR’, CommonDrawing::pixelsToEmu($paragraph->getMarginRight())); $objWriter->writeAttribute(‘indent’, CommonDrawing::pixelsToEmu($paragraph->getIndent())); $objWriter->writeAttribute(‘lvl’, $paragraph->getLevel()); $objWriter->startElement(‘a:lnSpc’); $objWriter->startElement(‘a:spcPct’); $objWriter->writeAttribute(‘val’, $shape->getActiveParagraph()->getLineSpacing() . “%”); $objWriter->endElement(); $objWriter->endElement(); $objWriter->endElement(); //TODO 1 END 添加排版信息 //TODO END 此处为chenxue4076@163.com手动添加,为了是页码也能够使用到样式 2)继续往下查找到代码 $objWriter->startElement(‘a:fld’); $objWriter->writeAttribute(‘id’, $this->getGUID()); $objWriter->writeAttribute(‘type’, ( $shape->getPlaceholder()->getType() == Placeholder::PH_TYPE_SLIDENUM ? ‘slidenum’ : ‘datetime’)); 在其后添加下面代码,主要是字体信息,比如加粗,字体类型,大小等信息 //TODO 此处为chenxue4076@163.com手动添加,为了是页码也能够使用到样式 //TODO 2 添加字体信息 $font = $shape->getActiveParagraph()->getFont(); // a:rPr $objWriter->startElement(‘a:rPr’); $objWriter->writeAttributeIf($font->isBold(), ‘b’, ‘1’); $objWriter->writeAttributeIf($font->isItalic(), ‘i’, ‘1’); $objWriter->writeAttributeIf($font->isStrikethrough(), ‘strike’, ‘sngStrike’); // Size $objWriter->writeAttribute(‘sz’, ($font->getSize() * 100)); // Character spacing $objWriter->writeAttribute(‘spc’, $font->getCharacterSpacing()); // Underline $objWriter->writeAttribute(‘u’, $font->getUnderline()); // Color – a:solidFill $objWriter->startElement(‘a:solidFill’); $this->writeColor($objWriter, $font->getColor()); $objWriter->endElement(); // Font – a:latin $objWriter->startElement(‘a:latin’); $objWriter->writeAttribute(‘typeface’, $font->getName()); $objWriter->endElement(); // a:rPr $objWriter->endElement(); //TODO 2 添加字体信息 //TODO END 此处为chenxue4076@163.com手动添加,为了是页码也能够使用到样式 经过以上几步设置,现在使用Placehoder 的 sldNum 已经能正常设置文字属性和位置了 下面是生成页码的函数方法,仅供参考 /** * @param PhpOffice\PhpPresentation\Slide $oSlide * @param string|array $text * @param float $width * @param float $height * @param float

查看全文