Ir para conteúdo
  • 0

Erro no configphp.php


M4Go

Pergunta

to tentando por site local para fazer test de alterações, estou usando o xampp 3.2.1

ta dano esse erro

 Parse error: syntax error, unexpected '}', expecting ',' or ';' in C:\xampp\htdocs\xampp\www\classes\configphp.php on line 30
o config ta assim

 

 

 

 

if(!defined('INITIALIZED'))

exit;

 

class ConfigPHP extends Errors

{

private $config;

private $loadedFromPath = 'C:\Ot\';

 

public function __construct($path = false)

{

if($path)

$this->loadFromFile($path);

}

 

public function loadFromFile($path)

{

if(Website::fileExists($path))

{

$content = Website::getFileContents($path);

$this->loadedFromPath = $path;

$lines = explode("\n", $content);

unset($lines[0]); // remove <?php

unset($lines[count($lines)]); // remove ? >

$this->loadFromString(implode("\n", $lines));

}

else

WebsiteErrors::addError('#C-4', 'ERROR: <b>#C-4</b> : Class::ConfigPHP - PHP config file doesn\'t exist. Path: <b>' . $path . '</b>');

 

}

 

public function fileExists($path)

{

return Website::fileExists($path);

}

 

public function loadFromString($string)

{

$ret = @eval('$_web_config = array();' . chr(0x0A) . $string . chr(0x0A) . '');

if($ret === false)

{

$error = error_get_last();

new Error_Critic('', ' - cannot load PHP config from string', array(

new Error('MESSAGE', $error['message']),

new Error('FILE', $error['file']),

new Error('LINE', $error['line']),

new Error('FILE PATH', $this->loadedFromPath)

));

}

$this->config = $_web_config;

unset($_web_config);

}

 

private function parsePhpVariableToText($value)

{

if(is_bool($value))

return ($value) ? 'true' : 'false';

elseif(is_numeric($value))

return $value;

else

return '"' . str_replace('"', '\"' , $value) . '"';

}

 

public function arrayToPhpString(array $a, $d)

{

$s = '';

if(is_array($a) && count($a) > 0)

foreach($a as $k => $v)

{

if(is_array($v))

$s .= self::arrayToPhpString($v, $d . '["' . $k . '"]');

else

$s .= $d . '["' . $k . '"] = ' . self::parsePhpVariableToText($v) . ';' . chr(0x0A);

}

return $s;

}

 

public function getConfigAsString()

{

return self::arrayToPhpString($this->config, '$_web_config');

}

 

public function saveToFile($path = false)

{

if($path)

$savePath = $path;

else

$savePath = $this->loadedFromPath;

Website::putFileContents($savePath, '<?php' . chr(0x0A) . $this->getConfigAsString() . '?>');

}

 

public function getValue($key)

{

if(isset($this->config[ $key ]))

return $this->config[ $key ];

else

new Error_Critic('#C-5', 'ERROR: <b>#C-5</b> : Class::ConfigPHP - Key <b>' . $key . '</b> doesn\'t exist.');

}

 

public function setValue($key, $value)

{

$this->config[ $key ] = $value;

}

 

public function removeKey($key)

{

if(isset($this->config[ $key ]))

unset($this->config[ $key ]);

}

 

public function isSetKey($key)

{

return isset($this->config[ $key ]);

}

 

public function getConfig()

{

return $this->config;

}

 

public function setConfig($value)

{

$this->config = $value;

}

}

 

 

Editado por M4Go
Link para o comentário
Compartilhar em outros sites

3 respostass a esta questão

Posts Recomendados

  • 0

 

if(!defined('INITIALIZED'))
exit;

class ConfigPHP extends Errors
{
private $config;
private $loadedFromPath = 'C:\Ot\';

public function __construct($path = false)
{
if($path)
$this->loadFromFile($path);
}

public function loadFromFile($path)
{
if(Website::fileExists($path))
{
$content = Website::getFileContents($path);
$this->loadedFromPath = $path;
$lines = explode("\n", $content);
unset($lines[0]); // remove unset($lines[count($lines)]); // remove ? >
$this->loadFromString(implode("\n", $lines));
}

public function fileExists($path)
{
return Website::fileExists($path);
}

public function loadFromString($string)
{
$ret = @eval('$_web_config = array();' . chr(0x0A) . $string . chr(0x0A) . '');
if($ret === false)
{
$error = error_get_last();
new Error_Critic('', ' - cannot load PHP config from string', array(
new Error('MESSAGE', $error['message']),
new Error('FILE', $error['file']),
new Error('LINE', $error['line']),
new Error('FILE PATH', $this->loadedFromPath)
));
}
$this->config = $_web_config;
unset($_web_config);
}

private function parsePhpVariableToText($value)
{
if(is_bool($value))
return ($value) ? 'true' : 'false';
elseif(is_numeric($value))
return $value;
else
return '"' . str_replace('"', '\"' , $value) . '"';
}

public function arrayToPhpString(array $a, $d)
{
$s = '';
if(is_array($a) && count($a) > 0)
foreach($a as $k => $v)
{
if(is_array($v))
$s .= self::arrayToPhpString($v, $d . '["' . $k . '"]');
else
$s .= $d . '["' . $k . '"] = ' . self::parsePhpVariableToText($v) . ';' . chr(0x0A);
}
return $s;
}

public function getConfigAsString()
{
return self::arrayToPhpString($this->config, '$_web_config');
}

public function saveToFile($path = false)
{
if($path)
$savePath = $path;
else
$savePath = $this->loadedFromPath;
Website::putFileContents($savePath, 'getConfigAsString() . '?>');
}

public function getValue($key)
{
if(isset($this->config[ $key ]))
return $this->config[ $key ];
else
new Error_Critic('#C-5', 'ERROR: #C-5 : Class::ConfigPHP - Key ' . $key . ' doesn\'t exist.');
}

public function setValue($key, $value)
{
$this->config[ $key ] = $value;
}

public function removeKey($key)
{
if(isset($this->config[ $key ]))
unset($this->config[ $key ]);
}

public function isSetKey($key)
{
return isset($this->config[ $key ]);
}

public function getConfig()
{
return $this->config;
}

public function setConfig($value)
{
$this->config = $value;
}
}

 

Link para o comentário
Compartilhar em outros sites

  • 0

Fiz o que os dois pediram

deu esse erro agora =x

 

 

 

 

if(!defined('INITIALIZED')) exit; class ConfigPHP extends Errors { private $config; private $loadedFromPath = 'C:\Ot\'; public function __construct($path = false) { if($path) $this->loadFromFile($path); } public function loadFromFile($path) { if(Website::fileExists($path)) { $content = Website::getFileContents($path); $this->loadedFromPath = $path; $lines = explode("\n", $content); unset($lines[0]); // remove unset($lines[count($lines)]); // remove ? > $this->loadFromString(implode("\n", $lines)); } public function fileExists($path) { return Website::fileExists($path); } public function loadFromString($string) { $ret = @eval('$_web_config = array();' . chr(0x0A) . $string . chr(0x0A) . ''); if($ret === false) { $error = error_get_last(); new Error_Critic('', ' - cannot load PHP config from string', array( new Error('MESSAGE', $error['message']), new Error('FILE', $error['file']), new Error('LINE', $error['line']), new Error('FILE PATH', $this->loadedFromPath) )); } $this->config = $_web_config; unset($_web_config); } private function parsePhpVariableToText($value) { if(is_bool($value)) return ($value) ? 'true' : 'false'; elseif(is_numeric($value)) return $value; else return '"' . str_replace('"', '\"' , $value) . '"'; } public function arrayToPhpString(array $a, $d) { $s = ''; if(is_array($a) && count($a) > 0) foreach($a as $k => $v) { if(is_array($v)) $s .= self::arrayToPhpString($v, $d . '["' . $k . '"]'); else $s .= $d . '["' . $k . '"] = ' . self::parsePhpVariableToText($v) . ';' . chr(0x0A); } return $s; } public function getConfigAsString() { return self::arrayToPhpString($this->config, '$_web_config'); } public function saveToFile($path = false) { if($path) $savePath = $path; else $savePath = $this->loadedFromPath; Website::putFileContents($savePath, 'getConfigAsString() . '?>'); } public function getValue($key) { if(isset($this->config[ $key ])) return $this->config[ $key ]; else new Error_Critic('#C-5', 'ERROR: #C-5 : Class::ConfigPHP - Key ' . $key . ' doesn\'t exist.'); } public function setValue($key, $value) { $this->config[ $key ] = $value; } public function removeKey($key) { if(isset($this->config[ $key ])) unset($this->config[ $key ]); } public function isSetKey($key) { return isset($this->config[ $key ]); } public function getConfig() { return $this->config; } public function setConfig($value) { $this->config = $value; } }

Fatal error: Class 'ConfigPHP' not found in C:\xampp\htdocs\xampp\www\classes\website.php on line 47

 

 

com ajuda consegue resolver o erro do phpconfig

O erro agora é aqui

Fatal error: Class 'Website' not found in C:\xampp\htdocs\www\system\load.init.php on line 22

 

agradeço se poder ajudar novamente

 

 

 

 

<?php

if(!defined('INITIALIZED'))

exit;

 

$time_start = microtime(true);

session_start();

 

function autoLoadClass($className)

{

if(!class_exists($className))

if(file_exists('./classes/' . strtolower($className) . '.php'))

include_once('./classes/' . strtolower($className) . '.php');

else

new Error_Critic('#E-7', 'Cannot load class <b>' . $className . '</b>, file <b>./classes/class.' . strtolower($className) . '.php</b> doesn\'t exist');

}

spl_autoload_register('autoLoadClass');

 

//load acc. maker config to $config['site']

$config = array();

include('./config/config.php');

//load server config $config['server']

if(Website::getWebsiteConfig()->getValue('useServerConfigCache'))

{

// use cache to make website load faster

if(Website::fileExists('./config/server.config.php'))

{

$tmp_php_config = new ConfigPHP('./config/server.config.php');

$config['server'] = $tmp_php_config->getConfig();

}

else

{

// if file isn't cached we should load .lua file and make .php cache

$tmp_lua_config = new ConfigLUA(Website::getWebsiteConfig()->getValue('serverPath') . 'config.lua');

$config['server'] = $tmp_lua_config->getConfig();

$tmp_php_config = new ConfigPHP();

$tmp_php_config->setConfig($tmp_lua_config->getConfig());

$tmp_php_config->saveToFile('./config/server.config.php');

}

}

else

{

$tmp_lua_config = new ConfigLUA(Website::getWebsiteConfig()->getValue('serverPath') . 'config.lua');

$config['server'] = $tmp_lua_config->getConfig();

}

 

// remove magic quotes, to make it compatible with some bad PHP configurations, 'stripslashes' in scripts is not needed anymore!

if(function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc())

{

$process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);

while(list($key, $val) = each($process))

{

foreach ($val as $k => $v)

{

unset($process[$key][$k]);

if(is_array($v))

{

$process[$key][stripslashes($k)] = $v;

$process[] = &$process[$key][stripslashes($k)];

}

else

$process[$key][stripslashes($k)] = stripslashes($v);

}

}

unset($process);

}

 

 

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...