function do_step($from, $to) { global $facebook; global $canvas_url; $conn = get_db_conn(); mysql_query('INSERT INTO footprints SET `from`=' . $from . ', `time`=' . time() . ', `to`=' . $to, $conn); $prints = get_prints($to); try { // Set Profile FBML $fbml = render_profile_action($to, count($prints)) . render_profile_box($to, $prints); $facebook->api_client->profile_setFBML($fbml, $to); // Send notification email $send_email_url = $facebook->api_client->notifications_send($to, ' stepped on you. ' . '<a href="' . $canvas_url . '/footprints/">See all your Footprints</a>.', '<fb:notif-subject>You have been stepped on...</fb:notif-subject>' . ' stepped on you. <a href="' . $canvas_url . '/footprints/">See all your Footprints</a>.'); // Publish feed story $feed_title = '<fb:userlink uid="' . $from . '" shownetwork="false"/> stepped on <fb:name uid="' . $to . '"/>.'; $feed_body = 'Check out <a href="' . $canvas_url . '/footprints/?to=' . $to . '">' . '<fb:name uid="' . $to . '" firstnameonly="true" possessive="true"/> Footprints</a>.'; $facebook->api_client->feed_publishActionOfUser($feed_title, $feed_body); } catch (Exception $e) { error_log($e->getMessage()); } if (isset($send_email_url) && $send_email_url) { $facebook->redirect($send_email_url . '&next=' . urlencode('?to=' . $to) . '&canvas'); } return $prints; }
function do_step($from, $to) { global $facebook; $conn = get_db_conn(); mysql_query('INSERT INTO footprints SET `from`=' . $from . ', `time`=' . time() . ', `to`=' . $to, $conn); $prints = get_prints($to); try { // Set Profile FBML $fbml = render_profile_action($to, count($prints)) . render_profile_box($to, $prints); // start batch operation $facebook->api_client->begin_batch(); $facebook->api_client->profile_setFBML($fbml, $to); // Send notification // Notice the use of reference '&' $result =& $facebook->api_client->notifications_send($to, ' stepped on you. ' . '<a href="http://apps.facebook.com/footprints/">See all your Footprints</a>.'); // Publish feed story $feed_title = '<fb:userlink uid="' . $from . '" shownetwork="false"/> stepped on <fb:name uid="' . $to . '"/>.'; $feed_body = 'Check out <a href="http://apps.facebook.com/footprints/?to=' . $to . '">' . '<fb:name uid="' . $to . '" firstnameonly="true" possessive="true"/> Footprints</a>.'; $facebook->api_client->feed_publishActionOfUser($feed_title, $feed_body); // End batch operation. This will actually send queued API call to Facebook in // a single HTTP request $facebook->api_client->end_batch(); } catch (Exception $e) { error_log($e->getMessage()); } return $prints; }
function get_prints($user) { $conn = get_db_conn(); $res = mysql_query('SELECT `from`, `to`, `time` FROM footprints WHERE `to`=' . $user . ' ORDER BY `time` DESC', $conn); $prints = array(); while ($row = mysql_fetch_assoc($res)) { $prints[] = $row; } return $prints; }
function get_tt_user($user_fb) { $conn = get_db_conn(); $result = mysql_query("SELECT `user_tt` FROM `users` WHERE (`user_fb` = '{$user_fb}')", $conn); if (mysql_num_rows($result) == 1) { list($user_tt) = mysql_fetch_array($result); return $user_tt; } else { return FALSE; } }
function update_share_limit($sharer, $borrower, $share_limit) { $conn = get_db_conn(); $sql = "UPDATE trust SET share_limit='{$share_limit}' " . "WHERE sharer='{$sharer}', borrower='{$borrower}'"; return mysql_query($sql, $conn); }
function delete_event($calendar_id, $event_id) { // get required objects and variables $app = \Slim\Slim::getInstance(); $response_body_array = array('errors' => array()); $token = $app->request->params('token'); // attempt DB operations, returning on error $unknown_error = 77; if (!($conn = get_db_conn()) | !($stmt = $conn->prepare('CALL delete_event(?, ?, ?, @error_28, @error_18, @error_65, @error_75)')) | !$stmt->bind_param('sss', $token, $event_id, $calendar_id) | !$stmt->execute() | !$stmt->close() | !($result_28 = $conn->query('SELECT @error_28')) | !($result_18 = $conn->query('SELECT @error_18')) | !($result_65 = $conn->query('SELECT @error_65')) | !($result_75 = $conn->query('SELECT @error_75')) | !$conn->close()) { $response_body_array['errors'][] = $unknown_error; echo prepare_response_body($response_body_array); return; } // check for errors if ($result_28->fetch_assoc()['@error_28']) { $response_body_array['errors'][] = 28; } $result_28->free(); if ($result_18->fetch_assoc()['@error_18']) { $response_body_array['errors'][] = 18; } $result_18->free(); if ($result_65->fetch_assoc()['@error_65']) { $response_body_array['errors'][] = 65; } $result_65->free(); if ($result_75->fetch_assoc()['@error_75']) { $response_body_array['errors'][] = 75; } $result_75->free(); // return response echo prepare_response_body($response_body_array); return; }
<?php include_once 'lib/config.php'; include_once 'lib/lib.php'; include_once 'model/user.php'; get_db_conn(0); $erroroccured = false; session_start(); // If user is logged in then log them out if (isset($_SESSION['username'])) { session_destroy(); // Log user out session_start(); // Start a new session $logout = true; $erroroccured = true; $error = "You have been logged out please login again."; } $requiredparameterssupplied = false; if (isset($_POST['USERNAME'])) { $username = $_POST['USERNAME']; if (isset($_POST['PASSWORD'])) { $password = $_POST['PASSWORD']; $requiredparameterssupplied = true; } } // Validate credentials if user has attempted to login if ($requiredparameterssupplied) { $login_failed = false; $isvaliduser = checkUser($username, $password); // Process the results of the attempt to login.
<?php include_once '../lib/config.php'; include_once '../lib/lib.php'; include_once '../model/user.php'; get_db_conn(1); session_start(); $error = ''; $erroroccured = false; $username = $_SESSION['username']; $userid = $_SESSION['userid']; if (isset($userid) && !($userid == "")) { // The userid has been supplied $user = getUserByID($userid); if (!isset($user["USERID"])) { $erroroccured = true; $error .= 'ERROR - No details exists for this user [' . $_SESSION['userid'] . ':' . $_SESSION['username'] . '] please try again later'; } else { $action = 'updateuser'; } } else { $error .= 'ERROR - Creating a new user as the supplied user details wer - ' . $_SESSION['username'] . ' - ' . $_SESSION['userid']; $action = 'createuser'; } echo ' <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>onemanwenttomow - ' . $username . '</title> <link rel="stylesheet" href="../res/stylesheet.css" type="text/css" media="all" /> <script type="text/javascript" src="../lib/jquery/jquery-1.4.2.js"></script>
function render_current_user_profile($user) { $conn = get_db_conn(); $sql = 'SELECT id, from_user, quote, source_type FROM quotes WHERE `to_user`=\'' . $user . '\' AND `state`=\'pending\';'; $pending_rows = mysql_query($sql, $conn); if (mysql_num_rows($pending_rows) == 0) { return '<fb:visible-to-user uid="' . $user . '">You\'ve answered all the quotes!</fb:visible-to-user>'; } $fbml = '<fb:visible-to-user uid="' . $user . '"><ul>'; while ($row = mysql_fetch_assoc($pending_rows)) { $fbml = $fbml . '<li>' . profile_guess_link($row['from_user'], guess_url($row['id']), $row['source_type'], $row['quote']) . '</li>'; $fbml = $fbml . '<br />'; } return $fbml . '</ul></fb:visible-to-user>'; }