douxian9706 2017-05-01 22:54
浏览 65
已采纳

获取异常,说无法找到设置

I get an Exception saying that settings can't be found. I need help please, I don't know how to repair that and I need it quickly.

That are my files I don't put the folders but there are in the correct folder so i don't know why i get that error, thanks if you can help me fixing this.. you can see the github of that project here : https://github.com/dialtoneuk/Syscrack2017; You can't mount it in your host because it isn't finished.

ERROR:

PHP Fatal error: Uncaught Framework\Exceptions\ApplicationException: Setting does not exist in /var/www/html/src/Application/Settings.php:181 Stack trace:

#0 /var/www/html/src/Syscrack/BetaKeys.php(119): Framework\Application\Settings::getSetting('syscrack_betake...')

#1 /var/www/html/src/Syscrack/BetaKeys.php(31): Framework\Syscrack\BetaKeys->getBetakeys()

#2 /var/www/html/cronjob/cronjob.betakeys.php(10): Framework\Syscrack\BetaKeys->__construct()

#3 {main} thrown in /var/www/html/src/Application/Settings.php on line 181

settings.json file

    {
    "filesystem_root": "{$_SERVER['DOCUMENT_ROOT']}",
    "filesystem_separator": "\/",
    "filesystem_default_extension": ".json",
    "filesystem_default_access": "0777",
    "developer_page": "developer",
    "developer_disabled": false,
    "database_connection_file": "conf\/database\/connection.json",
    "database_schema_file":"conf\/database\/databaseschema.json",
    "user_default_group": "guest",
    "user_group_admin": "admin",
    "user_group_developer": "developer",
    "user_allow_registrations": true,
    "user_require_betakey": true,
    "error_log_location": "conf\/errorlog.json",
    "error_display_page": true,
    "error_logging": true,
    "active_log_location": "conf\/activelog.json",
    "active_log_enabled": false,
    "active_log_showdeveloper": false,
    "api_use_get": true,
    "api_default_method": "endpoint",
    "api_method_length": 32,
    "logger_max_errors": "32",
    "controller_url_length": 4048,
    "controller_namespace": "Framework\\Views\\Pages\\",
    "controller_index_root": "\/",
    "controller_index_page": "index",
    "controller_page_folder": "src\/Views\/Pages\/",
    "database_driver": "mysql",
    "database_charset": "utf8",
    "database_collation": "utf8_unicode_ci",
    "database_prefix": "",
    "session_timeout": "{60 * 60 * 2}",
    "session_update_lastaction": true,
    "middlewares_enabled": true,
    "middlewares_location": "src\/Views\/Middleware\/",
    "middlewares_namespace": "Framework\\Views\\Middleware\\",
    "registration_password_length": 8,
    "facebook_enabled": true,
    "facebook_app_id": "",
    "facebook_app_secret": "",
    "facebook_app_version": "v2.8",
    "facebook_redirect_url": "http:\/\/{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI]'}",
    "online_timeframe": "{60 * 60 * 2}",
    "syscrack_game_name": "beta",
    "syscrack_bank_type": "bank",
    "syscrack_bitcoin_type": "bitcoin",
    "syscrack_market_type": "market",
    "syscrack_virus_type": "virus",
    "syscrack_npc_type": "npc",
    "syscrack_vpc_type": "vpc",
    "syscrack_cracker_type": "cracker",
    "syscrack_hasher_type": "hasher",
    "syscrack_firewall_type": "firewall",
    "syscrack_text_type": "text",
    "syscrack_cpu_type": "cpu",
    "syscrack_download_type": "download",
    "syscrack_collector_type": "collector",
    "syscrack_software_namespace": "Framework\\Syscrack\\Game\\Softwares\\",
    "syscrack_software_location": "src\/Syscrack\/Game\/Softwares\/",
    "syscrack_addressdatabase_location": "syscrack\/addressdatabase\/",
    "syscrack_bankdatabase_location": "syscrack\/bankdatabase\/",
    "syscrack_filedatabase_extension": ".json",
    "syscrack_bank_default_balance": 1000,
    "syscrack_bitcoin_live": true,
    "syscrack_bitcoin_sellprice": 500,
    "syscrack_bitcoin_buyprice": 550,
    "syscrack_bitcoin_url": "https:\/\/blockchain.info\/ticker",
    "syscrack_bitcoin_country": "USD",
    "syscrack_default_bank": 1,
    "syscrack_bank_accountnumber_length": 8,
    "syscrack_currency": "\u00a3",
    "syscrack_master_user": 1,
    "syscrack_npc_filepath": "syscrack\/npc\/",
    "syscrack_npc_page_location": "syscrack\/npc\/",
    "syscrack_log_current": "current",
    "syscrack_log_location": "syscrack\/logs\/",
    "syscrack_startup_on_verification": true,
    "syscrack_lowest_iprange": 192,
    "syscrack_whois_computer": 1,
    "syscrack_level_expert": 100,
    "syscrack_level_advanced": 50,
    "syscrack_level_normal": 50,
    "syscrack_view_location": "syscrack\/",
    "syscrack_operations_location": "src\/Syscrack\/Game\/Operations\/",
    "syscrack_operations_namespace": "Framework\\Syscrack\\Game\\Operations\\",
    "syscrack_vminer_uniquename": "vminer",
    "syscrack_vddos_uniquename": "vddos",
    "syscrack_vspam_uniquename": "vspam",
    "syscrack_collector_static": false,
    "syscrack_collector_amount": 1000,
    "syscrack_collector_btc_amount": 0.5,
    "syscrack_marketstock_location": "syscrack\/stocks.json",
    "syscrack_default_processingtime": 10,
    "syscrack_internet_page": "internet",
    "syscrack_game_page": "game",
    "syscrack_hack_speed": 5.5,
    "syscrack_statistics_file": "syscrack\/statistics.json",
    "syscrack_statistics_enabled": true,
    "syscrack_software_allowedmethods": [
        "onInstalled",
        "onUninstalled",
        "onExecute",
        "onCollect"
    ],
    "syscrack_vpc_viewcount": 5,
    "syscrack_globe_enabled": true,
    "syscrack_betakey_location":"conf\/betakeys.json",
    "sycsrack_betakey_steps":3,
    "sycsrack_betakey_length":6
}

cronjob.betakeys.php file

<?php
require_once "../vendor/autoload.php";

use Framework\Syscrack\BetaKeys;


if( php_sapi_name() == 'cli' )
{

    $betakeys = new BetaKeys();

    $betakeys->generateBetaKeys( 1000 );

    //Echo out the betakeys

    print_r( $betakeys->getBetakeys() );
}

?>

BetaKeys.php file `

/**
 * Lewis Lancaster 2017
 *
 * Class BetaKey
 *
 * @package Framework\Syscrack
 */

use Framework\Application\Settings;
use Framework\Application\Utilities\FileSystem;

class BetaKeys
{

    /**
     * @var null
     */

    private $keys = [];

    /**
     * BetaKey constructor.
     */

    public function __construct()
    {

        $this->keys = $this->getBetakeys();
    }

    /**
     * Adds the beta-key to the array and then saves
     *
     * @param $betakey
     */

    public function addBetaKey( $betakey )
    {

        $this->keys[] = $betakey;

        $this->saveBetaKeys();
    }

    /**
     * Removes a betakey from the list
     *
     * @param $betakey
     */

    public function removeBetaKey( $betakey )
    {

        foreach( $this->keys as $key=>$value )
        {

            if( $value == $betakey )
            {

                unset( $this->keys[ $key ] );
            }
        }

        $this->saveBetaKeys();
    }

    /**
     * Returns true if this beta-key exists
     *
     * @param $betakey
     *
     * @return bool
     */

    public function hasBetaKey( $betakey )
    {

        if( empty( $this->keys ) )
        {

            return false;
        }

        foreach( $this->keys as $key=>$value )
        {

            if( $value == $betakey )
            {

                return true;
            }
        }

        return false;
    }

    /**
     * Saves the betakeys
     */

    public function saveBetaKeys()
    {

        FileSystem::writeJson( Settings::getSetting('syscrack_betakey_location'), $this->keys );
    }

    /**
     * Gets the beta keys
     *
     * @return null
     */

    public function getBetakeys()
    {

        if( FileSystem::fileExists( Settings::getSetting('syscrack_betakey_location') ) == false )
        {

            return null;
        }

        return FileSystem::readJson( Settings::getSetting('syscrack_betakey_location') );
    }

    /**
     * Generates a set of Betakeys
     *
     * @param int $count
     *
     * @return array
     */

    public function generateBetaKeys( $count=1 )
    {

        $keys = [];

        for( $i = 0; $i < $count; $i++ )
        {

            $keys[] = $this->getBetakey();
        }

        return $keys;
    }

    /**
     * Generates a new betakey
     *
     * @return string
     */

    private function getBetaKey()
    {

        $key = "";

        for( $i = 0; $i < Settings::getSetting('sycsrack_betakey_steps'); $i++ )
        {

            $step = "";

            for( $k = 0; $k < Settings::getSetting('sycsrack_betakey_length'); $k++ )
            {

                $step = $step . rand(0,9 );
            }

            $key = $key . "-" . $step;
        }

        return $key;
    }
}
  • 写回答

1条回答 默认 最新

  • doutian3010 2017-05-01 23:33
    关注

    The issue is in your Settings-class. When it tries to load the settings.json file, it uses $_SERVER['DOCUMENT_ROOT'] to find the correct location.
    That value is set by the web server (since it is the web servers document root), so when you're calling the script through CLI, that value don't exist and the script won't find the correct path to the file.

    To solve it, simply add that key to the $_SERVER array in your cronjob.betakeys.php-file. Don't forget to load the settings, as well!

    <?php
    require_once "../vendor/autoload.php";
    
    use Framework\Application\Settings;
    use Framework\Syscrack\BetaKeys;
    
    // Set the document root manually 
    // (one level up since this file is in a sub directory).
    $_SERVER['DOCUMENT_ROOT'] = realpath(__DIR__ . '/..');
    
    // Now, make sure the settings get loaded!
    Settings::preloadSettings();
    
    if( php_sapi_name() == 'cli' )
    {
    
        $betakeys = new BetaKeys();
    
        $betakeys->generateBetaKeys( 1000 );
    
        //Echo out the betakeys
    
        print_r( $betakeys->getBetakeys() );
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。