Po umieszczeniu plikow na server lycosa i odpaleniu mygosuclan_v1.03/install/install.php
Pojawia sie :
<?php
/**
* install.php
* ------------------------------------------------------------
* Package: MyGosuClan
* Version: 1.03
* License: GNU GPL
* Author: cagrET (Cezary Tomczak)
* Email: cagret@yahoo.com
* Homepage: http://cagret.prv.pl
* ------------------------------------------------------------
*/
require 'config.php';
$error = array();
if (@$_GET['do']) {
foreach ($_POST as $key => $val) {
$_POST[$key] = trim($val);
}
if (!get_magic_quotes_gpc()) {
$_POST['user_login'] = addslashes($_POST['user_login']);
$_POST['user_password'] = addslashes($_POST['user_password']);
}
$error['host'] = $_POST['host'] ? null : true ;
$error['username'] = $_POST['username'] ? null : true;
//$error['password'] = $_POST['password'] ? null : true;
$error['database'] = $_POST['database'] ? null : true;
$error['user_login'] = $_POST['user_login'] ? null : true;
$error['user_password'] = $_POST['user_password'] ? null : true;
if (!isError()) {
//fields are filled
$db_link = @mysql_connect($_POST['host'], $_POST['username'], $_POST['password']);
if (!is_resource($db_link))
{
switch (mysql_error())
{
case 2005:
$error['host'] = true;
break;
case 1045:
$error['username'] = true;
$error['password'] = true;
break;
default:
$error['host'] = true;
$error['username'] = true;
$error['password'] = true;
break;
}
}
if (!isError()) {
//connected
if (@$_POST['database_new']) {
if(!@mysql_query("CREATE DATABASE IF NOT EXISTS `{$_POST['database']}`")) {
$error['database'] = true;
}
}
if (!@mysql_select_db($_POST['database'])) {
$error['database'] = true;
}
if (!isError()) {
//database create and select ok
//save connection info to file
$db_file = '../init/db.php';
if (!is_writable($db_file)) {
exit('Error: file init/db.php is not writable');
}
//read from file
$c = @file($db_file);
if ($c === false) {
exit('Error: couldnt open file init/db.php for read');
}
//trim whitespace
foreach ($c as $key => $val) {
$c[$key] = trim($val);
}
$content = array(
'host' => "\$cfg['sql_host']",
'user' => "\$cfg['sql_user']",
'pass' => "\$cfg['sql_pass']",
'db' => "\$cfg['sql_db']",
'prefix' => "define('prefix'"
);
function change($c, $val)
{
switch ($c)
{
case 'host':
return "\$cfg['sql_host'] = '" . $val . "';";
case 'user':
return "\$cfg['sql_user'] = '" . $val . "';";
case 'pass':
return "\$cfg['sql_pass'] = '" . $val . "';";
case 'db':
return "\$cfg['sql_db'] = '" . $val . "';";
case 'prefix':
return "define('prefix', '" . $val . "');";
}
exit('function change() called with wrong parameters');
}
function post($s)
{
switch ($s)
{
case 'host':
return $_POST['host'];
case 'user':
return $_POST['username'];
case 'pass':
return $_POST['password'];
case 'db':
return $_POST['database'];
case 'prefix':
return $_POST['prefix'];
default:
exit('function post() called with wrong parameter');
}
}
$i = 0;
//changing content - database conn
foreach ($c as $key => $val) {
foreach ($content as $key2 => $val2) {
if (strpos($val, $val2) !== false) {
$c[$key] = change($key2, post($key2));
$i++;
}
}
}
//we change 5 parameters only
if ($i != count($content)) {
exit('Error: unknown error in file init/db.php');
}
//write to file
$fp = @fopen($db_file, 'w');
if (!$fp) {
exit('Error: couldnt open file init/db.php for write');
}
//changing array to string
$c = implode("\n", $c);
fwrite($fp, $c);
fclose($fp);
//read list of sql files
$files = file('sql.txt');
//execute each sql file - if err => $err[file] = mysql_error() else $err[file] = null
$err = array();
foreach ($files as $val) {
$val = trim($val);
$err[basename($val)] = !executeQuery($val, $_POST['prefix']) ? (string) mysql_error() : null;
}
mysql_query("UPDATE `{$_POST['prefix']}users` SET user='".$_POST['user_login']."', pass='". md5($_POST['user_password']) ."' WHERE uid=1");
$success = true;
//success ?
foreach ($err as $key => $val) {
if (!is_null($val)) {
$success = false;
break;
}
}
//display tables ok etc
include 'templates/install_end.tpl';
exit;
}
}
}
}
include 'templates/install.tpl';
function isError()
{
global $error;
foreach ($error as $key => $val) {
if ($val === true) {
return true;
}
}
return false;
}
function executeQuery($file, $prefix)
{
global $db_link;
$fp = fopen($file, 'r');
$sql = trim(fread($fp, filesize($file)));
fclose($fp);
$sql = preg_split("#;(\r\n|\n|\r)#", $sql);
foreach($sql as $key => $val) {
if (strpos($val, '`mgc_') === false) {
return false;
}
$val = str_replace('`mgc_', '`'.$prefix, $val);
$result = @mysql_query($val . ';', $db_link);
if(!$result) {
return false;
}
}
return true;
}
?>
Ktos wie ocb ? Jak to naprawic ? Pls help
