Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

PHP 

Strict standards: Only variables should be passed by reference in

So this is the error I am getting basically.
[Image: zku7z8k.png]


Here is the code:
PHP Code

<?php
error_reporting
(E_STRICT);
$name = trim(strtolower($_GET['name']));


$name = str_replace(".", "\.", $name);
$name = str_replace("'", "\'", $name);
$name = str_replace("_", "\_", $name);

$log = array_pop(glob('logs/debug-*-*.log'));
$contents = file_get_contents($log);

if(
preg_match('/' . $name . '.*?-r(\d+\.\d+\.\d+\.\d+)/', $contents, $results))
{
        echo 
$results[1];
}
else
{
        
        if(
$error)
        {    
            echo 
'That user is not in our DB, please resovle them first!';
        }
}

?>

Basically, I have a folder full of logs, I want it to print out every IP that is connected with this username, but removing the duplicates and looking through all the .log files.
[Image: 42PYpC3.png]
What is the $log, value or an array?
array_pop expects an array variable (by reference), not a value.
Here is your problem...
PHP Code

<?php 
$log 
= array_pop(glob('logs/debug-*-*.log')); 

array_pop takes an argument that is passed by reference. That means you must give it a variable whereas you are just passing in an array which is returned from glob.

Changing it to the following should fix the issue:

PHP Code

<?php 
$filesArray 
= glob('logs/debug-*-*.log');
$log = array_pop($filesArray); 
Now it wont print out anything :/
[Image: 42PYpC3.png]
Either im confused, or :

a) there is no array to remove from
b) $log = array_pop(glob('logs/debug-*-*.log')); will end up in an empty array since its removing all log files.

Shouldnt it be like this? :

PHP Code

<?php 
$logs 
= glob('logs/debug-*-*.log');
foreach (
$logs as $log) {
$contents = file_get_contents($log);

if(
preg_match('/' . $name . '.*?-r(\d+\.\d+\.\d+\.\d+)/', $contents, $results))
{
        echo 
$results[1];
        
array_pop($log); // not even sure if this is needed
}
else
{
        
        if(
$error)
        {    
            echo 
'That user is not in our DB, please resovle them first!';
        }
}
} 


Possibly Related Threads...
Thread / Author Replies Views Last Post
[The Brotherhood] by VinavilMar 27, 2026 09:05 AM 25 849 Mar 27, 2026 09:05 AM
Last Post: Vinavil
[Javascript]  by SIM-1517830Feb 3, 2021 02:48 PM 17 446 Feb 3, 2021 02:48 PM
Last Post: SIM-1517830
[Javascript]  by Nemo2478Nov 18, 2020 02:18 AM 2 89 Nov 18, 2020 02:18 AM
Last Post: vorticalbox