Warning: require_once(includes/EliteScript.php) [function.require-once]: failed to open stream: No such file or directory in

会有一股神秘感。 提交于 2019-12-02 03:15:37

问题


This is a licence based script and it has a valid licence using SourceGuardian. The script was working fine on client's old server and he hired me to migrate it to the new server.

After migrating, everything was working fine but not the login area, when trying to login it gives the follow error

Warning: require_once(includes/EliteScript.php) [function.require-once]: failed to open stream: No such file or directory in /home/sitetalk/public_html/interface/index.php on line 3

Fatal error: require_once() [function.require]: Failed opening required 'includes/EliteScript.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/sitetalk/public_html/interface/index.php on line 3

Registration works fine and can see the filled data in database. Tried to take it to the script developer, but there's no response since 3months.

Not sure, what causing this error to happen. Pasting the part of code of the shown file names.

EliteScript.php

    <?php
global $config;
global $country_array;
error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING ^ E_DEPRECATED);
define("ES_VERSION", "7.0.4");
define("ES_SERVER", "http://primary.shadowscripts.com/master/server.php");
define("ES_FLASH", "/includes/graphs/src/lang/my.inc.php");
define("ES_VERIFYDEV", "eth0");
require_once("ShadowScripts.php");
require_once("interface/template.php");
spl_autoload_register(function($class)
    {
    if ($class == "EliteScriptBase")
        {
        return 0;
        }
    if ($class != "FusionCharts_Gen.php")
        {
        $class = preg_replace("/\\_/", "/", $class);
        }
    $class       = preg_replace("/\\\\/", "/", $class);
   ?>

and

index.php

<?php 
global $es;
global $ui;
global $member_id;
global $base_url;
global $member_url;
global $image_url;
global $admin_url;
require_once("includes/EliteScript.php");
$es = new EliteScript();
$ui = new UserInterface();
$es->RequireMember();
$member_id = $es->GetMemberId();
$base_url = $es->GetConfig("baseUrl");
$member_url = $es->GetConfig("memberUrl");
$image_url = $es->GetConfig("imageUrl");
$f_login_page = $es->GetLoginUIPage();
if( $f_login_page ) 
{
    $ui->ChangePage($f_login_page);
}

$es->DisplayHeader($es->getText("home_window_title"), "member.php");
switch( $_REQUEST["do"] ) 
{
    case "toggle_autorenew":
        toggle_autorenew();
        break;
    default:
        display_main();
}
$es->DisplayFooter();
echo "\r\n\r\n\r\n\r\n\r\n\r\n";
function toggle_autorenew()
{
    global $es;
    global $ui;
    global $member_id;
    global $base_url;
    global $member_url;
    global $image_url;
    global $admin_url;
    $way = $_REQUEST["way"];
    $es->ToggleMembershipAutoRenew($member_id, $way);
    $ui->SetMessage("msg", $es->getText("home_togglerenew_success"));
    $ui->ChangePage($_SERVER["PHP_SELF"]);
}

function display_main()
?>

As it says on line 3, I find nothing to edit. Please help what I can do to fix this.

Thanks


回答1:


Change this and check it is working or not

require_once("includes/EliteScript.php");

to

require_once("../includes/EliteScript.php");

Explanation current code calling current directory/includes/EliteScript.php but your file in previous directory so you have to add ../ it will include file from previous directory.




回答2:


The problem you encounter has to do with relative and absolute paths in the include and require functions of php. Your index file is requiring the EliteScript.php with a relative path.

Articles about the difference between relative and absolute:

  • php relative and absolute paths
  • PHP: Absolute vs. relative paths
  • And a comparison table: http://www.geeksengine.com/article/absolute-relative-path.html

In your comments you mention the files are encrypted, so the best way to handle this is to keep the directory structure in exact the same way as the files are given to you.

The specifically point out (as I've done in the comments) where the problem lies:

public_html/interface/index.php loads the relative path includes/EliteScript.php which therefor will require the path public_html/interface/includes/EliteScript.php however your EliteScript.php is located in public_html/includes/EliteScript.php.




回答3:


The other answers maybe true, but they didn't fix my problem.

I did exactly as it was showing in this article

I edited the include_path in php.ini and it's working like charm.



来源:https://stackoverflow.com/questions/30206147/warning-require-onceincludes-elitescript-php-function-require-once-failed

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!