Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.95 KB | None | 0 0
  1. <?php
  2.  
  3.     if ( !defined('SQL_INCLUDED') ) {
  4.         die('This file does not have its required defined scripts. Exiting.');
  5.     }
  6.  
  7.     // $logged_in info
  8.     if ( !$logged_in ) {
  9.         return;
  10.     }
  11.  
  12.     // Handle the setting of default values
  13.     $get_preferences = $local_conn->query('
  14.         SELECT
  15.             `pref_name`, `pref_value`
  16.         FROM
  17.             `user_prefs`
  18.         WHERE
  19.             `userid` = "' . $session_info['userid'] . '"
  20.     ');
  21.  
  22.     $__PREF_LIST = array();
  23.     if ( $local_conn->num_rows($get_preferences) ) {
  24.         while ( $r = $local_conn->fetch_assoc($get_preferences) ) {
  25.             array_push($__PREF_LIST, $r);
  26.         }
  27.     }
  28.  
  29.     $get_preference_value = function($key, $list) {
  30.         $value = null;
  31.  
  32.         if ( !is_array($list) || count($list) == 0 ) {
  33.             return false;
  34.         }
  35.  
  36.         for ( $i = 0; $i < count($list); $i += 1 ) {
  37.             if ( $list[$i]['pref_name'] == $key ) {
  38.                 $value = $list[$i]['pref_value'];
  39.                 break;
  40.             }
  41.         }
  42.  
  43.         return isset($value) ? $value : false;
  44.     };
  45.  
  46.     unset($r, $get_preferences);
  47.  
  48. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement