<?php //with the support of several existimg scripts//
//************************************
//altered and used by http://key22.com
//no warranty - no charge!
//keep this part.
//************************************
//# Table structure for table 'binary_data'
//#
//
//CREATE TABLE binary_data (
// id int(4) DEFAULT '0' NOT NULL auto_increment,
// description varchar(50),
// bin_data longblob,
// filename varchar(50),
// filesize varchar(50),
// filetype varchar(50),
// email varchar(64) NOT NULL,
// message varchar(240) NOT NULL,
// PRIMARY KEY (id)
//);
//you also need to have Florian Dittmer's getdata
//to do a big part of the job:
//_____________________________________________ ?>
<?
// getdata.php3 - by Florian Dittmer <dittmer@gmx.net>
if($id) {
@MYSQL_CONNECT("$a","$c","$d");
@mysql_select_db("$db");
$query = "select bin_data,filetype from binary_data where id=$id";
$result = @MYSQL_QUERY($query);
$data = @MYSQL_RESULT($result,0,"bin_data");
$type = @MYSQL_RESULT($result,0,"filetype");
Header( "Content-type: $type");
echo $data;
}; ?>
<? //**************************************
//here we go... ?>
HTML
<HEAD>
</HEAD>
<BODY>
<? include("connect.php3"); ?>
<? if ($submit) {
if (empty($form_description) || empty($form_data) || empty($email))
{
echo "<br><center><font color=red><b>Please fill in name/description,
email and file_path for a file before submitting.</b>
(only text is optional)<br><br>
<a href="javascript:window.history.back()">back</a></font><center>";
echo "</center><br>"; //include("IF_YOU_WANT_A_footer.inc"); echo "</body></html>";
exit();
}
else if( !ereg( "^([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z]+))
*[@]([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z]+))
*[.]([0-9,a-z,A-Z]){2}([0-9,a-z,A-Z])?$", $email ) )
{
print "<BR>n";
echo "<br>";
echo "<center><font color=red>Wrong email address!<br><br>
<a href="javascript:window.history.back()">Please go back and
correct the email address</a></font></center>";
$valid = false;
echo "</center><br>"; //include("IF_YOU_WANT_A_footer.inc"); echo "</body></html>";
exit ();
}
else if ($form_data_size > 30000) {
echo "<br><center><font color=red><b>File is way tooo BIG!</b>
(Max. file size allowed is 30 KB.)<br><br>
<a href="javascript:window.history.back()">back</a>
</font><center>";
echo "</center><br>"; //include("IF_YOU_WANT_A_footer.inc"); echo "</body></html>";
exit();
}
else {
MYSQL_CONNECT("$a","$c","$d");
@mysql_select_db("$db") or die("Unable to select database");
$data = addslashes(fread(fopen($form_data, "r"), filesize($form_data))); $form_description = addslashes($form_description); $message = addslashes($message);
$result=MYSQL_QUERY("INSERT INTO binary_data
(description,email,message,bin_data,filename,filesize,filetype) ". "VALUES ('$form_description','$email','$message','$data','$form_data_name',
'$form_data_size','$form_data_type')");
MYSQL_CLOSE();
}
} else {
// else show the form to submit new data: ?> <center>
<form method="post" action="<?php echo $PHP_SELF; ?>"
enctype="multipart/form-data">
<table with="500" class="text"><tr><td class="text">
<b><u>HERE'S THE FORM and TIME to add <i>your!</i> PHOTO......
</u></b>
<br>see existing files and maybe finally <i>yours</i>
below the form<br><br>
<b>File Description or Name:</b> <small>(pls.fill all fields -
text is optional)</small><br>
<input type="text" name="form_description" size="20">
<b>Email: </b><input type="text" name="email" size="15">
<br>
<textarea name="message" cols="40" rows="2"></textarea>
...how about some text..?<br>
<INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="50000">
<font color="red">NOTE: only image files of type *.jpg,*.gif
and *.png are supported.<br>
Max. file size is set to 30 K' (30 kilobytes)!
TEXT max. 240 characters.<br></font>
<b>File to upload/store in database:</b><br>
<input type="file" name="form_data" size="40"><br>
<p><input type="submit" name="submit" value="submit">
...please submit once ... it takes a few seconds.
</td></tr></table>
</form>
</center>
<?php
}
?>
<center>
<table width="700" class="text"><tr><td class="text">
Here's the files available with <i>yours?</i> on final
position...<br><br>
<? include("YOUR_CONNECTION_FILE"); ?>
<? MYSQL_CONNECT($a, $c, $d) OR DIE("Unable to connect to database");
@mysql_select_db( "$db") or die( "Unable to select database");
$usertable = "binary_data"; $query = mysql_query("SELECT id,description FROM $usertable ORDER BY id");
while ($row = mysql_fetch_array($query))
{
$variable1=$row["id"];
$variable2=$row["description"];
print ("<b>$variable1...</b>
<a href=$PHP_SELF?numba=$variable1>$variable2</a>>> ");
}
mysql_close(); ?>
<br><br>
<? if (!$numba) {
echo ("<br>");
}
else
{ MYSQL_CONNECT($a, $c, $d) OR DIE("Unable to connect to database");
@mysql_select_db( "$db") or die( "Unable to select database");
$usertable = "binary_data";
$query = mysql_query("SELECT * FROM $usertable WHERE id=$numba");
while ($row = mysql_fetch_array($query))
{
$variable1=$row["id"];
$variable2=$row["description"];
$variable3=$row["email"];
$variable4=$row["message"];
echo ("<center><img src=getdata.php3?id=$variable1><p class=text><b>-
<a href=mailto:$variable3>$variable2</a> -</b><br><br>$variable4</p>
</center><br>");
}
mysql_close();
} ?> </td></tr></table></center>
<br>
//<? include("IF_YOU_WANT_A_footer.inc"); ?>
</body>
</html>
|
|