Advertisement
Guest User

Untitled

a guest
Jul 29th, 2015
39
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3.     if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
  4.         header('Location: ../');
  5.         exit;
  6.     }
  7.  
  8.     function qa_get_mysql_user_column_type()
  9.     {
  10.  
  11.     //  Set this before anything else
  12.         return 'VARCHAR(255)';
  13.  
  14.     }
  15.  
  16.  
  17.     function qa_get_login_links($relative_url_prefix, $redirect_back_to_url)
  18.     {
  19.  
  20.     //  Until you edit this function, don't show login, register or logout links
  21.  
  22.         return array(
  23.             'login' => 'http://www.site.org/cgi-bin/community.cgi',
  24.             'register' => 'http://www.site.org/cgi-bin/community.cgi?do=user_signup',
  25.             'logout' => 'http://www.site.org/cgi-bin/community.cgi?do=user_logout',
  26.         );
  27.  
  28.     }
  29.  
  30.  
  31.     function qa_get_logged_in_user()
  32.     {
  33.  
  34.     //  Until you edit this function, nobody is ever logged in
  35.  
  36.         if (isset($_COOKIE['Community_Sesssion'])) {
  37.  
  38.             $session_id =$_COOKIE['Community_Sesssion'];
  39.  
  40.             //Define Connection Within Function
  41.             $conn = mysql_connect("localhost",'my_user','my_pass');
  42.             mysql_select_db('the_db', $conn);
  43.  
  44.             $result = mysql_query("SELECT sess_user_fk FROM comm_sessions WHERE sess_id='".mysql_real_escape_string($session_id)."'");
  45.             while($person = mysql_fetch_array($result)) {
  46.                 $person_id = $person['sess_user_fk'];
  47.             }
  48.  
  49.  
  50.             if ($person_id) {
  51.                 $glinks_connection = mysql_connect("localhost",'my_user','my_pass');
  52.                 mysql_select_db('my_db', $conn);
  53.                 $result2 = mysql_fetch_assoc(
  54.                     mysql_query(
  55.                         "SELECT Username,Email FROM glinks_Users WHERE user_id_fk = '".mysql_real_escape_string($person_id, $glinks_connection)."'",
  56.                         $glinks_connection
  57.                     )
  58.                 );
  59.  
  60.                 if (is_array($result2)) {
  61.                     return array(
  62.                         'userid' => $result2['Username'],
  63.                         'publicusername' => $result2['Username'],
  64.                         'email' => $result2['Email'],
  65.                         'level' => ($result2['Username']=='the_admin_user') ? QA_USER_LEVEL_ADMIN : QA_USER_LEVEL_BASIC
  66.                     );
  67.                 }
  68.  
  69.                 mysql_close($glinks_connection);
  70.             }
  71.  
  72.  
  73.         }
  74.  
  75.         return null;
  76.     }
  77.  
  78.  
  79.     function qa_get_user_email($userid)
  80.     {
  81.  
  82.     //  Until you edit this function, always return null
  83.  
  84.         return null;
  85.  
  86.     }
  87.  
  88.  
  89.     function qa_get_userids_from_public($publicusernames)
  90.     {
  91.  
  92.  
  93.         return null;
  94.  
  95.     }
  96.  
  97.  
  98.     function qa_get_public_from_userids($userids)
  99.     {
  100.  
  101.     //  Until you edit this function, always return null
  102.  
  103.         $useridtopublic=array();
  104.  
  105.         foreach ($userids as $userid) {
  106.             $useridtopublic[$userid]=$userid;
  107.         }
  108.  
  109.         return $useridtopublic;
  110.  
  111.         return null;
  112.  
  113.     }
  114.  
  115.  
  116.     function qa_get_logged_in_user_html($logged_in_user, $relative_url_prefix)
  117.     {
  118.  
  119.         $publicusername=$logged_in_user['publicusername'];
  120.  
  121.         return '<a href="'.qa_path_html('user/'.$publicusername).'" class="qa-user-link">'.htmlspecialchars($publicusername).'</a>';
  122.  
  123.     }
  124.  
  125.  
  126.     function qa_get_users_html($userids, $should_include_link, $relative_url_prefix)
  127.     {
  128.  
  129.     //  By default, show the public username linked to the Q2A profile page for each user
  130.  
  131.         $useridtopublic=qa_get_public_from_userids($userids);
  132.  
  133.         $usershtml=array();
  134.  
  135.         foreach ($userids as $userid) {
  136.             $publicusername=$useridtopublic[$userid];
  137.  
  138.             $usershtml[$userid]=htmlspecialchars($publicusername);
  139.  
  140.             if ($should_include_link)
  141.                 $usershtml[$userid]='<a href="'.qa_path_html('user/'.$publicusername).'" class="qa-user-link">'.$usershtml[$userid].'</a>';
  142.         }
  143.  
  144.         return $usershtml;
  145.  
  146.     }
  147.  
  148.  
  149.     function qa_avatar_html_from_userid($userid, $size, $padding)
  150.  
  151.     {
  152.         return null; // show no avatars by default
  153.  
  154.     }
  155.  
  156.  
  157.     function qa_user_report_action($userid, $action)
  158.     {
  159.         // do nothing by default
  160.     }
  161.  
  162.  
  163. /*
  164.     Omit PHP closing tag to help avoid accidental output
  165. */
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement