Codice PHP:
<?
// Ultimate PHP Board
// Author: Tim Hoeppner aka RR_Pilot, FixITguy
// Website: [url]http://www.webrc.ca/php[/url]
// Version: 1.0
// Using textdb Version: 1.0
include "func.inc.php";
if($t_id == "") {
$w_forum = get($id, "./db/forum");
$where = "[b]>[/b] [url='viewforum.php?id=$id']$w_forum[forum][/url] [b]>[/b] Nuovo Post";
} else {
$w_forum = get($id, "./db/forum");
$upb["def"] = "./db/p_forum";
$w_topic = get($t_id, "./db/$id");
$where = "[b]>[/b] [url='viewforum.php?id=$id']$w_forum[forum][/url] [b]>[/b] [url='viewtopic.php?id=$id&t_id=$t_id']$w_topic[subject][/url] [b]>[/b] Rispondi al Post";
$wherepost = "[b]>[/b] [url='viewtopic.php?id=$id&t_id=$t_id']$w_topic[subject][/url] [b]>[/b] Rispondi al Post";
}
include "header.php";
if(isset($HTTP_GET_VARS["id"])) {
if(is_numeric($HTTP_GET_VARS["id"])) {
$id = $HTTP_GET_VARS["id"];
} else {
$id = "";
echo "Invalid ID";
include "footer.php";
exit;
}
}
if(isset($HTTP_GET_VARS["t_id"])) {
if($HTTP_GET_VARS["t_id"] != "") {
if(is_numeric($HTTP_GET_VARS["t_id"])) {
$t_id = $HTTP_GET_VARS["t_id"];
} else {
$t_id = "";
echo "Invalid Topic ID";
include "footer.php";
exit;
}
}
}
if (!isset($a))
{
$a = 0;
}
if (@!is_logged_in($user_env, $pass_env, $power_env, $id_env))
{
echo "Please Login.";
} else {
$closedforums = file("./db/closedforums.dat");
foreach($closedforums as $closedforum)
{
settype($closedforum, "integer");
if($closedforum == $id)
{
if($power_env < 3)
{
echo "questo forum è di sola lettura, non puoi postare";
exit;
}
}
}
if ($a == 1)
{
if ($t == 1)
{
if(trim($subject) == "") {
die("You must enter a subject!");
}
if(!isset($HTTP_POST_VARS["icon"])) {
echo "Bisogna inviare attraverso il forum.";
include "footer.php";
exit;
}
if($icon == "") {
$icon = "icon1.gif";
}
//FILE UPLOAD BEGIN
$uploadText = "";
if(trim($file_name) != "") {
$jpg = "image/pjpeg";
$gif = "image/gif";
$zip = "application/x-zip-compressed";
$txt = "text/plain";
if ($file_type == $txt || $file_type == $jpg || $file_type == $gif || $file_type == $zip)
{
if ($file_name == '')
{
$uploadText = "";
} else {
if ($file_size >= (1024 * $fileupload_size))
{
$uploadText = "";
} else {
// successful file upload
if (copy (@$file, "$fileupload_location/$file_name")) {
$uploadText = "[img]images/attachment.gif[/img] Attachment: [url]$fileupload_location/".$file_name."[/url]
";
} else {
$uploadText = "";
}
}
}
unlink ($file);
} else {$uploadText = ""; }
}
$message = $uploadText.$message;
//END
$message = format_field($message);
$subject = str_replace("[Sticky Note]", "Sticky Note", $subject);
if(isset($HTTP_POST_VARS["stick"])) {
$subject .= " [Sticky Note]";
}
$t_id = add("$icon<~>$subject<~>$u_name<~>0<~>".date("M d, Y g:i:s a")."<~>$u_name<~>$id_env", "./db/$id", "no");
add_down("$icon<~>$subject<~>$u_name<~>".date("M d, Y g:i:s a")."<~>$message<~>$id_env", "./db/$id/$t_id", "yes");
$r = listall("./db/forum");
$b = count($r);
$field = "id";
$q = $id;
for($i=0;$i<=$b;$i++)
{
$stuff = def($r[$i], "./db/forum");
if(@$stuff[$field] == $q)
{
$rec = $r[$i];
break;
}
}
$rec = def($rec, "./db/forum");
@settype($rec[topics], "double");
@settype($rec[posts], "double");
@$rec[topics] = $rec[topics]+1;
@$rec[posts] = $rec[posts]+1;
@$rec[last_post] = $t_id;
@$rec[user] = $u_name;
@$rec[user_id] = $id_env;
$rec = implode("<~>", $rec);
edit($id, $rec, "./db/forum", "no");
/*beginner post update in profile*/
$u = get($id_env, "./db/users");
@settype($u[posts], "double");
@$u[posts] = $u[posts]+1;
$u = implode("<~>", $u);
edit($id_env, $u, "./db/users", "no");
echo "<meta http-equiv='refresh' content='1;URL=viewforum.php?id=$id'>";
/* end */
} else {
if(!isset($HTTP_POST_VARS["icon"])) {
echo "Bisogna inviare attraverso il forum.";
include "footer.php";
exit;
}
if (isset($t_id))
{
if(!is_writable("./db/$id/".$t_id.".dat")) {
echo "Il topic è chiuso.";
exit;
}
if($icon == "") {
echo "seleziona un'icona!";
exit;
}
//FILE UPLOAD BEGIN
$uploadText = "";
if(trim($file_name) != "") {
$jpg = "image/pjpeg";
$gif = "image/gif";
$zip = "application/x-zip-compressed";
$txt = "text/plain";
if ($file_type == $txt || $file_type == $jpg || $file_type == $gif || $file_type == $zip)
{
if ($file_name == '')
{
$uploadText = "";
} else {
if ($file_size >= (1024 * $fileupload_size)) //50kb
{
$uploadText = "";
} else {
// successful file upload
if (copy (@$file, "$fileupload_location/$file_name")) {
$uploadText = "[img]images/attachment.gif[/img] Allegati: [url]$fileupload_location/".$file_name."[/url]
";
} else {
$uploadText = "";
}
}
}
unlink ($file);
} else {$uploadText = ""; }
}
$message = $uploadText.$message;
//END
$message = format_field($message);
add_down("$icon<~>$subject<~>$u_name<~>".date("M d, Y g:i:s a")."<~>$message<~>$id_env", "./db/$id/$t_id", "no");
$r = listall("./db/forum");
$b = count($r);
$field = "id";
$q = $id;
for($i=0;$i<=$b;$i++)
{
@$stuff = def($r[$i], "./db/forum");
if(@$stuff[$field] == $q)
{
$rec = $r[$i];
break;
}
}
$rec = def($rec, "./db/forum");
@settype($rec[posts], "double");
@$rec[posts] = $rec[posts]+1;
@$rec[last_post] = $t_id;
@$rec[user] = $u_name;
@$rec[user_id] = $id_env;
$rec = implode("<~>", $rec);
edit($id, $rec, "./db/forum", "no");
$r1 = listall("./db/$id");
$b1 = count($r1);
$field1 = "id";
$q1 = $t_id;
for($i1=0;$i1<=$b1;$i1++)
{
$stuff1 = def($r1[$i1], "./db/p_forum");
if(@$stuff1[$field1] == $q1)
{
$rec1 = $r1[$i1];
break;
}
}
$rec1 = def($rec1, "./db/p_forum");
@settype($rec1[replies], "double");
@$rec1[replies] = $rec1[replies]+1;
@$rec1[last_post] = date("M d, Y g:i:s a");
@$rec1[user_name] = $u_name;
if(isset($HTTP_POST_VARS["unstick"])) {
$rec1["subject"] = str_replace("[Sticky Note]", "", $rec1["subject"]);
}
@$rec1[user_id] = $id_env;
$rec1 = implode("<~>", $rec1);
edit($t_id, $rec1, "./db/$id", "no");
/*beginner post update in profile*/
$u = get($id_env, "./db/users");
@settype($u[posts], "double");
@$u[posts] = $u[posts]+1;
$u = implode("<~>", $u);
edit($id_env, $u, "./db/users", "no");
/* end */
if($page == "") {
$page = 1;
}
echo "<meta http-equiv='refresh' content='1;URL=viewtopic.php?id=$id&t_id=$t_id&page=$page'>";
}
}
include "sortTopics.php";
} else {
if(!isset($page)) {
$page = 1;
}
if($t == 1)
{
$tpc = "<tr><td bgcolor='$table1'><font size='$font_m' face='$font_face' color='$font_color_main'>Titolo:</font></td><td bgcolor='$table1'><input type=text name=subject size=40></td></tr>";
if(isset($power_env) && isset($user_env) && isset($pass_env) && isset($id_env))
{
if(is_logged_in($user_env, $pass_env, $power_env, $id_env) && $power_env == 3)
{
$sticky = "<tr><td bgcolor='$table1'><font size='$font_m' face='$font_face' color='$font_color_main'>Messaggio in rilievo:</font></td><td bgcolor='$table1'><input type=checkbox name=stick size=40></td></tr>";
}
}
$hed = "Nuovo Topic";
$iframe = "";
} else {
$tpc = "<input type=hidden name=subject value=''>";
if(isset($power_env) && isset($user_env) && isset($pass_env) && isset($id_env))
{
if(is_logged_in($user_env, $pass_env, $power_env, $id_env) && $power_env == 3)
{
$unsticky = "<tr><td bgcolor='$table1'><font size='$font_m' face='$font_face' color='$font_color_main'>Un-Sticky:</font></td><td bgcolor='$table1'><input type=checkbox name=unstick size=40></td></tr>";
}
}
$hed = "Reply";
$iframe = "
[B]<font size='$font_m' face='$font_face' color='$font_color_main'>Rassegna Topic:
</font>[/B]
<IFRAME SRC='viewtopic_simple.php?id=$id&t_id=$t_id&page=$page' WIDTH=$table_width_main HEIGHT='300'></IFRAME>";
}
$icons = message_icons();
echo "
<script LANGUAGE='JavaScript'>
<!--
function SetSmiley(Which) {
if (document.newentry.message.createTextRange) {
document.newentry.message.focus();
document.selection.createRange().duplicate().text = Which;
} else {
document.newentry.message.value += Which;
}
}
//-->
</SCRIPT>
<script language='JavaScript'>
function submitonce(theform){
if (document.all||document.getElementById){
for (i=0;i<theform.length;i++){
var tempobj=theform.elements[i]
if(tempobj.type.toLowerCase()=='submit'||tempobj.type.toLowerCase()=='reset')
tempobj.disabled=true
}
}
}
</script>
<form action='newpost.php?id=$id&a=1&t=$t&t_id=$t_id&page=$page' method=POST name='newentry' onSubmit='submitonce(this)' enctype='multipart/form-data'>";
if($t_id == "") {
echo "$skin_tableheading";
} else {
echo "$skin_tableheading_post";
}
echo "<table width=$table_width_main cellspacing=1 cellpadding=3 border=0 bgcolor='$border' align='center'>
<tr><td colspan='2' bgcolor='$header' background=$skin_images_dir/cat_top_bg.gif >[B]<font size='$font_l' face='$font_face' color='$font_color_header'>$hed</font>[/b]</td></tr>
<tr><td bgcolor='$table1'><font size='$font_m' face='$font_face' color='$font_color_main'>User Name:</font></td><td bgcolor='$table1'><font size='$font_m' face='$font_face' color='$font_color_main'>$user_env<input type=hidden name=u_name value='$user_env'></td></tr>
$tpc
$sticky
$unsticky
<tr><td bgcolor='$table1'><font size='$font_m' face='$font_face' color='$font_color_main'>Icone Messaggio:</font></td><td bgcolor='$table1'><input type=radio name=icon value='icon1.gif' CHECKED>[img]./icon/icon1.gif[/img] $icons</td></tr>
<tr><td bgcolor='$table1' valign='top'><font size='$font_m' face='$font_face' color='$font_color_main'>Messaggio:</font>
<center>
</td></tr>
<tr><td bgcolor='$table1' colspan=2><font size='$font_m' face='$font_face' color='$font_color_main'>
Allega File:
<input type=file name='file' value='file_name' size=20>
[size="1"][b]Tipi di file validi: txt, gif, jpg, jpeg, zip.
La grandezza massima del file è $fileupload_size Kb. Se il tuo file non risponde ai requisiti, sarà rifiutato senza avviso.[/b][/size]</font></td></tr>
<tr><td bgcolor='$table1' colspan=2>
<input type=submit value='Invia nuova discussione' onclick='return check_submit()'></td></tr></form></font>$skin_tablefooter
$iframe</p>";
}
}
include "footer.php";
?>
Un piccolo aiutino che potrei dare...ma dove non riesco ad applicarlo..è al register.php quando inserisco un e-mail non valida..ma non sò se aiuta..lo script è questo: