Esempio n. 1
0
 public function try_new_file($class)
 {
     global $G_LOAD_PATH;
     $file = mpf_classname_to_filename($class);
     $position = strrpos($file, "/");
     $pathmid = "page/" . substr($file, 0, $position);
     $fileName = substr($file, $position + 1);
     foreach ($G_LOAD_PATH as $pathpre) {
         $files = glob("{$pathpre}{$pathmid}/*.php");
         foreach ($files as $tmpfile) {
             $pos1 = strrpos($tmpfile, "/") + 1;
             $pos2 = strrpos($tmpfile, ".");
             $trueName = substr($tmpfile, $pos1, $pos2 - $pos1);
             if (strtolower($fileName) == strtolower($trueName)) {
                 $newClass = substr_replace($class, $trueName, strrpos($class, "_") + 1);
                 return $newClass;
             }
         }
     }
     return null;
 }
Esempio n. 2
0
/**
 * 导入v2类
 * @param string $class 类名
 * @param string $prefix 父目录
 * @param string $firelog
 * @return boolean
 */
function mpf_require_class($class, $prefix = "classes", $firelog = true)
{
    if (defined('G_LOAD_AUTO') && G_LOAD_AUTO === true) {
        return true;
    }
    if ($prefix == "classes" && class_exists($class)) {
        return true;
    }
    $file = mpf_classname_to_filename($class);
    $flag = true;
    if (!mpf_require_file("{$file}.php", $prefix)) {
        if ($firelog) {
            $logger = MPF::get_instance()->get_logger();
            //出错时的url
            $error_url = @$_SERVER['REQUEST_URI'];
            //屏蔽由于某些蜘蛛将url处理成小写时,引发的class not found
            if (preg_match('#\\.js$|\\.css$#', $error_url)) {
                return false;
            }
            //trigger_error("'$prefix/$class' not found", E_USER_ERROR);
            $http_host = @$_SERVER['HTTP_HOST'];
            $http_refer = @$_SERVER['HTTP_REFERER'];
            $logger->error("'{$prefix}/{$class}' not found error_url : {$http_host}{$error_url} refer : {$http_refer}");
            //add by jackie for more error infomation
            ob_start();
            debug_print_backtrace();
            $trace = ob_get_contents();
            ob_end_clean();
            $logger->error($trace);
        }
        return false;
    }
    return $flag;
}