小编Jef*_*eff的帖子

会话cookie http和安全标志 - 你如何设置这些?

刚收到安全审计的结果 - 除了两件事之外,一切都清楚了

没有http标志的会话cookie.

会话cookie没有安全标志设置.

应用程序在php中编码,修复建议如下:

  1. 使用仅http标志设置会话cookie
  2. 用安全标志设置会话cookie

我查看了示例,但没有完全理解如何在Linux服务器上实现.我无法访问.ini文件.是否可以在htaccess文件中设置它们?

或者,我在代码中实现的方式和位置?

php linux security

30
推荐指数
3
解决办法
5万
查看次数

warning feof()期望参数1是资源

我的错误日志失控,出现以下两个错误

warning feof() expects parameter 1 to be resource
Run Code Online (Sandbox Code Playgroud)

warning fread() expects parameter 1 to be resource
Run Code Online (Sandbox Code Playgroud)

负责的代码是

<?php
    $file = '../upload/files/' . $filex;
    header("Content-Disposition: attachment; filename=" . urlencode($file));
    header("Content-Type: application/force-download");
    header("Content-Type: application/octet-stream");
    header("Content-Type: application/download");
    header("Content-Description: File Transfer");
    header("Content-Length: " . filesize($file));
    flush(); // this doesn't really matter.

    $fp = fopen($file, "r");
    while (!feof($fp)) {
        echo fread($fp, 65536);
        flush(); // this is essential for large downloads
    }
    fclose($fp);
?> 
Run Code Online (Sandbox Code Playgroud)

我使用这个代码进行标题下载,但它现在吓坏了 - 在任何人询问我尝试过之前,我试过google但仍然不完全理解错误消息.

php error-handling

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

php函数不会多次工作

我已经创建了一个函数,可以从用户ID中为我提供用户名.不同的用户ID将在while循环中,因此该函数将被多次使用.它适用于一个用户ID,但如果有多个用户ID,则会给我一个错误.错误是"警告:mysql_select_db():提供的参数不是有效的MySQL-Link资源"

代码是

<?php 

function user_details($user_id) {

require_once('../Connections/runner.php'); 

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string   ($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . …
Run Code Online (Sandbox Code Playgroud)

php mysql

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

标签 统计

php ×3

error-handling ×1

linux ×1

mysql ×1

security ×1