51ff3226 |
1 | <?php |
2 | function set_mood() { |
3 | global $db,$error; |
4 | |
5 | $set = $db->query(sprintf('select moods from users where user_id = %d', $_SESSION['user_id'])); |
6 | $set->next(); |
7 | $moods_expl = explode(";",$set->getString('moods')); |
8 | $moods_expl[count($moods_expl)-1] = $_POST['mood']; |
9 | |
10 | if (is_numeric($_POST['mood'])) { |
11 | $_SESSION['mood_id'] = $_POST['mood']; |
12 | $set = $db->query(sprintf('select node_name, node_content from nodes where node_id = %d', $_POST['mood'])); |
13 | $set->next(); |
14 | $_SESSION['mood_name'] = strip_tags($set->getString('node_name')); |
15 | $_SESSION['mood_content'] = addslashes(substr(strip_tags($set->getString('node_content')),0,223)); |
16 | } |
17 | else { |
18 | $_SESSION['mood_id'] = ''; |
19 | $_SESSION['mood_name'] = ''; |
20 | $_SESSION['mood_content'] = ''; |
21 | } |
22 | $moods = implode(";",$moods_expl); |
23 | $db->query(sprintf('update users set moods="%s" where user_id=%d', $moods, $_SESSION['user_id'])); |
24 | } |
25 | ?> |