donglie7778 2019-02-22 20:35
浏览 56

PHP版本已弃用

Any ideas for these 2 functions, they stopped working due to PHP version upgrade

function read_str($fp)
{
   $strlen = $this->bin2dec(fread($fp, 4), 4);
   return fread($fp, $strlen);
}

and

function read_byte($fp)
{
  return $this->bin2dec(fread($fp, 1), 1);
}

And old script that I am trying to workaround.

Error the server is output

"[22-Feb-2019 20:24:38 UTC] PHP Strict Standards: Only variables should be passed by reference in /? on line 2884 [22-Feb-2019 20:24:38 UTC] PHP Strict Standards: Only variables should be passed by reference in /? on line 2860 "

Here are the 2 functions

    /*!
     * @function read_byte
     * @abstract Reads a byte from a file
     * @param fp  file pointer - pointer to an open file
     * @result the read byte as an int
     */
     function read_byte($fp)
     {
     return $this->bindec(fread($fp, 1), 1);
     }

     /*!
     * @function read_str
     * @abstract Reads a string from a file
     * @param fp  file pointer - pointer to an open file
     * @result the read string
     */
     function read_str($fp)
     {
     $strlen = $this->bindec(fread($fp, 4), 4);
     return fread($fp, $strlen);
     }

Here is the actual file been used in which it is calling the error above.

    <?php
    if(ereg("[a-zA-Z0-9]",$event))
    {

    //returns highest key in the database
    function getMaxKey($db) {

    $maxKey = 0;

    $sortby = "event_key";
    $result = $db->getall();

    foreach($result as $item){
       $key = $item["event_key"];
       if($key > $maxKey)
          $maxKey = $key;
    }

    return $maxKey;
    }

    // Include the FFDB library
    include("../ffdb.inc.php");

    //open db or create new db
    $db = new FFDB();
    if (!$db->open("../calendar"))
    {
       // Define the database shema.
       // Note that the "last_name" field is our key.
       $schema = array(
          array("_key", FFDB_INT, "key"),
          array("_name", FFDB_STRING),
          array(_year", FFDB_INT)
       );

       // Try and create it...
       if (!$db->create("calendar", $schema))
       {
          echo "Error creating database
";
          return;
       }
    }

    //if no key file create a new one
    if(!file_exists("key.dat"))
    {
     $newKey = getMaxKey($db);
     $newFile = fopen("key.dat", "w") Or die("Can't open file");
     fwrite($newFile,$newKey);
     fclose($newFile);

    }

    //add a record
    //convert forms to record
     $fileread = fopen("key.dat", "r")Or die("Can't open file");
     $data = (int) fread($fileread, 10);
     fclose($fileread);
     $data++;
     $fileread = fopen("key.dat", "w") Or die("Can't open file");
     fwrite($fileread,$data);
     fclose($fileread);

     //add the record
     $record["_key"] = $data;
     $record["_name"] = ucwords($event);
     list($record["_year"]) = sscanf($year, "%d"); // string -> int

     // Add a _new_ entry
     echo("");
     if (!$db->add($record))
     echo("failed!
");
     else {

     //table to display after adding
     $addedTable ="

Thank you

  • 写回答

1条回答 默认 最新

  • duanci8209 2019-02-22 20:49
    关注

    The error is saying already, you are passing $fp which is a fsocketopen probably by open a binary file ... this is forbidden.

    The bin2dec is a local custom private function since is called with $this->.

    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么