Początkujący
Postów: 258 Pomógł: 8 Ostrzeżeń: 6
Data rejestracji: 16.06.2007 14:45
ZBANOWANY: Dożywotnio
|
Siema, Mam skrypt do uploadu obrazków ale kiedy Chce go zainstalować to Wyskakuje Mi błąd "Unable to connect to MySQL database!
Click here to install" Niby że nie może się połączyć z bazą, Mam wszystko dobrze zrobione. Na pewno można Samemu dodać te wpisy w bazie ale niestety nie Wiem jak :\
Oto plik install.php :
<?php
if (file_exists("includes/lock.bin")) {die('<div align="center"><h1>You cannot access the installation procedure because the file "lock.bin" exists inside the "includes" directory!</h1><br><br>The "lock.bin" file is created automatically during the installation and it is used to mark this script as "installed". When this file is created, this installation script is disabled in order to prevent unathorized access. If you are the owner of this script, and you want to install/reinstall this script, please delete the "lock.bin" file which is located inside the "includes" directory.</div>');}
if ($_POST['install']=="yes") {
$musername=$_POST['username'];
$mpassword=$_POST['password'];
$mhostname=$_POST['hostname'];
$mdatabase=$_POST['database'];
$mprefix=$_POST['prefix'];
$errors="no";
$reasons="<br>";
if ($musername=="" || $mhostname=="" || $mdatabase=="") {$errors="yes"; $reasons.="- One of the required fields on the previous page was left blank. Please hit the \"Back\" button in your browser and correct this.<br>";}
$link=@mysql_connect($mhostname,$musername,$mpassword);
if (@mysql_select_db($mdatabase)===FALSE) {$errors="yes"; $reasons.="- Unable to connect to your MySQL database. Please hit the \"Back\" button in your browser anc doublecheck the entered details.<br>";}
$sql="SELECT `password` FROM `".$mprefix."admin` WHERE 1";
$result=@mysql_query($sql);
if (@mysql_result($result)!="") {
$errors="yes"; $reasons.="- An existing installation of this script already exists! Either remove the current installation, or select a different table prefix.<br>";}
@mysql_close($link);
if ($errors!="yes")
{
if (file_exists("includes/settings.inc.php"))
{@chmod("includes/settings.inc.php",0777); @unlink("includes/settings.inc.php");}
//Write to file
$data='<?php
$mysql_host="'.$hostname.'";
$mysql_username="'.$musername.'";
$mysql_password="'.$mpassword.'";
$mysql_database="'.$mdatabase.'";
$mysql_prefix="'.$mprefix.'";
?>';
$filename = "includes/settings.inc.php";
$filehandle = @fopen($filename, 'x+') or die("<div align=\"center\">Error while writing file!<br>Please CHMOD 777 the \"includes\" directory first and try again!</div>");
@fwrite($filehandle,$data);
@fclose($filehandle);
if ($errors!="yes")
{
require("includes/connect.inc.php");
$sql = "CREATE TABLE `".$mprefix."admin` ("
. " `password` LONGTEXT NOT NULL, "
. " `max_x` INT NOT NULL, "
. " `max_y` INT NOT NULL, "
. " `slogan` LONGTEXT NOT NULL, "
. " `maxsize` INT NOT NULL, "
. " `watermark` TINYTEXT NOT NULL, "
. " `websites` TINYTEXT NOT NULL, "
. " `forums1` TINYTEXT NOT NULL, "
. " `forums2` TINYTEXT NOT NULL, "
. " `hotlink1` TINYTEXT NOT NULL, "
. " `hotlink2` TINYTEXT NOT NULL, "
. " `hotlink3` TINYTEXT NOT NULL, "
. " `regularlink` TINYTEXT NOT NULL, "
. " `directlink` TINYTEXT NOT NULL, "
. " `maxcharacters` INT NOT NULL, "
. " `mailcontents` LONGTEXT NOT NULL, "
. " `mailfrom` LONGTEXT NOT NULL, "
. " `mailsubject` LONGTEXT NOT NULL,"
. " `fields` TINYTEXT NOT NULL"
. " )"
. " TYPE = myisam";
$result=mysql_query($sql);
$sql = "CREATE TABLE `".$mprefix."report` (`id` TEXT NOT NULL, `ip` TEXT NOT NULL, `date` TINYTEXT NOT NULL, `comment` LONGTEXT NOT NULL) TYPE = myisam";
$result=mysql_query($sql);
$sql = "CREATE TABLE `".$mprefix."images` ("
. " `realfilename` MEDIUMTEXT NOT NULL, "
. " `size_width` INT NOT NULL, "
. " `size_height` INT NOT NULL, "
. " `allow_rc` TINYTEXT NOT NULL, "
. " `watermark` TINYTEXT NOT NULL, "
. " `comment` LONGTEXT NOT NULL, "
. " `rating` TINYTEXT NOT NULL, "
. " `rates` INT NOT NULL, "
. " `rnumber` INT NOT NULL, "
. " `ip` TINYTEXT NOT NULL, "
. " `minute` TINYTEXT NOT NULL, "
. " `hour` TINYTEXT NOT NULL, "
. " `day` TINYTEXT NOT NULL, "
. " `month` TINYTEXT NOT NULL, "
. " `year` TINYTEXT NOT NULL"
. " )"
. " TYPE = myisam";
$result=mysql_query($sql);
$sql = "ALTER TABLE `".$mprefix."images` ADD `lminute` TINYTEXT NOT NULL, ADD `lhour` TINYTEXT NOT NULL, ADD `lday` TINYTEXT NOT NULL, ADD `lmonth` TINYTEXT NOT NULL, ADD `lyear` TINYTEXT NOT NULL";
$result=mysql_query($sql);
$sql = "ALTER TABLE `".$mprefix."images` ADD `id1` MEDIUMTEXT NOT NULL, ADD `id2` MEDIUMTEXT NOT NULL";
$result=mysql_query($sql);
$sql = "CREATE TABLE `".$mprefix."files` ("
. " `jpeg` TINYTEXT NOT NULL, "
. " `jpg` TINYTEXT NOT NULL, "
. " `png` TINYTEXT NOT NULL, "
. " `gif` TINYTEXT NOT NULL, "
. " `bmp` TINYTEXT NOT NULL, "
. " `tif` TINYTEXT NOT NULL, "
. " `tiff` TINYTEXT NOT NULL"
. " )"
. " TYPE = myisam";
$result=mysql_query($sql);
$sql = "INSERT INTO `".$mprefix."files` (`jpeg`, `jpg`, `png`, `gif`, `bmp`, `tif`, `tiff`) VALUES ('yes', 'yes', 'yes', 'yes', 'yes', 'no', 'no')";
$result=mysql_query($sql);
$sql = "INSERT INTO `".$mprefix."admin` (`password`, `max_x`, `max_y`, `slogan`, `maxsize`, `watermark`, `websites`, `forums1`, `forums2`, `hotlink1`, `hotlink2`, `hotlink3`, `regularlink`, `directlink`, `mailcontents`, `mailfrom`, `mailsubject`, `maxcharacters`, `fields`) VALUES ('21232f297a57a5a743894a0e4a801fc3', '1024', '768', 'no', '1073741824', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'Hello, {-TONAME-}!"
. " Your friend, {-FROMNAME-}, has sent you this picture:"
. " {-IMAGE-}"
. " Free image hosting by YourSite.com', 'YourPictureHosting <>', '{-TONAME-}, you have received a picture!', '255', '5')";
$result=mysql_query($sql);
$sql = "CREATE TABLE `".$mprefix."maillog` ("
. " `ip` TINYTEXT NOT NULL, "
. " `minute` TINYTEXT NOT NULL, "
. " `hour` TINYTEXT NOT NULL, "
. " `day` TINYTEXT NOT NULL, "
. " `month` TINYTEXT NOT NULL, "
. " `year` TINYTEXT NOT NULL, "
. " `to` MEDIUMTEXT NOT NULL, "
. " `from` MEDIUMTEXT NOT NULL, "
. " `subject` MEDIUMTEXT NOT NULL, "
. " `body` LONGTEXT NOT NULL"
. " )"
. " TYPE = myisam";
$result=mysql_query($sql);
$sql = "CREATE TABLE `".$mprefix."lmail` ("
. " `mailfrom` MEDIUMTEXT NOT NULL, "
. " `mailsubject` MEDIUMTEXT NOT NULL, "
. " `mailbody` LONGTEXT NOT NULL"
. " )"
. " TYPE = myisam";
$result=mysql_query($sql);
$sql = "INSERT INTO `".$mprefix."lmail` (`mailfrom`, `mailsubject`, `mailbody`) VALUES ('YourPictureHosting <>', '{-EMAIL-}, here are your links!', 'Hello, {-EMAIL-}!"
. " Here are the links that you requested recently while uploading the file \"{-FILE-}\":"
. " Download/view link: {-LINK-}"
. " Removal link: {-REMLINK-}"
. " http://www.yoursite.com')";
$result=mysql_query($sql);
$sql = 'ALTER TABLE `'.$mprefix.'images` ADD `feedback` LONGTEXT NOT NULL';
$result=mysql_query($sql);
$sql = 'ALTER TABLE `'.$mprefix.'images` ADD `visits` BIGINT( 20 ) NOT NULL DEFAULT \'0\'';
$result=mysql_query($sql);
$sql = 'ALTER TABLE `'.$mprefix.'images` ADD `wvisit` BIGINT DEFAULT \'0\' NOT NULL, ADD `ban` TINYTEXT NOT NULL';
$result=mysql_query($sql);
$sql = "CREATE TABLE `".$mprefix."stats_total` ( `pageviews` MEDIUMTEXT NOT NULL, `imageviews` MEDIUMTEXT NOT NULL ) TYPE = myisam";
$result=mysql_query($sql);
$sql = "ALTER TABLE `".$mprefix."stats_total` ADD `visits` TEXT NOT NULL, ADD `unique` TEXT NOT NULL";
$result=mysql_query($sql);
$sql = "INSERT INTO `".$mprefix."stats_total` (`pageviews`, `imageviews`, `visits`, `unique`) VALUES ('0', '0', '0', '0')";
$result=mysql_query($sql);
$sql = "CREATE TABLE `".$mprefix."stats_week` ( `1` TEXT NOT NULL, `2` TEXT NOT NULL, `3` TEXT NOT NULL, `4` TEXT NOT NULL, `5` TEXT NOT NULL, `6` TEXT NOT NULL, `7` TEXT NOT NULL, `week` TEXT NOT NULL ) TYPE = myisam";
$result=mysql_query($sql);
$week = date("W");
$sql = "INSERT INTO `".$mprefix."stats_week` (`1`, `2`, `3`, `4`, `5`, `6`, `7`, `week`) VALUES ('0|0|0|0', '0|0|0|0', '0|0|0|0', '0|0|0|0', '0|0|0|0', '0|0|0|0', '0|0|0|0', '$week')";
$result=mysql_query($sql);
$sql = "CREATE TABLE `".$mprefix."stats_ref` ( `ref` MEDIUMTEXT NOT NULL, `count` BIGINT NOT NULL) TYPE = myisam";
$result=mysql_query($sql);
$sql = "ALTER TABLE `".$mprefix."images` ADD `niceurl` TEXT NOT NULL";
$result=mysql_query($sql);
$sql = "CREATE TABLE `".$mprefix."watermark` ( `text` MEDIUMTEXT NOT NULL, `position` TINYTEXT NOT NULL, `minx` TINYTEXT NOT NULL, `miny` TINYTEXT NOT NULL, `colorr` TINYTEXT NOT NULL, `colorg` TINYTEXT NOT NULL, `colorb` TINYTEXT NOT NULL, `alpha` TINYTEXT NOT NULL ) TYPE = myisam";
$result=mysql_query($sql);
$sql = "ALTER TABLE `".$mprefix."watermark` ADD `size` TINYTEXT NOT NULL";
$result=mysql_query($sql);
$sql = "INSERT INTO `".$mprefix."watermark` (`text`, `position`, `minx`, `miny`, `colorr`, `colorg`, `colorb`, `alpha`, `size`) VALUES ('Image hosted by YourSite.com', 'bottom', '100', '100', '255', '255', '255', '70', '14')";
$result=mysql_query($sql);
$sql = "CREATE TABLE `".$mprefix."voting` ( `load` TINYTEXT NOT NULL, `vote` TINYTEXT NOT NULL ) TYPE = myisam";
$result=mysql_query($sql);
$sql = "INSERT INTO `".$mprefix."voting` (`load`, `vote`) VALUES ('no', 'no')";
$result=mysql_query($sql);
$filename = "includes/lock.bin";
$filehandle = @fopen($filename, 'x+') or die("<div align=\"center\">Error while writing file!<br>Please CHMOD 777 the \"includes\" directory first and try again!</div>");
@fwrite($filehandle,"Please do not delete this file as it is used for security reasons. For further info, run \"install.php\".");
@fclose($filehandle);
require("includes/disconnect.inc.php");
}}}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Administration Panel</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
background-color: #FFFFFF;
background-image: url(images/background.jpg);
background-repeat: repeat-x;
}
-->
</style>
<link href="style.css" rel="stylesheet" type="text/css">
<link href="../xtreme/images/style.css" rel="stylesheet" type="text/css">
<link href="images/style.css" rel="stylesheet" type="text/css">
</head>
<body>
<p> </p>
<table width="674" border="0" align="center" cellpadding="0" cellspacing="1" class="tablex">
<tr>
<td height="32" background="images/installtop.jpg" class="texttitle"><div align="center" class="heading1">eXtreme Photo hosting installation | Nullified by TNG</div></td>
</tr>
<tr>
<td height="34" bgcolor="#EBFCE2"><div align="center"><span class="ttl">
<?php if ($_POST['install']!="yes") { ?>
</span>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#FFFFFF"><div align="center">
<p><strong><img src="images/box.jpg" width="80" height="122"><br>Hello and welcome to the eXtremePow photo hosting installation process!</strong><br>
In a few clicks from now, you will be able to host images for the whole world to see! Good luck!<br>
</p>
</div></td>
</tr>
</table>
<span class="ttl">
<p class="text">Before proceeding, make sure that you have set CHMOD 777 for the following folders:<br>
<strong>temp<br>
links<br>
includes<br>
img</strong></p>
<p class="text">If you are not sure if your mail server properties in PHP.ini are configured right, double-check them to allow users to send images to their friends VIA e-mail.</p>
</span>
<p class="ttl"><br>
Checking for GD:
<?php
$gd=1;
$image = @imagecreate(50, 100) or $gd=0;
if ($gd==0) {echo("FAILED");} else {echo("OK");}
@imagedestroy($image);
?>
</p>
<span class="ttl"><form name="form1" method="post" action="install.php">
<table width="337" border="0" cellpadding="0" cellspacing="1">
<tr>
<td width="135"><div align="right">MySQL username: </div></td>
<td width="199"><input name="username" type="text" class="field" id="username" size="30"> </td>
</tr>
<tr>
<td><div align="right">MySQL password: </div></td>
<td><input name="password" type="password" class="field" id="password" size="30"> </td>
</tr>
<tr>
<td><div align="right">MySQL hostname: </div></td>
<td><input name="hostname" type="text" class="field" id="hostname" value="localhost" size="30"> </td>
</tr>
<tr>
<td><div align="right">MySQL database: </div></td>
<td><input name="database" type="text" class="field" id="database" size="30"> </td>
</tr>
<tr>
<td><div align="right">MySQL table prefix: </div></td>
<td><input name="prefix" type="text" class="field" id="prefix" value="img_" size="30"></td>
</tr>
</table>
<p>
<input name="install" type="hidden" id="install" value="yes">
<input name="Submit" type="submit" class="button" value="Install script" onclick="return check()">
</p>
</form>
<?php }
else
{
if ($errors!="yes")
{
echo("
<p>Installation complete!</p>
<p class=\"text\">You may <a href=\"admin/login.php\">login</a> to your administration panel now. <br><br> For login details please read 'NULL.TNG.nfo' for where to locate them.</p>
");
} else {
echo("
<p>Installation failed!</p>
<p class=\"text\">The installation has failed because of the following reasons: <br>$reasons</p>
");
}
}
?>
</span></div></td>
</tr>
<tr>
<td height="19" bgcolor="#CEF8B8"> </td>
</tr>
</table>
</body>
</html>
Jest ktoś tak dobry i ułoży Mi kod który Sobie zaimportuje w bazie? Dzięki z góry.
Edytowane przez LAbUdZiN dnia 02.02.2008 21:47:22
|