我得到一个异常,说无法找到设置。我需要帮助,我不知道如何修复它,我很快就需要它。
这是我的文件我没有放文件夹,但有正确的文件夹,所以我不知道为什么我得到了这个错误,谢谢你,如果你可以帮我修复这个..你可以看到那个github项目在这里:https://github.com/dialtoneuk/Syscrack2017; 您无法将其安装在主机中,因为它尚未完成。
错误:
PHP致命错误:未捕获的Framework \ Exceptions \ ApplicationException:/var/www/html/src/Application/Settings.php:181中不存在设置 堆栈跟踪:
#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} 在第181行的/var/www/html/src/Application/Settings.php中抛出
settings.json文件
{
"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文件
<?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文件 `
/**
* 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;
}
}
答案 0 :(得分:1)
问题出在您的设置类中。当它尝试加载settings.json
文件时,会使用$_SERVER['DOCUMENT_ROOT']
来查找正确的位置
该值由Web服务器设置(因为它是Web服务器文档根目录),因此当您通过CLI调用脚本时,该值不存在且脚本无法找到正确的文件路径。
要解决此问题,只需将该密钥添加到$_SERVER
文件中的cronjob.betakeys.php
数组即可。不要忘记加载设置!
<?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() );
}