Blame view

social/config/functions.php 1.1 KB
42868d70   andryeyev   Создал GIT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
  <?php
  
  //require 'dbconfig.php';
  
  //echo dirname ( __FILE__ )."/new_csv/mysql.class.php";
  //exit;
  
  
  
  @include_once("../config/config.php");
  @include_once("../new_csv/mysql.class.php");
  
  
  define ("DBHOST", DB_HOST); 
  define ("DBNAME", DB_BASE);
  define ("DBUSER", DB_USER);
  define ("DBPASS", DB_PSW);  
  $db = new db;
  
  
  class User {
  
      function checkUser($uid, $oauth_provider, $username) 
  	{
          $query = mysql_query("SELECT * FROM `users` WHERE oauth_uid = '$uid' and oauth_provider = '$oauth_provider'") or die(mysql_error());
          $result = mysql_fetch_array($query);
          if (!empty($result)) {
              # User is already present
          } else {
              #user not present. Insert a new Record
              $query = mysql_query("INSERT INTO `users` (oauth_provider, oauth_uid, username) VALUES ('$oauth_provider', $uid, '$username')") or die(mysql_error());
              $query = mysql_query("SELECT * FROM `users` WHERE oauth_uid = '$uid' and oauth_provider = '$oauth_provider'");
              $result = mysql_fetch_array($query);
              return $result;
          }
          return $result;
      }
  
      
  
  }
  
  ?>