Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7826431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T09:24:45+00:00 2026-06-02T09:24:45+00:00

The following code is a part of using google api access. After connectDb(), there

  • 0

The following code is a part of using google api access. After connectDb(), there is a line

$q = sprintf("select * from users where google_user_id='%s' limit 1", r($me->id));

...// and more afterwards

$q = sprintf("insert into users (google_user_id, google_email, google_name, google_picture, google_access_token, created, modified) values ('%s','%s','%s','%s','%s',now(),now());",
    r($me->id),
    r($me->email),
    r($me->name),
    r($me->picture),
    r($me->access_token));

And I am not sure what r($me->id) is doing. What is “r” for?

More detailed code is here:

 // get profile   
$params = array(
    'client_id' => CLIENT_ID,
    'client_secret' => CLIENT_SECRET,
    'code' => $_GET['code'],
    'redirect_uri' => SITE_URL.'redirect.php',
    'grant_type' => 'authorization_code'
);
$url = 'https://accounts.google.com/o/oauth2/token';

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($params));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

$rs = curl_exec($curl);
curl_close($curl);

$json = json_decode($rs);

$url = 'https://www.googleapis.com/oauth2/v1/userinfo?access_token='.$json->access_token;
$me = json_decode(file_get_contents($url));

// enter into DB

connectDb();

$q = sprintf("select * from users where google_user_id='%s' limit 1", r($me->id));
$rs = mysql_query($q);
$user = mysql_fetch_assoc($rs);

if (empty($user)) {
    $q = sprintf("insert into users (google_user_id, google_email, google_name, google_picture, google_access_token, created, modified) values ('%s','%s','%s','%s','%s',now(),now());",
        r($me->id),
        r($me->email),
        r($me->name),
        r($me->picture),
        r($me->access_token));
    $rs = mysql_query($q);
    $q = sprintf("select * from users where id=%d", mysql_insert_id());
    $rs = mysql_query($q);
    $user = mysql_fetch_assoc($rs);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T09:24:58+00:00Added an answer on June 2, 2026 at 9:24 am

    Whilst one can’t be sure as it’s not present in the code, it’s being used to SQL-escape values injected into a query… so my guess is that it has been defined as a shortcut alias for one of the string escaping functions. eg

    function r($s) {
        return mysql_real_escape_string($s);
    }
    

    As typing out the name mysql_real_escape_string every time gets a bit boring.

    Escaping prevents SQL-injection attacks. Parameterised queries are generally considered a more sustainable way to tackle it, but in PHP that means changing to the mysqli or PDO interfaces.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the following code as part of an autocomplete script to avoid
Using linkedin-j , I have the following code in one part of my application
Google optimizer includes the following snippet as part of their conversion code. Unfortunately, the
I'm using the following code to find out which part of the page the
Hi Im using the following code: http://vikaskanani.wordpress.com/2011/01/11/android-upload-image-or-file-using-http-post-multi-part/ To POST an image to a WCF
I have the following code, which is run every 10ms as part of a
Following code is from a sample of playframework-2.0: /** * Display the dashboard. */
Following code is to save image took from camera into photo album. if ([mediaType
This following code snippet works fine using jQuery1.2.3, but it doesn’t work with latest
I'm using the following code to add web parts to a page programmatically, however

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.