草庐IT

php - 拉维尔 5.2 : How to get the role of current user when using `Zizaco/entrust` ?

我正在使用Laravel5.2和Zizaco/entrust5.2,我的问题是:使用Zizaco/entrust时如何获取当前用户的角色?名称和角色.phpnamespaceApp\Services;useApp\User;useApp\Role;useZizaco\Entrust\EntrustRole;useIlluminate\Support\Facades\Cache;classNameAndRole{public$username;public$role;publicfunction__construct(){$user=\Auth::user();$this->userna

PHP 和 mySQLi : Do I still need to check user input when using prepare statements?

如果我在mySQLi中使用prepare语句,我是否仍然需要以任何方式转义或检查用户输入。例如,如果我有代码:$members=newmysqli("localhost","user","pass","members");$r_email=$_POST['r_email'];$check=$members->prepare("selectuser_idfromuserswhereemail=?");$check->bind_param('s',$r_email);$check->execute();$check->store_result();if($check->num_rows>0

php - Yii 框架 : Using data from related Active Record models for searching

Yii1.1applicationdevelopmentCookbook解释了一种使用来自相关ActiveRecord模型的数据来搜索相关模型的方法。此方法在第193和194页中进行了说明。我已尝试将此方法集成到我的应用程序中,但它不起作用。谁能解释一下这个功能在Yii框架版本1.1.8中是否仍然可用在这个位置,我还可以找到用于从相关事件记录模型中搜索数据的注释。但它也不起作用。http://www.yiiframework.com/doc/api/1.1/CDbCriteria我有订单表和用户表订单表和用户表是一对多的关系。用户有很多订单,订单只有一个用户。因此,我正在编辑CDbCr

php - Symfony2 : new instance at each service call instead of using the same

我创建了一个服务,但每次调用它时,它都会创建一个新实例,而不是使用同一个实例。这是我的services.yml:my.sessiondata:class:My\Bundle\Service\SessionDatacalls:-[setServices,[@security.context,@service_container,@session,@doctrine.orm.entity_manager]]scope:container还有我的服务:namespaceMy\Bundle\Service;classSessionData{protected$company;publicfun

php - 谷歌网站管理员 API : How to impersonate using server to server request?

我可以使用通过网络服务请求授予的访问token访问网站管理员的googleAPI网站列表,现在我想通过服务器到服务器请求来完成.在授予服务器帐户访问列表的权限后,我无法使用以下范围正确使用setAssertionCredentials:'https://www.googleapis.com/auth/webmasters'案例一模拟用户帐户时:$cred->sub='user.account@gmail.com';PHP客户端返回'ErrorrefreshingtheOAuth2token,message:'{"error":"unauthorized_client","error_d

php - 警告 : openssl_pkcs7_sign(): error getting private key using WAMP

我正在尝试使用TCPDF签署PDF,但出现此错误:Warning:openssl_pkcs7_sign():errorgettingprivatekeyinC:\wamp\www\tcpdf\tcpdf.phponline7594.我的PHP版本是5.5.12和TCPDF6.2.11。Windows7。其他示例运行良好,但失败了。我试过:'file://'.(dirname(FILE)).'./path/to/file'andagain$certificate='file://'.realpath('../tcpdf.crt');但对我不起作用。 最佳答案

php - 是否有可能实现 SSL (wss ://) using PHP socket extension?

我有一个websocket服务器,使用PHP的socket库实现,并且一切正常...只要您使用的是ws://协议(protocol)。但是,我们现在需要升级库以通过SSL工作,即支持wss://协议(protocol)。是否有可能使用PHPsocket实现wss://(或者更一般地说,我想是SSL连接)函数,或者我们是否需要重写代码以使用stream_socket函数?(请注意,切换到stream_socket可能还有其他充分的理由,因此无论答案如何,我们都可以考虑这样做。但是,在我花时间评估这两个选项之前,我想确认坚持使用socket甚至是我们的一个选择。)

php - 初学者 : Limit URL parameter by using regular expression

我需要一些关于正则表达式的帮助来限制用户为输入传递糟糕的参数时的选择。例如路径是这样的:/project/create/:category(:category是参数的占位符,因此我可以在我的Controller中访问它)基本上我想要做的是将URL与该类别的2个选项(报价|请求)之一相匹配。这使得用户尝试执行404重定向的任何其他路径都能正常工作。只允许这些选择的正则表达式需要是什么?(提供|请求)'/\/component\/create\/(offer|request)/'-会成功吗?提前致谢 最佳答案 从您表达问题的方式来看,您

php - Symfony2 : Validating a date using the Form Validator returns error

我在我的表单中添加了一个类型为“日期”的元素,然后它有一个验证规则,该规则指定表单元素值必须是日期类型,否则返回错误。然而,Symfony并没有处理验证,而是返回了一个异常。见下面的代码:用户类型.php$builder->add('startdate','date',array('label'=>'StartDate','widget'=>'single_text','format'=>'yyyy-MM-dd'));验证.ymlAcme\StoreBundle\Entity\User:properties:startdate:-Date:message:Youmustspecifya

php - 亚马逊 S3 : Monitor my bucket's current disk and bandwidth usage using PHP?

是否可以使用PHP创建基本脚本,以便在特定存储桶已经使用AmazonS3的100GB磁盘或100GB带宽时我可以收到警报(例如通过电子邮件)? 最佳答案 您可以使用亚马逊的php库以编程方式获取存储桶的大小。http://docs.amazonwebservices.com/AWSSDKforPHP/latest/#m=AmazonS3/get_bucket_filesize是如何做的一个例子。使用上面的示例,您可以创建一个简单的函数来获取所有存储桶的大小。如果它们超过您的尺寸阈值,您可以给自己发送一封电子邮件。如果您使用的是基于u