'; } $code .= '<<Prev'; if ($o != 0) { $code .= ''; } $code .= ' | '; for ($i = 0; $i <= $pages; $i++) { $page_num = $i + 1; $offset = $i * 10; if ($o != $offset) { $code .= '$page_num | "; } else { $code .= "$page_num | "; } } if ($next < $count) { $code .= ""; } $code .= "Next>>"; if ($next < $count) { $code .= ""; } return($code); } function friend_list($dbh, $user_num) { $sql = 'select u.user_num, u.username from users u, friend_list fl where fl.user_num = ' . $user_num . ' and u.user_num = fl.friend_num order by u.username'; $result = mysql_query($sql, $dbh); while($data = mysql_fetch_array($result)){ $friends .= "$data[username], "; } if ($friends) { $friends = substr("$friends", 0, -2); echo "$friends"; } else { echo " "; } } function generate_pm_nav($dbh, $user_num, $offset) { $sql = 'select count(*) from private_messages where ((sender_num = ' . $user_num . ' and sender_status = \'s\') or (recipient_num = ' . $user_num . ' and recipient_status = \'a\'))'; $result = mysql_query($sql, $dbh); $count = mysql_result($result, 0); $pages = floor($count / 50); $prev = $offset - 50; $next = $offset + 50; if ($offset != "0") { $code .= ""; } $code .= "<<Prev"; if ($offset != "0") { $code .= ""; } $code .= " "; for ($i = 0; $i <= $pages; $i++) { $page_num = $i + 1; $o = $i * 50; if ($offset != $o) { $code .= "$page_num | "; } else { $code .= "$page_num | "; } } if($next < $count) { $code .= ""; } $code .= "Next>>"; if($next < $count) { $code .= ""; } return($code); } function private_messages($dbh, $user_num, $archive, $offset) { if (!$archive) { $result = mysql_query("select u.user_num, u.username, pm.message_num, pm.date, pm.message from users u, private_messages pm where pm.sender_num = u.user_num and pm.recipient_num = '$user_num' and pm.recipient_status in ('r', 'u') order by pm.date desc", $dbh); } else { $sql = "select u.user_num, u.username, pm.message_num, pm.date, pm.message from users u, private_messages pm where ((pm.sender_num = '$user_num' and pm.sender_status = 's') or (pm.recipient_num = '$user_num' and pm.recipient_status = 'a')) and pm.sender_num = u.user_num order by pm.date desc limit $offset, 50"; $result = mysql_query($sql, $dbh); } while($data = mysql_fetch_array($result)){ $sub_result = mysql_query("select u.user_num, u.username from users u, private_messages pm where pm.message_num = '$data[message_num]' and pm.sender_num = '$user_num' and pm.recipient_num = u.user_num", $dbh); if($sub_data = mysql_fetch_array($sub_result)){ $sent_to = "$sub_data[username]"; } else { $sent_to = ""; } $code .= ' '; $code .= ' '; if ($archive) { $code .= ' '; $code .= ' '; $code .= ' '; $code .= ' '; $code .= ' '; $code .= ' '; $code .= ' '; $code .= ' '; } else { $code .= 'Delete'; } $code .= ' '; $code .= ' '; if(!$archive) { $sub_result = mysql_query("update private_messages set recipient_status = 'r' where message_num = '$data[message_num]'", $dbh); } } return($code); } function response($dbh, $sender_num, $recipient_num, $message_num) { $result = mysql_query("select pm.message, u.username, u.user_num, pm.date from private_messages pm, users u where pm.recipient_num = $recipient_num and pm.sender_num = $sender_num and pm.message_num = $message_num and u.user_num = pm.sender_num", $dbh); if($data = mysql_fetch_array($result)) { $code = "
'; $code .= ' '; $code .= ' '; } else { $code .= ' '; } $code .= '

' . $data['message'] . '

'; $code .= '
' . $data['username'] . 'Author:
'; if ($sent_to) { $code .= 'Sent To:
'; } $code .= 'Date:
' . $data['username'] . '
'; if ($sent_to) { $code .= $sent_to . '
'; } $code .= $data['date'] . '
'; if ($user_num != $data[user_num]) { $code .= 'Respond  '; } if (!$archive) { $code .= 'Delete  Archive
\n"; $code .= " \n"; $code .= " \n"; $code .= " \n"; $code .= "
\n"; $code .= " \n"; $code .= " \n"; $code .= " \n"; $code .= " \n"; $code .= " \n"; $code .= " \n"; $code .= " \n"; $code .= " \n"; $code .= " \n"; $code .= " \n"; $code .= " \n"; $code .= "
\n"; $code .= "

$data[message]

\n"; $code .= "
Author:
Date:
$data[username]
$data[date]
  
\n"; $code .= "
\n"; } return($code); } function submit_messages($dbh, $sender_num, $recipient_num, $message) { $message = mysql_real_escape_string($message); $result = mysql_query("insert into private_messages (sender_num, recipient_num, date, message, recipient_status, sender_status) values ('$sender_num', '$recipient_num', sysdate(), '$message', 'u', 's')", $dbh); $result = mysql_query("select username from users where user_num = $sender_num", $dbh); $sender_name = mysql_result($result, 0); $result = mysql_query("select pm_notification from settings where user_num = $recipient_num", $dbh); if(mysql_result($result, 0)) { $result = mysql_query("select u.username, p.email from users u, profiles p where u.user_num = $recipient_num and p.user_num = u.user_num", $dbh); $data = mysql_fetch_array($result); $to = "$data[email]"; $subject = "Private Message from $sender_name!!!"; $message = "$data[username],\n\nYou have a new private message from $sender_name waiting for you.\n\nhttp://www.cultzero.com/\nIf you do not want to receive further PM notifications, this feature can be turned off on your profile page."; $headers = "From: CultZero \n"; $headers .= "X-Sender: CultZero \n"; mail($to, $subject, $message, $headers); } } function delete_message($dbh, $user_num, $message_num) { $result = mysql_query("select sender_num, recipient_num from private_messages where message_num = '$message_num'", $dbh); $data = mysql_fetch_array($result); if ($user_num == $data[sender_num]) { $result = mysql_query("update private_messages set sender_status = 'd' where message_num = '$message_num' and sender_num = '$user_num'", $dbh); } if ($user_num == $data[recipient_num]) { $result = mysql_query("update private_messages set recipient_status = 'd' where message_num = '$message_num' and recipient_num = '$user_num'", $dbh); } } function pm_notification($dbh, $user_num) { $result = mysql_query("select pm_notification from settings where user_num = '$user_num'", $dbh); $bool = mysql_result($result, 0); return($bool); } function view_online($dbh, $user_num) { $result = mysql_query("select view_online from settings where user_num = '$user_num'", $dbh); $bool = mysql_result($result, 0); return($bool); } $f = (isset($_POST['f'])) ? $_POST['f'] : $_GET['f']; $u = (isset($_POST['u'])) ? $_POST['u'] : $_GET['u']; $s = $_GET['s']; $g = $_GET['g']; $r = $_GET['r']; $a = (isset($_POST['a'])) ? $_POST['a'] : $_GET['a']; $o = (isset($_POST['o'])) ? $_POST['o'] : $_GET['o']; $dbh = @mysql_connect($DBHOST, $DBUSER, $DBPASSWORD); mysql_select_db($DBNAME, $dbh); if (isset($user_num)) { $username = get_username($dbh, $user_num); } if ($u) { print_header(); } if ($f == "m") { $sender_num = $_POST['sender_num']; $recipient_num = $_POST['recipient_num']; $message = $_POST['message']; submit_messages($dbh, $sender_num, $recipient_num, $message); header("Location: " . prep_url("profiles.php?u=$user_num", true)); } if ($f == "a") { $mn = $_GET['mn']; $result = mysql_query("update private_messages set recipient_status = 'a' where message_num = '$mn' and recipient_num = '$user_num'", $dbh); } if ($f == "d") { $mn = $_GET['mn']; delete_message($dbh, $user_num, $mn); } if ($f == "md") { $mn = $_POST['mn']; $count = count($mn); for ($i = 0; $i < $count; $i++) { delete_message($dbh, $user_num, $mn[$i]); } } if ($f == "pmn") { $v = $_GET['v']; $result = mysql_query("update settings set pm_notification = $v where user_num = '$user_num'", $dbh); } if ($f == "vo") { $v = $_GET['v']; $result = mysql_query("update settings set view_online = $v where user_num = '$user_num'", $dbh); } if ($u) { $result = mysql_query("select 1 from users where user_num = $u and status != 0", $dbh); if ($data = mysql_fetch_array($result)) { header("Location: " . prep_url("inactive.php", true)); } } if (!$u) { $sql = "select count(*) from profiles p, users u where p.user_num = u.user_num and u.status = '0' "; if ($g == 1) { $sql .= "and p.gender = 'M' "; } elseif ($g == 2) { $sql .= "and p.gender = 'F' "; } $result = mysql_query($sql, $dbh); $count = mysql_result($result, 0); $pages = floor($count / 10); if(!$o) { $o = 0; } $prev = $o - 10; $next = $o + 10; } mysql_close($dbh); $profile_nav_code = generate_profile_nav ($o, $s, $g, $prev, $pages, $next, $count); ?>

CultZero

Welcome !!!