if ($HTTP_GET_VARS['expert'] == "" or $HTTP_GET_VARS['target'] == "") { page_close(); Header("Location: " . $sess->url("/Experts/" . rawurlencode($expert))); exit; } $uname = uid2name($HTTP_GET_VARS['expert']); $hisname = uid2name($HTTP_GET_VARS['target']); /*foreach($HTTP_GET_VARS as $key => $value) echo("$key = $value<br>"); die("test");*/ switch ($HTTP_GET_VARS['action']) { case "comfirm": //echo("blepp"); delete_friendship_request($HTTP_GET_VARS['expert'], $HTTP_GET_VARS['target']); create_friendship($HTTP_GET_VARS['expert'], $HTTP_GET_VARS['target']); friendship_notification($uname, $HTTP_GET_VARS['target'], "accepted"); friendship_notification($uname, $HTTP_GET_VARS['target'], "accepted_self", $hisname); break; case "decline": delete_friendship_request($HTTP_GET_VARS['expert'], $HTTP_GET_VARS['target']); friendship_notification($uname, $HTTP_GET_VARS['target'], "ignore"); friendship_notification($uname, $HTTP_GET_VARS['target'], "ignore_self", $hisname); break; case "quit": remove_friendship($HTTP_GET_VARS['expert'], $HTTP_GET_VARS['target']); friendship_notification($uname, $HTTP_GET_VARS['target'], "term"); friendship_notification($uname, $HTTP_GET_VARS['target'], "term_self", $hisname); break; case "cancel": delete_friendship_request($HTTP_GET_VARS['expert'], $HTTP_GET_VARS['target']);
function do_changes() { global $HTTP_POST_VARS, $invalid_user_names, $username, $uid; $errors = 0; $username = strtolower($HTTP_POST_VARS['field_username']); if ($username == "" and $HTTP_POST_VARS['field_username_suggestion'] != '') { if ($HTTP_POST_VARS['field_username_suggestion'] == 'other') { $username = $HTTP_POST_VARS['field_username_txt']; } else { $username = $HTTP_POST_VARS['field_username_suggestion']; } } foreach ($invalid_user_names as $baduser) { if ($username == $baduser) { $errors = $errors | ERR_NOUSERNAME; } } if ($username == "") { $errors = $errors | ERR_NOUSERNAME; } // lock_table('auth_user'); //we do not allow any writes of usernames whiile checking for dupes... if (user_exists($username)) { $errors = $errors | ERR_USEREXISTS; } if ($HTTP_POST_VARS['field_email'] == "") { $errors = $errors | ERR_NOEMAIL; } if (!validate_email($HTTP_POST_VARS['field_email'])) { $errors = $errors | ERR_NOEMAIL; } if ($HTTP_POST_VARS['field_password1'] != $HTTP_POST_VARS['field_password2']) { $errors = $errors | ERR_PASSWORDMATCH; } $resp = recaptcha_check_answer(RECAPTCHA_PRIVATE_KEY, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { $errors = $errors | ERR_CAPTCHA; } if ($errors != 0) { return $errors; } $userval['name'] = $username; $userval['email'] = $HTTP_POST_VARS['field_email']; $userval['password'] = $HTTP_POST_VARS['field_password1']; $uid = add_user($userval); create_friendship($uid, 'c1b984f523714d0bdf9b0bbf9bceea4e'); create_friendship('c1b984f523714d0bdf9b0bbf9bceea4e', $uid); return 0; }
<?php require 'db_connect.php'; $users = array('cody' => array('gary', 'chris', 'josh', 'gerald', 'carol', 'rebecca'), 'gary' => array('cody', 'chris', 'melissa', 'suzanne'), 'chris' => array('cody', 'gary'), 'melissa' => array('tom', 'hunter')); pg_query($conn, 'DELETE FROM users'); pg_query($conn, 'DELETE FROM friendships'); pg_query($conn, 'DELETE FROM places'); pg_query($conn, 'DELETE FROM lists'); /* Create Users */ foreach ($users as $key => $value) { create_user($key); foreach ($value as $user) { create_user($user); } } /* Create Friendships */ foreach ($users as $key => $value) { $user = user($key); foreach ($value as $record) { $friend = user($record); create_friendship($user, $friend); } } pg_query($conn, sprintf("INSERT INTO places (name) VALUES ('%s')", "25 Lusk")); $place = place_by_name('25 Lusk'); $user = user('melissa'); pg_query($conn, sprintf("INSERT INTO lists (user_id, place_id) VALUES (%d, %d)", $user['id'], $place['id'])); print_r($user); echo "\n-------------\n"; print_r($place);