|
Revision 1, 2.4 KB
(checked in by anonymous, 7 years ago)
|
|
initial import
|
| Line | |
|---|
| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | |
|---|
| 24 | |
|---|
| 25 | if(is_numeric($token[3]) ) |
|---|
| 26 | { |
|---|
| 27 | $is_membre = $db->getOne('SELECT count(id) as nb FROM user_comm WHERE id=? AND status=? AND id_comm=?', array($_SESSION['my_id'], 'ok', $token[3])); |
|---|
| 28 | if($is_membre != 1) |
|---|
| 29 | { |
|---|
| 30 | header('Location: /error/not_in_community'); |
|---|
| 31 | exit(); |
|---|
| 32 | } |
|---|
| 33 | |
|---|
| 34 | $date = time(); |
|---|
| 35 | $title = stripslashes($_POST['title']); |
|---|
| 36 | $message = stripslashes($_POST['message']); |
|---|
| 37 | |
|---|
| 38 | if(strlen(trim($_POST['title'])) < 1 || strlen(trim($_POST['message'])) < 1) |
|---|
| 39 | { |
|---|
| 40 | header('Location: /error/incorrect_topic'); |
|---|
| 41 | exit(); |
|---|
| 42 | } |
|---|
| 43 | |
|---|
| 44 | |
|---|
| 45 | $topic_values = array( |
|---|
| 46 | 'id' => $_SESSION['my_id'], |
|---|
| 47 | 'id_comm' => $token[3], |
|---|
| 48 | 'author' => $_SESSION['my_fname'], |
|---|
| 49 | 'title' => $title, |
|---|
| 50 | 'nb_posts'=> 1, |
|---|
| 51 | 'date' => $date, |
|---|
| 52 | 'last_post_date' => $date); |
|---|
| 53 | $db->autoExecute('community_topic', $topic_values, DB_AUTOQUERY_INSERT); |
|---|
| 54 | |
|---|
| 55 | $id_topic = $db->getOne('SELECT LAST_INSERT_ID()'); |
|---|
| 56 | |
|---|
| 57 | $post_values = array( |
|---|
| 58 | 'id' => $_SESSION['my_id'], |
|---|
| 59 | 'id_topic'=> $id_topic, |
|---|
| 60 | 'id_comm' => $token[3], |
|---|
| 61 | 'author' => $_SESSION['my_fname'], |
|---|
| 62 | 'title' => $title, |
|---|
| 63 | 'message' => $message, |
|---|
| 64 | 'date' => $date); |
|---|
| 65 | $db->autoExecute('community_post', $post_values, DB_AUTOQUERY_INSERT); |
|---|
| 66 | |
|---|
| 67 | $db->query('UPDATE community SET last_post_date=? WHERE id_comm=?', array($date, $token[3])); |
|---|
| 68 | |
|---|
| 69 | } |
|---|
| 70 | |
|---|
| 71 | header('Location: /communities/view/'.$token[3]); |
|---|
| 72 | ?> |
|---|