小编fre*_*ed2的帖子

只有在启用缓存时,Wordpress才会返回未展开的文件

似乎是一个简单的问题,但我找不到答案.

禁用缓存后,一切正常.启用缓存后,以下javascript包含返回Wordpress"页面无效"错误.

HTTP://myserver/wp-content/plugins/myplugin/js/jquery.cycle.all.min.js

我正在使用Firefox Web开发人员工具禁用缓存,但我看不出这应该对问题有任何影响.出于某种原因,Wordpress无法找到合法的文件.

该脚本已正确注册并使用以下代码排队:

 wp_register_script("jquery.cycle.all.min.js", $plugin_url . '/js/jquery.cycle.all.min.js', 'jquery');
 wp_enqueue_script("jquery.cycle.all.min.js");
Run Code Online (Sandbox Code Playgroud)

php wordpress

7
推荐指数
1
解决办法
155
查看次数

使用Imagick创建动态图像/ Apache标头

在将现有的,稳定的网站转移到新服务器的过程中,我遇到了一些间歇性问题,其中包含一些使用Imagick动态创建图像的代码.

代码解析GET查询(例如example.com/image.php?ipid=750123&r=0&w=750&h=1000),然后缩放和旋转存储在服务器上的图像并将其提供给客户端.

ipid = id for an image stored on server
r = degrees of rotation
w = width to display
h = height to display.
Run Code Online (Sandbox Code Playgroud)

代码可能已经使用了至少5年没有问题.

在转移到一个新的,更快的服务器(从Debian Squeeze到Ubuntu 12.04)时,我遇到了一个问题,即大约50%的时间没有显示图像,而是服务器发送一个0字节的"png文件".没有PHP错误或服务器错误.

根据图像是否成功发送,将发送不同的标头:

成功的图片标题:

Connection: Keep-Alive
Content-Type:   image/png
Date:   Tue, 23 Jul 2013 17:03:32 GMT
Keep-Alive: timeout=5, max=76
Server: Apache/2.2.22 (Ubuntu)
Transfer-Encoding:  chunked
X-Powered-By:   PHP/5.3.10-1ubuntu3.7
Run Code Online (Sandbox Code Playgroud)

图像标题失败:

Connection  Keep-Alive
Content-Length  0
Content-Type    image/png
Date    Tue, 23 Jul 2013 17:03:31 GMT
Keep-Alive  timeout=5, max=78
Server  Apache/2.2.22 (Ubuntu)
X-Powered-By    PHP/5.3.10-1ubuntu3.7
Run Code Online (Sandbox Code Playgroud)

有没有人有任何想法为什么会这样?

有没有办法'强制'png图像被发送分块,因为我想知道这是否是问题的根源.我已经尝试了各种变通方法,我通过PHP的header()函数发送图像大小或"Transfer-Encoding:chunked"作为标题,但是没有用,并且在这些情况下浏览器声明图像已损坏.

<?php

//Class used …
Run Code Online (Sandbox Code Playgroud)

php apache2 imagemagick imagick

6
推荐指数
1
解决办法
1065
查看次数

使用未知数量的参数创建Laravel Eloquent Query

我正在尝试使用用户输入动态创建一个Eloquent查询,该输入根据输入的长度更改查询.使用直接MySQL这很简单......只需根据用户输入连接查询字符串.使用Eloquent是不可能的,除非你要么a)使用'raw'sql查询,这违背了使用Eloquent的目的或b)使用像eval()函数那样高度不健康的东西.

如何迭代未知长度的用户输入并创建一个Eloquent查询,使用'OR'和'AND'的组合在多个字段中搜索单词

考虑以下无法实际工作的伪代码.

$search = "cat sat on the mat";
$searchWords = explode(' ', $search);

$data['finds'] = DB::table('mytable') [... incomplete query]


foreach ($searchWords as $word) {
     ->where('firstname', 'like', '%' . $word . '%')
     ->orWhere('lastname', 'like', '%' . $word . '%')
     ->orWhere('address', 'like', '%' . $word . '%')->AND [... next word]
}
Run Code Online (Sandbox Code Playgroud)

或者只是放弃和使用原始查询?我可以为每个单词运行一个单独的查询,然后使用PHP来合并/操作结果,但这对于在传统MySQL中的一个查询中可以完成的操作来说似乎非常麻烦.

我正在尝试做的传统MySQL查询将是:

SELECT * FROM `mytable`
WHERE (firstame LIKE '%$cat%' OR lastname LIKE '%cat%' OR address LIKE '%cat%')
AND (firstname LIKE '%sat% OR lastname LIKE '%sat%' OR address LIKE …
Run Code Online (Sandbox Code Playgroud)

php mysql laravel eloquent

5
推荐指数
1
解决办法
459
查看次数

在 Thunderbird 中使用 Content-ID 和 cid 嵌入电子邮件图像

我在 PHP 应用程序中生成电子邮件,将多个文件附加到 HTML 电子邮件。一些文件是 Excel 电子表格,一些文件是需要嵌入 HTML 中的公司徽标,因此它们默认使用 Content-ID 和 cid 标识符加载以引用附加的图像。

据我所知,我的语法是正确的,但图像永远不会内联加载(但是它们已成功附加)。

From: email@example.com
Reply-To: email@example.com
MIME-Version: 1.0
Content-type: multipart/mixed;boundary="d0f4ad49cc20d19bf96d4adf9322d567"
Message-Id: <20150421165500.0A5488021B@server>
Date: Tue, 21 Apr 2015 12:54:59 -0400 (EDT)

--d0f4ad49cc20d19bf96d4adf9322d567
Content-type: text/html; charset=utf-8
Content-transfer-encoding: 8bit

<html>
    Html message goes here, followed by email.<br/>
    <img src="cid:mylogo" />
</html>
--d0f4ad49cc20d19bf96d4adf9322d567
Content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; name=excelsheet.xlsx
Content-Description: excelsheet.xlsx
Content-Disposition: attachment;
 filename="excelsheet.xlsx"; size=24712;
Content-transfer-encoding:base64

[base64 encoded string goes here.]

--b19e863e2cf66b40db1d138b7009010c
Content-Type: image/jpeg;
 name="mylogo.jpg"
Content-transfer-encoding:base64
Content-ID: <mylogo>
Content-Disposition: inline;
 filename="mylogo.jpg"; size=7579;

[base64 encoded string …
Run Code Online (Sandbox Code Playgroud)

php email thunderbird html-email email-attachments

4
推荐指数
1
解决办法
2万
查看次数

mktime在6月/ 7月产生错误的奇怪行为

我有以下笨拙的代码将日期字符串转换为另一个日期字符串.

//$invDate starts as a date string in format dd/mm/yyyy
$dateArray = explode('/', $invDate);      
$invDate = $dateArray[0] .' '.  date("F",mktime (1,1,1,$dateArray[1])) .' '. $dateArray[2];
Run Code Online (Sandbox Code Playgroud)

我并不为此感到特别自豪,但它在一个美国和英国的约会方法可能产生混淆的国家产生了一个明确的约会.

它的工作时间很长,然后突然间它已经开始转动了

01/06/2012
Run Code Online (Sandbox Code Playgroud)

1 July 2012
Run Code Online (Sandbox Code Playgroud)

我已经看过mktime的行为,并且看不出为什么mktime (1,1,1,6)要在7月份制作日期的原因.有任何想法吗?

php mktime

3
推荐指数
1
解决办法
138
查看次数

Laravel 5.5 FormRequest自定义错误消息验证不起作用

我正在使用以下标准代码来验证使用各种数组的表单。规则已正确实施,但是当使用标准的“ messages()”方法替代时,Laravel不会拾取消息,而只是返回内置的标准消息。

输出量

array (size=7)
  0 => string 'The newitems.0.pickup_date field is required.' (length=45)
  1 => string 'The newitems.0.m_f field is required when newitems.0.item type id is present.' (length=77)
  2 => string 'The newitems.1.pickup_date is not a valid date.' (length=47)
  3 => string 'The newitems.0.size field is required when newitems.0.item type id is present.' (length=78)
  4 => string 'The newitems.1.size field is required when items.1.size unknown is not present.' (length=79)
  5 => string 'The newitems.0.width field is required when newitems.0.item …
Run Code Online (Sandbox Code Playgroud)

php laravel laravel-5.5

3
推荐指数
1
解决办法
2057
查看次数

PHPExcel创建"不可读的内容"

我试图用1000种不同的方法解决这个问题.感谢是否有其他人可以发现问题.

我有使用PHPExcel的代码生成多个Excel工作表并将其保存到磁盘.

当使用MS Excel 2010打开第二个文件中的所有内容时,我收到错误"Excel在FILENAME中找到了不可读的内容.是否要恢复此工作簿的内容." 该文件已"恢复"并且工作正常.在OPEN Office开业不会产生任何错误.

这是代码的简化版本.

<?php
$filenames = array("filenames go here");

$sheet1 = PHPExcel_IOFactory::load($template1);
$writer1 = new PHPExcel_Writer_Excel2007($sheet1);
$writer1->save('somefilename.xlsx');
//This file opens without problem
$sheet1->disconnectWorksheets();
unset($sheet1);
unset($writer1);

$i = 0;
foreach($filenames as $file){
    $template = "template2.xlsx";
    $fileName = 'filename' . $i . ' .xlsx';
    $spreadsheet = PHPExcel_IOFactory::load($template);
    $objWriter = new PHPExcel_Writer_Excel2007($spreadsheet);
    $objWriter->save($fileName);
    $spreadsheet->disconnectWorksheets();
    unset($spreadsheet);
    //This file throws error when opened in Excel 2007+
    $i++;
 }
?>
Run Code Online (Sandbox Code Playgroud)

我检查过以下内容:

  1. 没有明显的php错误消息,空白或无关输入会破坏文件.
  2. 模板文件在Excel 2010中打开正常.
  3. 我尝试过使用不同的PHPExcel编写器方法,但它们都会产生同样的问题.

真正的代码完成了一大堆额外的东西,但我已经通过评论它来检查它是不负责任的.上面的代码似乎是唯一可以引入问题的地方.

任何建议都感激不尽.

==== EDITED ====这是Ex​​cel生成的错误日志:

<?xml …
Run Code Online (Sandbox Code Playgroud)

php phpexcel

1
推荐指数
1
解决办法
8632
查看次数