douzai3399 2015-12-31 04:46
浏览 27

从类中获取函数结果

I have a function inside a class, and I would like to get the result of this function, something like:

Returned dangerous functions are: dl, system

Here is my code

public final function filterFile(){

$disabled_functions = ini_get('disable_functions');

$disFunctionsNoSpace = str_replace(' ', '', $disabled_functions);

$disFunctions = explode(',', $disFunctionsNoSpace);

$this->disFunctions = $disFunctions;

// get file content of the uploaded file (renamed NOT the temporary)
$cFile = file_get_contents($this->fileDestination, FILE_USE_INCLUDE_PATH);


$found = array();

foreach($this->disFunctions as $kkeys => $vvals)
{            
    if(preg_match('#'.$vvals.'#i', $cFile))
    {                  
        array_push($found, $vvals);

    } 
} // end foreach

} // end filterFile

// calling the class
$up = new uploadFiles($filename);

$fileterringFile    = $up->filterFile();

print_r($fileterringFile);
var_dump($fileterringFile);

EDIT: add 2 functions for errors:

// check if any uErrors
public final function checkErrors(){

    $countuErrors = count($this->uErrors);

    if((IsSet($this->uErrors) && (is_array($this->uErrors) && ($countuErrors > 0))))
    {
        return true;            
    }
        return false;
} // end checkErrors()


// print user errors
public final function printErrors(){

    $countuErrors = count($this->uErrors);

    if((IsSet($this->uErrors) && (is_array($this->uErrors) && ($countuErrors > 0))))
    {

        echo '<ul>';
        foreach($this->uErrors as $uV)
        {       
            echo '<li>';
            echo $uV;
            echo '</li>';
        }
        echo '</ul>';
    }                
} // end printErrors()

Thanks in advance

  • 写回答

1条回答 默认 最新

  • doubiao1734 2015-12-31 04:59
    关注

    at the end of end filterFile, add:

    return 'Returned dangerous functions are: '.implode(',',$found);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)