1- <?
1+ <?php
22
33function create_error_offline ($ msg )
44{
55 header ('Location: ' .URL .'/error.php?msg= ' . rawurlencode (htmlspecialchars ($ msg , ENT_QUOTES )));
66 exit ;
77}
88
9-
10- require_once ('../config.inc ' );
11- require_once (ENGINE . 'Default/smr.inc ' );
12- require_once (get_file_loc ('SmrMySqlDatabase.class.inc ' ));
13- require_once (get_file_loc ('SmrSession.class.inc ' ));
14-
15- require_once (LIB . 'Album/album_functions.php ' );
16-
17- if (SmrSession::$ account_id == 0 )
18- create_error_offline ('You need to logged in to post comments! ' );
19-
20- if (!isset ($ _GET ['album_id ' ]) || empty ($ _GET ['album_id ' ]))
21- create_error_offline ('Which picture do you want comment? ' );
22- else
23- $ album_id = $ _GET ['album_id ' ];
24-
25- if (!is_numeric ($ album_id ))
26- create_error_offline ('Picture ID has to be numeric! ' );
27-
28- if ($ album_id < 1 )
29- create_error_offline ('Picture ID has to be positive! ' );
30-
31- require_once (get_file_loc ('SmrAccount.class.inc ' ));
32- $ account =& SmrAccount::getAccount (SmrSession::$ account_id );
33-
34- if (isset ($ _GET ['action ' ]) && $ _GET ['action ' ] == 'Moderate ' )
9+ try
3510{
36- if (!$ account ->hasPermission (PERMISSION_MODERATE_PHOTO_ALBUM ))
37- create_error_offline ('You do not have permission to do that! ' );
38- $ container = create_container ('skeleton.php ' , 'album_moderate.php ' );
39- $ container ['account_id ' ] = $ album_id ;
40-
41- forward ($ container );
11+ require_once ('../config.inc ' );
12+ require_once (ENGINE . 'Default/smr.inc ' );
13+ require_once (get_file_loc ('SmrMySqlDatabase.class.inc ' ));
14+ require_once (get_file_loc ('SmrSession.class.inc ' ));
15+
16+ require_once (LIB . 'Album/album_functions.php ' );
17+
18+ if (SmrSession::$ account_id == 0 )
19+ create_error_offline ('You need to logged in to post comments! ' );
20+
21+ if (!isset ($ _GET ['album_id ' ]) || empty ($ _GET ['album_id ' ]))
22+ create_error_offline ('Which picture do you want comment? ' );
23+ else
24+ $ album_id = $ _GET ['album_id ' ];
25+
26+ if (!is_numeric ($ album_id ))
27+ create_error_offline ('Picture ID has to be numeric! ' );
28+
29+ if ($ album_id < 1 )
30+ create_error_offline ('Picture ID has to be positive! ' );
31+
32+ require_once (get_file_loc ('SmrAccount.class.inc ' ));
33+ $ account =& SmrAccount::getAccount (SmrSession::$ account_id );
34+
35+ if (isset ($ _GET ['action ' ]) && $ _GET ['action ' ] == 'Moderate ' )
36+ {
37+ if (!$ account ->hasPermission (PERMISSION_MODERATE_PHOTO_ALBUM ))
38+ create_error_offline ('You do not have permission to do that! ' );
39+ $ container = create_container ('skeleton.php ' , 'album_moderate.php ' );
40+ $ container ['account_id ' ] = $ album_id ;
41+
42+ forward ($ container );
43+ exit ;
44+
45+ }
46+
47+ $ db = new SmrMySqlDatabase ();
48+
49+ if (!isset ($ _GET ['comment ' ]) || empty ($ _GET ['comment ' ]))
50+ create_error_offline ('Please enter a comment ' );
51+ else
52+ $ comment = $ _GET ['comment ' ];
53+
54+ // get current time
55+ $ curr_time = TIME ;
56+
57+ $ comment = word_filter ($ comment );
58+ $ account ->sendMessageToBox (BOX_ALBUM_COMMENTS ,$ comment );
59+
60+ // check if we have comments for this album already
61+ $ db ->lockTable ('album_has_comments ' );
62+
63+ $ db ->query ('SELECT MAX(comment_id) FROM album_has_comments WHERE album_id = ' .$ album_id );
64+ if ($ db ->nextRecord ())
65+ $ comment_id = $ db ->getField ('MAX(comment_id) ' ) + 1 ;
66+ else
67+ $ comment_id = 1 ;
68+
69+ $ db ->query ('INSERT INTO album_has_comments
70+ (album_id, comment_id, time, post_id, msg)
71+ VALUES ( ' .$ album_id .', ' .$ comment_id .', ' .$ curr_time .', ' .SmrSession::$ account_id .', ' .$ db ->escapeString ($ comment ).') ' );
72+ $ db ->unlock ();
73+
74+ header ('Location: ' .URL .'/album/? ' . get_album_nick ($ album_id ));
4275 exit ;
43-
4476}
45-
46- $ db = new SmrMySqlDatabase ();
47-
48- if (!isset ($ _GET ['comment ' ]) || empty ($ _GET ['comment ' ]))
49- create_error_offline ('Please enter a comment ' );
50- else
51- $ comment = $ _GET ['comment ' ];
52-
53- // get current time
54- $ curr_time = TIME ;
55-
56- $ comment = word_filter ($ comment );
57- $ account ->sendMessageToBox (BOX_ALBUM_COMMENTS ,$ comment );
58-
59- // check if we have comments for this album already
60- $ db ->lockTable ('album_has_comments ' );
61-
62- $ db ->query ('SELECT MAX(comment_id) FROM album_has_comments WHERE album_id = ' .$ album_id );
63- if ($ db ->nextRecord ())
64- $ comment_id = $ db ->getField ('MAX(comment_id) ' ) + 1 ;
65- else
66- $ comment_id = 1 ;
67-
68- $ db ->query ('INSERT INTO album_has_comments
69- (album_id, comment_id, time, post_id, msg)
70- VALUES ( ' .$ album_id .', ' .$ comment_id .', ' .$ curr_time .', ' .SmrSession::$ account_id .', ' .$ db ->escapeString ($ comment ).') ' );
71- $ db ->unlock ();
72-
73- header ('Location: ' .URL .'/album/? ' . get_album_nick ($ album_id ));
74- exit ;
77+ catch (Exception $ e )
78+ {
79+ handleException ($ e );
80+ }
7581
7682?>
0 commit comments