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