forked from phamtienthanh-luvina/samforum
/
threads.php
109 lines (83 loc) · 3.16 KB
/
threads.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?PHP
//******************************************//
//* This copyright notice must not be removed
//* under any circumstances.
//* It must stay intact in all the files.
//* Samforum
//* Version 1.0
//* Script created by Samiuddin Samiuddin
//* Email: phpdevsami@gmail.com
//* Skype: n0h4cks
//* - This is not an open source project, functions/classes
//* or any other code form this script cannot be
//* used for other scripts or applications.
//* You are not allowed to resell this script.
//* - You are free to make modification/changes,
//* however it must be for your own use.
//*********************************************************************//
?>
<?PHP
//session_start();
include_once("general/general_class.php");
include_once("connection_to_db.php");
include_once("show_data_class.php");
include_once("thread_editor_class.php");
include_once("post_reply/post_reply_class.php");
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<title>
<?PHP
echo Data_display::show_thread_title($conn);
?>
</title>
</head>
</html>
<?PHP
if( isset($_GET["thread_id"]) and isset($_GET["cat_id"]) ){
$Thread_editor = new Thread_editor($conn);
//shows whole thread info, like thread body, title, thread by and time.
$Show_thread_body = new Data_display($conn);
//show thread body.
$Show_thread_body->show_thread_body();
//show thread replies.
$Show_thread_body->show_replies();
//code below only runs if user is logged in.
if($Thread_editor->is_user_logged_in("logged_in")){
//***************************************************************************//
//*****************TAKES CARE OF SHOWING REPLY OPTIONS***********************//
//***************************************************************************//
//do these if only is user if logged in. this also shows the form to reply if user if logged in.
$Post_reply = new reply($conn);
$Post_reply->show_form();
//takes care of making sure user is logged in. thread_id and cat_id variables exist, reply length and empty reply...
if($Post_reply->set_reply()){
$Post_reply->post_reply();
}
//***************************************************************************//
//***************************************************************************//
//*******************TAKES CARE OF EDITING THREAD****************************//
//***************************************************************************//
$Thread_editor = new Thread_editor($conn);
//if user is allowed to edit the thread, either is admin or owns the thread.
if($Thread_editor->check_if_allowed_to_edit()){
echo "Edit thread";
//show user the form.
$Thread_editor->show_edit_form();
//validate submitted infromation.
if($Thread_editor->validate_submitted_info()){
$Thread_editor->update_info();
}
}else{
//if not allowed to edit then do nothing.
//header("location: index.php");
}
//***************************************************************************//
}else{
echo " </br> Please login to post a reply </br>";
}
}else{
header("location:index.php");
}
?>