我似乎无法使用PHP安全地绑定到Active Directory.未加密的连接工作正常.使用其他客户端可以安全绑定,例如通过SSL使用LDAPAdmin进行连接.这里有什么问题?是否有一些我缺少的LDAP SSL模块?如何使用PHP安全绑定到服务器?
我注意到phpinfo()cURL支持ldap/ldaps - 利用它在php中执行安全绑定有什么好的例子?这是一个可行的解决方法吗?
的phpinfo();
ldap
LDAP Support enabled
RCS Version $Id: ldap.c 293036 2010-01-03 09:23:27Z sebastian $
Total Links 0/unlimited
API Version 3001
Vendor Name OpenLDAP
Vendor Version 20421
SASL Support Enabled
Run Code Online (Sandbox Code Playgroud)
尝试使用Ubuntu 10.04 repo中的PHP版本5.3.2-1ubuntu4.7绑定到Active Directory服务器
$username = 'user';
$password = 'passwd';
$account_suffix = '@example.com';
$hostnameSSL = 'ldaps://ldap.example.com:636';
$hostnameTLS = 'ldap.example.com';
$portTLS = 389;
ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7);
// Attempting fix from http://www.php.net/manual/en/ref.ldap.php#77553
putenv('LDAPTLS_REQCERT=never');
####################
# SSL bind attempt #
####################
// Attempting syntax from http://www.php.net/manual/en/function.ldap-bind.php#101445 …Run Code Online (Sandbox Code Playgroud) 我在.htaccess中有一个重写规则
RewriteRule (.+?\.fid)/ /$1 [L]
Run Code Online (Sandbox Code Playgroud)
使用请求URI,如: /123.fid/myfile.webm
如何强制mime类型:video/webm使用.htaccess包括上面的规则?
我已经尝试过,添加.htaccess文件的TOP但没有成功:
AddType video/webm .webm
Run Code Online (Sandbox Code Playgroud)
和
<FilesMatch "\.webm$">
ForceType video/webm
</FilesMatch>
Run Code Online (Sandbox Code Playgroud)
我使用apaches mime_magic模块查找mime类型的.fid文件,但这不适用于webm文件.我假设它是RewriteRule导致文件类型出现问题,我需要以某种方式在请求uri中查找webm.
如果我这样做:AddType video/webm .fid发送正确的mime类型 - 但这会破坏存储在.fid中的任何其他文件格式.使用.fid是设计要求,不能更改.
*编辑:
我也尝试过:
RewriteCond %{REQUEST_URI} \.webm$
RewriteRule .* - [T=video/webm]
Run Code Online (Sandbox Code Playgroud)
和
RewriteRule \.webm$ - [T=video/webm]
Run Code Online (Sandbox Code Playgroud)
结果相同.服务的哑剧类型是text/plain.这可能是mime_magic模块的interfiering吗?
我还尝试添加:DefaultType video/webm哪个有效.这是目前最接近解决方案的东西,因为mime_magic模块似乎找到了要发送的正确mime类型,但我发现这不是一个特别优雅的解决方案
*Edit2:AddType video/webm .fidIS工作 - 如何根据请求uri有条件地执行AddType?
使用php.net中的示例我收到警告,图像无法正确呈现.我提供了.ttf文件的完整路径,如下所示:/var/www/public/myfont.ttf
PHP Warning: imagettftext() [<a href='function.imagettftext'>function.imagettftext</a>]: Could not find/open font in <phpfile>
Run Code Online (Sandbox Code Playgroud)
我使用发现了一个自定义的字体名为.ttf 这里.我可以在Ubuntu中将文件打开为有效的字体文件.我也尝试了其他字体,结果相同.
我正在使用Ubuntu 10.04 LTS 32位,安装了apache2,php5,freetype6和php5-gd.我还尝试使用ttf文件chmod 777文件和文件夹,结果相同.
如何使用自定义ttf字体文件使示例工作?
*编辑:我正在使用的代码:
<?php
// File is: /var/www/public/test.php
// Apart from $font variable, it's copy-pasted from php.net
// Set the content-type
header('Content-Type: image/png');
// Create the image
$im = imagecreatetruecolor(400, 30);
// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, …Run Code Online (Sandbox Code Playgroud) 我在Zend MVC中表现不佳而苦苦挣扎.
我设置了一个控制器,只有这个die(),我启用了xdebug,并根据我的请求提取了webgrind,告诉我:
789 different functions called in 2150 milliseconds (1 runs, 137 shown)
Run Code Online (Sandbox Code Playgroud)
我在确定究竟花了这么长时间的问题时遇到了问题:
[procedural] {main} O 1 9 2150
[class] Zend_Application_Bootstrap_BootstrapAbstract->_bootstrap O 5 7 1203
[class] Zend_Config_Ini->_processKey O 622 451 1191
[class] Zend_Config_Ini->_processSection O 2 49 1023
[class] Zend_Application_Bootstrap_BootstrapAbstract->_executeResource O 16 11 1017
Run Code Online (Sandbox Code Playgroud)
(上面几乎告诉我这是我的application.ini中定义的引导程序启动类 - 但我不知道哪些是慢的)
有什么方法可以精确地确定代码中占用大量处理时间的步骤?
如何列出Gearman作业服务器上的所有作业句柄?我正在尝试提出一种监控方法,我可以在其中列出所有正在运行的线程,并轮询其状态.
列出具有'status'和'workers'的运行作业(如http://gearman.org/index.php?id=protocol中所述)列出了函数和worker,但没有作业句柄.需要工作句柄才能进行GET_STATUS等.
我正在尝试将作业提交与监视分离,因此没有在JOB_CREATED数据包中返回的作业句柄.
我有一个包含文件的数据库,可以在多个服务器上搜索,浏览和拥有多个副本.
我缓存搜索,浏览页面和服务器位置(网址).假设我删除了一个文件,有什么方法可以使所有搜索无效,浏览此文件的数据和网址?或者如果文件服务器出现故障,我需要使指向此服务器的所有URL无效?
基本上我正在寻找类似于memcache-tags的东西,但是使用标准的memcache和php组件.(无需更改Web服务器本身的任何内容).在键之间我需要某种多对多的关系(一个服务器有很多文件,一个文件有多个服务器),但似乎无法找到实现这一目标的好方法.在某些情况下,过时的缓存是可接受的(次要更新等),但在某些情况下,它不是(通常是删除和服务器关闭)我需要使包含对它的引用的所有缓存项无效.
我看过的一些方法:
命名空间:
$ns_key = $memcache->get("foo_namespace_key");
// if not set, initialize it
if($ns_key===false) $memcache->set("foo_namespace_key", rand(1, 10000));
// cleverly use the ns_key
$my_key = "foo_".$ns_key."_12345";
$my_val = $memcache->get($my_key);
//To clear the namespace do:
$memcache->increment("foo_namespace_key");
Run Code Online (Sandbox Code Playgroud)
$files = array('file1','file2');
// Cache all files as single entries
foreach ($files as $file) {
$memcache->set($file.'_key');
}
$search = array('file1_key','file2_key');
// Retrieve all items found by search (typically cached as file ids)
foreach ($search as $item) {
$memcache->get($item);
} …Run Code Online (Sandbox Code Playgroud) 我的目标是要求登录某些页面.我正在使用Zend Framework MVC,我正在尝试找到有关最佳实践的示例.
关于我正在寻找的一些注意事项:
或者完全不同的东西.我是Zend框架的新手,我想以"正确的方式"做到这一点.
如何填充php://input二进制数据以测试上传?(或以其他方式测试分块上传).我使用plupload作为我的前端,我想对我的后端进行单元测试.
这是我要测试的代码段:
public function recieve($file = 'file')
{
// Get parameters
$chunk = isset($_REQUEST["chunk"]) ? intval($_REQUEST["chunk"]) : 0;
$chunks = isset($_REQUEST["chunks"]) ? intval($_REQUEST["chunks"]) : 0;
$fileName = isset($_REQUEST["name"]) ? $_REQUEST["name"] : '';
$targetDir = $this->_uploadDir;
// Clean the fileName for security reasons
$fileName = preg_replace('/[^\w\._]+/', '_', $fileName);
// Make sure the fileName is unique but only if chunking is disabled
if ($chunks < 2 && file_exists($targetDir . DIRECTORY_SEPARATOR . $fileName)) {
$ext = strrpos($fileName, '.');
$fileName_a …Run Code Online (Sandbox Code Playgroud) 我正在努力使用Doctrine 2表演HYDRATE_OBJECT.当我切换HYDRATE_ARRAY到HYDRATE_OBJECT,它需要将近10倍!我使用了doctrine 2和zend paginator作为参考:
$query = $em->createQuery($dql)
->setHydrationMode(\Doctrine\ORM\AbstractQuery::HYDRATE_ARRAY)
->setParameter('x', 1);
// Pagination
$paginator = new Doctrine\ORM\Tools\Pagination\Paginator($query, false);
$iterator = $paginator->getIterator();
die(); // 160 ms
Run Code Online (Sandbox Code Playgroud)
VS
$query = $em->createQuery($dql)
->setHydrationMode(\Doctrine\ORM\AbstractQuery::HYDRATE_OBJECT)
->setParameter('x', 1);
// Pagination
$paginator = new Doctrine\ORM\Tools\Pagination\Paginator($query, false);
$iterator = $paginator->getIterator();
die(); // 1.4s
Run Code Online (Sandbox Code Playgroud)
我应该注意什么?如何减少处理时间仍然使用HYDRATE_OBJECT?是否有更好的方法来完成分页?
*编辑:使用->setFirstResult($itemsPerPage * $page - $itemPerPage)->setMaxResults($itemsPerPage);显着减少加载时间,但使用时$iterator:
$adapter = new \Zend_Paginator_Adapter_Iterator($iterator);
$zend_paginator = new \Zend_Paginator($adapter);
$zend_paginator->setItemCountPerPage($itemsPerPage)
->setCurrentPageNumber($page);
Run Code Online (Sandbox Code Playgroud)
Zend只知道$itemsPerPage,(count($iterator) == …
如何"停止"html5视频播放,并恢复为海报图片?在this.play()调用之前,海报图像正确显示.
我的代码:
<video loop="loop" onMouseOver="this.play();" onMouseOut="this.pause();" poster="/oceans-clip.thumb.jpg">
<source src="/oceans-clip.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"' />
<source src="/oceans-clip.webm" type='video/webm; codecs="vp8, vorbis"' />
</video>
Run Code Online (Sandbox Code Playgroud)
这是按预期工作,但我想恢复到onMouseOut上的海报图片而不是暂停视频.这样做的好方法是什么?
class a
{
public function f(&$ref1, &$ref2)
{
$ref1 = 'foo';
$ref2 = 'bar';
}
}
class b
{
public function __call($methodName, $arguments)
{
$a = new a();
call_user_func_array(array(
$a, $methodName
), $arguments);
}
}
$ref1 = 'X';
$ref2 = 'Y';
$b = new b();
$b->f($ref1, $ref2);
var_dump($ref1, $ref2);
Run Code Online (Sandbox Code Playgroud)
这导致:
PHP Warning: Parameter 1 to a::f() expected to be a reference, value given in /home/jon/sync_workspace/bugsync/tests/test.php on line 18
PHP Stack trace:
PHP 1. {main}() /test.php:0
PHP 2. b->f() /test.php:23
PHP …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用ffmpeg从mp4文件创建一个1s剪辑到mpeg,但是我收到一个错误:
ffmpeg -i /tmp/myfile.mp4 -y -ss 00:00:01 -t 00:00:01.000 /tmp/myfilesplit.1.mpg
ffmpeg version N-31716-g318fd9d, Copyright (c) 2000-2011 the FFmpeg developers
built on Aug 1 2011 16:10:33 with gcc 4.4.5
configuration: --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-nonfree --enable-postproc --enable-version3 --enable-x11grab --enable-libvpx
libavutil 51. 11. 1 / 51. 11. 1
libavcodec 53. 9. 0 / 53. 9. 0
libavformat 53. 6. 0 / 53. 6. 0
libavdevice 53. 2. 0 / 53. 2. 0
libavfilter 2. 27. 5 / …Run Code Online (Sandbox Code Playgroud) 我在命令行中运行Zend Framework操作时遵循示例2 ,我遇到了致命错误
Fatal error: Zend_Controller_Router_Exception: Route logout is not defined
Run Code Online (Sandbox Code Playgroud)
使用我在application.ini中定义的自定义路由和导航
resources.router.routes.logout.route = logout
resources.router.routes.logout.defaults.controller = authentication
resources.router.routes.logout.defaults.action = logout
resources.navigation.pages.logout.label = "Logout"
resources.navigation.pages.logout.controller = "authentication"
resources.navigation.pages.logout.action = "logout"
resources.navigation.pages.logout.route = "logout"
resources.navigation.pages.logout.resource = "logout"
Run Code Online (Sandbox Code Playgroud)
我已将错误原因缩小到此引导函数:
protected function _initRouter ()
{
if (PHP_SAPI == 'cli') {
$this->bootstrap ('frontcontroller');
$front = $this->getResource('frontcontroller');
require_once APPLICATION_PATH. '/router/Cli.php';
$front->setRouter (new Application_Router_Cli ());
$front->setRequest (new Zend_Controller_Request_Simple ());
}
}
Run Code Online (Sandbox Code Playgroud)
我在这做错了什么?错误仅在不使用CLI时出现(如果我删除了_initRouter(),它将按预期工作).
php ×11
video ×2
.htaccess ×1
apache ×1
caching ×1
doctrine-orm ×1
ffmpeg ×1
file-upload ×1
gearman ×1
html5 ×1
html5-video ×1
imagettftext ×1
javascript ×1
ldap ×1
memcached ×1
mime-types ×1
mod-rewrite ×1
mp4 ×1
mpeg ×1
overloading ×1
performance ×1
phpunit ×1
plupload ×1
profiling ×1
reference ×1
ssl ×1
ubuntu ×1
upload ×1
webm ×1