小编sam*_*azi的帖子

"不要直接访问Superglobal $ _REQUEST数组." Netbeans 8.0 PHP

在阅读了其他几个问题后,我们会问这个问题.

不要直接访问超全局$ _GET数组

在Netbeans 7.4 for PHP上"不要直接访问Superglobal $ _SERVER数组"

为什么filter_input()不完整?

我已经加载了最新版本Netbeans 8.0,我看到了一个警告

不要直接访问Superglobal $ _REQUEST数组.

太棒了,我很高兴能在我做一些可以改进的事情时出现,所以我看看hints.

这个建议很简单.

请改用一些过滤函数(例如filter_input(),带有_*()函数的条件等).

所以我开始研究fliter_input()它尚未实现$_REQUEST.这似乎有点死路一条.

然后我读了一些非常有帮助的东西(@bobince)" 在你的脚本开始过滤时,你不知道你的输入最终会在哪里,所以你不知道如何逃避它. "

它提醒我,我确切地知道我的输入最终会在哪里,以及它将用于什么.所以,我想问问每个人我将采取的方法是否基本上是safe.

我正在设计一个REST- ish API,我$_SERVER['REQUEST_METHOD'];用来确定需要返回的资源.我也使用$_REQUEST['resource'];它应该包含的一切URI/api/跟随.htaccess rewrite.

我对我的方法的问题是:

  1. 如果我总是验证$_SERVER['REQUEST_METHOD'];是否符合要求GET PUT POST DELETE(无论如何我都需要做),是否真的存在不填写输入的问题?
  2. 我应该$_REQUEST['resource'];通过使用来访问filter_input (INPUT_GET, 'resource');吗?当这只用于确定资源,以及无法确定资源的地方(比如有人试图添加恶意代码)时,我们根本找不到资源并返回404 Not Found状态.
  3. 我是否需要考虑其他因素,并且错过了我理解中的任何重要事项?

我意识到,对于仅被视为警告的内容,这看起来似乎很多,但是根据我的经验,只修复错误将为您提供工作代码,但修复警告将帮助您理解代码的工作原理.

php netbeans

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

PHP5 MySql和PDO异常

我在使用PDO与PHP5.4和MySql时遇到了异常.

我已经阅读了几乎所有其他帖子,博客,手册,片段,我可以与此错误相关的所有内容,并尝试了我所看到的一切,但没有运气.

所以我希望它特定于我在特定代码中做错的事情,你可以向我指出.

这是错误:

SQLSTATE [HY000]:常规错误:2014在其他未缓冲的查询处于活动状态时无法执行查询.考虑使用PDOStatement :: fetchAll().或者,如果您的代码只是针对mysql运行,则可以通过设置PDO :: MYSQL_ATTR_USE_BUFFERED_QUERY属性来启用查询缓冲.

以下是导致此错误的代码部分:

第一部分:

        $stmt = $this->dbConn->prepare("CALL getPopularProducts()");
        $stmt->execute();
        $rows = $stmt->fetchAll(\PDO::FETCH_ASSOC);

        //$stmt->closeCursor();

        foreach ($rows as $row) {
            $p = new entity\LightingPole();
             /* doing basic set stuff here so code omitted */

            // apply category to product
            $categroyTranslator = new ProductCategoryTranslator();
            $categroyTranslator->applyProductCategory($p);
Run Code Online (Sandbox Code Playgroud)

第二部分:

        public function applyProductCategory(entity\Product $product) {
            $productId = $product->getProductId();
            try {
               /** exception thrown on this line **/
               $stmt = $this->dbConn->prepare("CALL getCategoryByProductId(?)"); 

               $stmt->bindParam(1, $productId, \PDO::PARAM_INT);
               $stmt->execute();

               while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)){ …
Run Code Online (Sandbox Code Playgroud)

php mysql pdo

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

Android Intent.createChooser 不适用于 Intent.ACTION_SEND

ListView我有一个 Android 应用程序,我正在通过自定义将办公地点加载到Adapter.

在每个图标中ListViewItem,我都有ImageView一个电子邮件图标,并且我已将自定义绑定OnClickListener到该图标,该ImageView图标应允许用户创建电子邮件以发送到办公地点。

我希望用户能够从其设备上的电子邮件应用程序中进行选择,因此我Intent.CreateChooser()在自定义中使用了OnClickListener如下所示:

    private class EmailOnClickListener implements OnClickListener {
        private Context context;
        private String email;

        public EmailOnClickListener(Context context, String email) {
            this.context = context;
            this.email = email;
        }

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_SEND);
            intent.setType("message/rfc822");
            intent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] {email});
            intent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Test Subject");

            context.startActivity(Intent.createChooser(intent, "Send mail..."));
        }
    }
Run Code Online (Sandbox Code Playgroud)

我已经OnClickListener通过我的自定义绑定了我的自定义Adapter,如下所示:

    ImageView email = (ImageView) v.findViewById(R.id.btnEmail);
    email.setOnClickListener(new …
Run Code Online (Sandbox Code Playgroud)

android android-intent

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

Android Nexus 5设备上的React Native Dev菜单

我有一个基本的react-native应用程序,我在真正的Nexus 5上运行,我找不到一种方法来启用现有的开发人员菜单iOS和模拟设备.

https://facebook.github.io/react-native/docs/debugging.html

https://facebook.github.io/react-native/docs/running-on-device.html

方法1:使用adb reverse(推荐)
如果您的设备运行的是Android 5.0(Lollipop),它已启用USB调试,并且它通过USB连接到您的开发机器,则可以使用此方法.

在命令提示符中运行以下命令:

$ adb reverse tcp:8081 tcp:8081您现在可以使用React Native in-app Developer菜单中的Reload JS而无需任何其他配置.

当我跑步时,react-native run-android我在终端看到这一行

Running adb -s 06adb216 reverse tcp:8081 tcp:8081

但我看到没有 React Native in-app Developer菜单

我在跑步:

Windows 10
react-native-cli: 2.0.1
react-native: 0.42.0
Run Code Online (Sandbox Code Playgroud)

我的index.android.js文件看起来像这样:

import { AppRegistry } from 'react-native';
import Welcome from './src/modules/onboarding/components/welcome';

AppRegistry.registerComponent('mobileapp', () => Welcome);
Run Code Online (Sandbox Code Playgroud)

android nexus-5 windows-10 react-native react-native-android

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