diff -r 8f6143115bf5 -r a8a21e1c7afa punbb/misc.php --- a/punbb/misc.php Wed Jul 11 21:28:39 2007 -0400 +++ b/punbb/misc.php Thu Jul 12 01:04:01 2007 -0400 @@ -26,8 +26,11 @@ if (isset($_GET['action'])) define('PUN_QUIET_VISIT', 1); -define('PUN_ROOT', './'); -require PUN_ROOT.'include/common.php'; +//define('PUN_ROOT', './'); +//require PUN_ROOT.'include/common.php'; + +global $pun_db, $pun_user, $pun_config, $lang_common; + // Load the misc.php language file @@ -64,9 +67,9 @@ if ($pun_user['is_guest']) message($lang_common['No permission']); - $db->query('UPDATE '.$db->prefix.'users SET last_visit='.$pun_user['logged'].' WHERE id='.$pun_user['id']) or error('Unable to update user last visit data', __FILE__, __LINE__, $db->error()); + $pun_db->query('UPDATE '.$pun_db->prefix.'users SET last_visit='.$pun_user['logged'].' WHERE id='.$pun_user['id']) or error('Unable to update user last visit data', __FILE__, __LINE__, $pun_db->error()); - redirect('index.php', $lang_misc['Mark read redirect']); + pun_redirect('index.php', $lang_misc['Mark read redirect']); } @@ -79,13 +82,13 @@ if ($recipient_id < 2) message($lang_common['Bad request']); - $result = $db->query('SELECT username, email, email_setting FROM '.$db->prefix.'users WHERE id='.$recipient_id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error()); - if (!$db->num_rows($result)) + $result = $pun_db->query('SELECT username, email, email_setting FROM '.$pun_db->prefix.'users WHERE id='.$recipient_id) or error('Unable to fetch user info', __FILE__, __LINE__, $pun_db->error()); + if (!$pun_db->num_rows($result)) message($lang_common['Bad request']); - list($recipient, $recipient_email, $email_setting) = $db->fetch_row($result); + list($recipient, $recipient_email, $email_setting) = $pun_db->fetch_row($result); - if ($email_setting == 2 && $pun_user['g_id'] > PUN_MOD) + if ($email_setting == 2 && $pun_user['g_id'] < PUN_MOD) message($lang_misc['Form e-mail disabled']); @@ -120,7 +123,7 @@ pun_mail($recipient_email, $mail_subject, $mail_message, '"'.str_replace('"', '', $pun_user['username']).'" <'.$pun_user['email'].'>'); - redirect(htmlspecialchars($_POST['redirect_url']), $lang_misc['E-mail sent redirect']); + pun_redirect(htmlspecialchars($_POST['redirect_url']), $lang_misc['E-mail sent redirect']); } @@ -178,22 +181,22 @@ message($lang_misc['No reason']); // Get the topic ID - $result = $db->query('SELECT topic_id FROM '.$db->prefix.'posts WHERE id='.$post_id) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error()); - if (!$db->num_rows($result)) + $result = $pun_db->query('SELECT topic_id FROM '.$pun_db->prefix.'posts WHERE id='.$post_id) or error('Unable to fetch post info', __FILE__, __LINE__, $pun_db->error()); + if (!$pun_db->num_rows($result)) message($lang_common['Bad request']); - $topic_id = $db->result($result); + $topic_id = $pun_db->result($result); // Get the subject and forum ID - $result = $db->query('SELECT subject, forum_id FROM '.$db->prefix.'topics WHERE id='.$topic_id) or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error()); - if (!$db->num_rows($result)) + $result = $pun_db->query('SELECT subject, forum_id FROM '.$pun_db->prefix.'topics WHERE id='.$topic_id) or error('Unable to fetch topic info', __FILE__, __LINE__, $pun_db->error()); + if (!$pun_db->num_rows($result)) message($lang_common['Bad request']); - list($subject, $forum_id) = $db->fetch_row($result); + list($subject, $forum_id) = $pun_db->fetch_row($result); // Should we use the internal report handling? if ($pun_config['o_report_method'] == 0 || $pun_config['o_report_method'] == 2) - $db->query('INSERT INTO '.$db->prefix.'reports (post_id, topic_id, forum_id, reported_by, created, message) VALUES('.$post_id.', '.$topic_id.', '.$forum_id.', '.$pun_user['id'].', '.time().', \''.$db->escape($reason).'\')' ) or error('Unable to create report', __FILE__, __LINE__, $db->error()); + $pun_db->query('INSERT INTO '.$pun_db->prefix.'reports (post_id, topic_id, forum_id, reported_by, created, message) VALUES('.$post_id.', '.$topic_id.', '.$forum_id.', '.$pun_user['id'].', '.time().', \''.$pun_db->escape($reason).'\')' ) or error('Unable to create report', __FILE__, __LINE__, $pun_db->error()); // Should we e-mail the report? if ($pun_config['o_report_method'] == 1 || $pun_config['o_report_method'] == 2) @@ -210,7 +213,7 @@ } } - redirect('viewtopic.php?pid='.$post_id.'#p'.$post_id, $lang_misc['Report redirect']); + pun_redirect('viewtopic.php?pid='.$post_id.'#p'.$post_id, $lang_misc['Report redirect']); } @@ -252,13 +255,13 @@ if ($topic_id < 1) message($lang_common['Bad request']); - $result = $db->query('SELECT 1 FROM '.$db->prefix.'subscriptions WHERE user_id='.$pun_user['id'].' AND topic_id='.$topic_id) or error('Unable to fetch subscription info', __FILE__, __LINE__, $db->error()); - if ($db->num_rows($result)) + $result = $pun_db->query('SELECT 1 FROM '.$pun_db->prefix.'subscriptions WHERE user_id='.$pun_user['id'].' AND topic_id='.$topic_id) or error('Unable to fetch subscription info', __FILE__, __LINE__, $pun_db->error()); + if ($pun_db->num_rows($result)) message($lang_misc['Already subscribed']); - $db->query('INSERT INTO '.$db->prefix.'subscriptions (user_id, topic_id) VALUES('.$pun_user['id'].' ,'.$topic_id.')') or error('Unable to add subscription', __FILE__, __LINE__, $db->error()); + $pun_db->query('INSERT INTO '.$pun_db->prefix.'subscriptions (user_id, topic_id) VALUES('.$pun_user['id'].' ,'.$topic_id.')') or error('Unable to add subscription', __FILE__, __LINE__, $pun_db->error()); - redirect('viewtopic.php?id='.$topic_id, $lang_misc['Subscribe redirect']); + pun_redirect('viewtopic.php?id='.$topic_id, $lang_misc['Subscribe redirect']); } @@ -271,13 +274,13 @@ if ($topic_id < 1) message($lang_common['Bad request']); - $result = $db->query('SELECT 1 FROM '.$db->prefix.'subscriptions WHERE user_id='.$pun_user['id'].' AND topic_id='.$topic_id) or error('Unable to fetch subscription info', __FILE__, __LINE__, $db->error()); - if (!$db->num_rows($result)) + $result = $pun_db->query('SELECT 1 FROM '.$pun_db->prefix.'subscriptions WHERE user_id='.$pun_user['id'].' AND topic_id='.$topic_id) or error('Unable to fetch subscription info', __FILE__, __LINE__, $pun_db->error()); + if (!$pun_db->num_rows($result)) message($lang_misc['Not subscribed']); - $db->query('DELETE FROM '.$db->prefix.'subscriptions WHERE user_id='.$pun_user['id'].' AND topic_id='.$topic_id) or error('Unable to remove subscription', __FILE__, __LINE__, $db->error()); + $pun_db->query('DELETE FROM '.$pun_db->prefix.'subscriptions WHERE user_id='.$pun_user['id'].' AND topic_id='.$topic_id) or error('Unable to remove subscription', __FILE__, __LINE__, $pun_db->error()); - redirect('viewtopic.php?id='.$topic_id, $lang_misc['Unsubscribe redirect']); + pun_redirect('viewtopic.php?id='.$topic_id, $lang_misc['Unsubscribe redirect']); }