member
[ class tree: member ] [ index: member ] [ all elements ]

Source for file member.inc.php

Documentation is available at member.inc.php

  1. <?php
  2.     /**
  3.      * @author            Matthias Reuter ($LastChangedBy: matthias $)
  4.      * @version            $LastChangedDate: 2009-08-26 19:19:41 +0200 (Mi, 26 Aug 2009) $
  5.      * @package            member
  6.      * @copyright        2007-2010 IPBWI development team
  7.      * @link            http://ipbwi.com/examples/member.php
  8.      * @since            2.0
  9.      * @license            http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License
  10.      */
  11.     class ipbwi_member extends ipbwi {
  12.         private $ipbwi            null;
  13.         private $loggedIn        null;
  14.         public    $myInfo            = null;
  15.         /**
  16.          * @desc            Loads and checks different vars when class is initiating
  17.          * @author            Matthias Reuter
  18.          * @since            2.0
  19.          * @ignore
  20.          */
  21.         public function __construct($ipbwi){
  22.             // loads common classes
  23.             $this->ipbwi $ipbwi;
  24.  
  25.             // checks if the current user is logged in
  26.             if($this->ipbwi->ips_wrapper->loggedIn == 0){
  27.                 $this->loggedIn false;
  28.             }else{
  29.                 $this->loggedIn true;
  30.             }
  31.             
  32.             $this->myInfo = $this->ipbwi->ips_wrapper->myInfo();
  33.         }
  34.         /**
  35.          * @desc            Returns whether a member can access the board's Admin CP.
  36.          * @param    int        $userID User ID. If $userID is ommited, the last known member id is used.
  37.          * @return    bool    Whether currently logged in member can access ACP
  38.          * @author            Matthias Reuter
  39.          * @sample
  40.          *  <code>
  41.          *  $ipbwi->member->isAdmin(5);
  42.          *  </code>
  43.          * @since            2.0
  44.          */
  45.         public function isAdmin($userID=false){
  46.             return $this->ipbwi->permissions->has('g_access_cp',$userID);
  47.         }
  48.         /**
  49.          * @desc            Returns whether a member is a super moderator.
  50.          * @param    int        $userID User ID. If $userID is ommited, the last known member id is used.
  51.          * @return    bool    Whether currently logged in member is a Super Moderator
  52.          * @author            Matthias Reuter
  53.          * @sample
  54.          *  <code>
  55.          *  $ipbwi->member->isSuperMod(5);
  56.          *  </code>
  57.          * @since            2.0
  58.          */
  59.         public function isSuperMod($userID=false){
  60.             return $this->ipbwi->permissions->has('g_is_supmod',$userID);
  61.         }
  62.         /**
  63.          * @desc            Returns whether a member is logged in.
  64.          * @param    int        $userID User ID. If $userID is ommited, the last known member id is used.
  65.          * @return    bool    Whether currently logged in member is a Super Moderator
  66.          * @author            Matthias Reuter
  67.          * @sample
  68.          *  <code>
  69.          *  $ipbwi->member->isLoggedIn(5);
  70.          *  </code>
  71.          * @since            2.0
  72.          */
  73.         public function isLoggedIn($userID=false){
  74.             if($userID){
  75.                 if(in_array($userID,$this->listOnlineMembers())){
  76.                     return true;
  77.                 }else{
  78.                     return false;
  79.                 }
  80.             }else{
  81.                 return $this->loggedIn;
  82.             }
  83.         }
  84.         /**
  85.          * @desc            Grabs detailed information of a member.
  86.          * @param    int        $userID User ID. If $userID is ommited, the last known member id is used.
  87.          * @return    array    Member Information, or false on failure
  88.          * @author            Matthias Reuter
  89.          * @sample
  90.          *  <code>
  91.          *  $ipbwi->member->info(5);
  92.          *  </code>
  93.          * @since            2.0
  94.          */
  95.         public function info($userID false){
  96.             if(!$userID){
  97.                 if($this->isLoggedIn()){
  98.                     // No UID? Return current user info
  99.                     $userID $this->myInfo['member_id'];
  100.                 }else{
  101.                     // Return guest group info
  102.                     $sql $this->ipbwi->ips_wrapper->DB->query('SELECT * FROM '.$this->ipbwi->board['sql_tbl_prefix'].'groups WHERE g_id="2"');
  103.                     if($this->ipbwi->ips_wrapper->DB->getTotalRows($sql== 0){
  104.                         return false;
  105.                     }else{
  106.                         $info $this->ipbwi->ips_wrapper->DB->fetch($sql);
  107.                         
  108.                         $this->ipbwi->ips_wrapper->parser->parse_smilies            1;
  109.                         $this->ipbwi->ips_wrapper->parser->parse_html                0;
  110.                         $this->ipbwi->ips_wrapper->parser->parse_nl2br                1;
  111.                         $this->ipbwi->ips_wrapper->parser->parse_bbcode                1;
  112.                         $this->ipbwi->ips_wrapper->parser->parsing_section            'topics';
  113.                         
  114.                         $allowedRichText array('signature''pp_about_me');
  115.                         
  116.                         foreach($allowedRichText as $allowedRichText_field){
  117.                             if(isset($info[$allowedRichText_field])){
  118.                                 $info[$allowedRichText_field]    $this->ipbwi->ips_wrapper->parser->preDisplayParse($info[$allowedRichText_field]);
  119.                                 $info[$allowedRichText_field]    $this->ipbwi->makeSafe($info[$allowedRichText_field]);
  120.                             }
  121.                         }
  122.                         
  123.                         $this->ipbwi->cache->save('memberInfo'$userID$info);
  124.                         return $info;
  125.                     }
  126.                 }
  127.             }
  128.             // Check for cache - if exists don't bother getting it again
  129.             if($cache $this->ipbwi->cache->get('memberInfo'$userID)){
  130.                 return $cache;
  131.             }else{
  132.                 // Return user info if UID given
  133.                 $info IPSMember::load($userID);
  134.                 $this->ipbwi->cache->save('memberInfo'$userID$info);
  135.                 return $info;
  136.             }
  137.         }
  138.         /**
  139.          * @desc            Returns the HTML code to show a member's avatar.
  140.          * @param    int        $userID User ID. If $userID is ommited, the last known member id is used.
  141.          * @return    string    HTML Code for member's avatar, or false on failure
  142.          * @author            Matthias Reuter
  143.          * @sample
  144.          *  <code>
  145.          *  $ipbwi->member->avatar(5);
  146.          *  </code>
  147.          * @since            2.0
  148.          */
  149.         public function avatar($userID false){
  150.             // No Member ID specified? Go for the current users UID.
  151.             $member $this->info($userID);
  152.             $avatar IPSMember::buildAvatar($member);
  153.             $avatar str_replace('http://www.gravatar.com/avatar/f4b24f6f1dad5d1dfb39dcb281897203?d=http%3A%2F%2Froot.pc-intern.com%2Fdevelopment%2Fprojects.pc-intern.com%2Fpublic%2Fstyle_avatars%2Fblank_avatar.gif','http://root.pc-intern.com/development/projects.pc-intern.com/public/style_images/master/profile/default_thumb.png',$avatar);
  154.             return $avatar;
  155.         }
  156.         /**
  157.          * @desc            Returns HTML code for member's photo.
  158.          * @param    int        $userID User ID. If $userID is ommited, the last known member id is used.
  159.          * @param    bool    $thumb true to activate thumbnail, otherwise false (default)
  160.          * @return    string    HTML code for member photo
  161.          * @author            Matthias Reuter
  162.          * @sample
  163.          *  <code>
  164.          *  $ipbwi->member->photo(5,true);
  165.          *  </code>
  166.          * @since            2.0
  167.          */
  168.         public function photo($userID false$thumb false){
  169.             $member    $this->info($userID);
  170.             $photo    IPSMember::buildProfilePhoto($member);
  171.             if($photo['pp_main_photo']){
  172.                 if($thumb === true && $photo['pp_thumb_photo']){
  173.                     $photo '<a href="'.$photo['pp_main_photo'].'"><img src="'.$photo['pp_thumb_photo'].'" width="'.$photo['pp_thumb_width'].'" height="'.$photo['pp_thumb_height'].'" alt="'.$this->id2displayname($userID).'" /></a>';
  174.                 }else{
  175.                     $photo '<img src="'.$photo['pp_main_photo'].'" width="'.$photo['pp_main_width'].'" height="'.$photo['pp_main_height'].'" alt="'.$this->id2displayname($userID).'" />';
  176.                 }
  177.                 return $photo;
  178.             }else{
  179.                 return false;
  180.             }
  181.         }
  182.         /**
  183.          * @desc            Gets the Member ID associated with a Member Name.
  184.          * @param    mixed    $names If you pass an array with names, the function also returns an array with each name beeing the key and the ID as its value. If a member name could not be found, the value will be set to false.
  185.          * @return    mixed    Single Member ID, assoc. array with id/name pairs, or false if the name(s) could not be found
  186.          * @author            Matthias Reuter
  187.          * @sample
  188.          *  <code>
  189.          *  $ipbwi->member->name2id('name');
  190.          *  $ipbwi->member->name2id(array('name1','name2'));
  191.          *  </code>
  192.          * @since            2.0
  193.          */
  194.         public function name2id($names){
  195.             if(is_array($names)){
  196.                 foreach($names as $i => $j){
  197.                     $sql $this->ipbwi->ips_wrapper->DB->query('SELECT member_id FROM '.$this->ipbwi->board['sql_tbl_prefix'].'members WHERE LOWER(name)="'.$this->ipbwi->makeSafe(strtolower(trim($names))).'"');
  198.                     if($row $this->ipbwi->ips_wrapper->DB->fetch($sql)){
  199.                         $ids[$i$row['member_id'];
  200.                     }else{
  201.                         $ids[$ifalse;
  202.                     }
  203.                 }
  204.                 return $ids;
  205.             }else{
  206.                 $sql $this->ipbwi->ips_wrapper->DB->query('SELECT member_id FROM '.$this->ipbwi->board['sql_tbl_prefix'].'members WHERE LOWER(name)="'.$this->ipbwi->makeSafe(strtolower(trim($names))).'"');
  207.                 if($row $this->ipbwi->ips_wrapper->DB->fetch($sql)){
  208.                     return $row['member_id'];
  209.                 }else{
  210.                     return false;
  211.                 }
  212.             }
  213.         }
  214.         /**
  215.          * @desc            Gets the Member Name associated with a Member ID.
  216.          * @param    mixed    $userIDs Member Ids. If you pass an array with IDs, the function also returns an array with each ID beeing the key and the member name as its value. If a member ID could not be found, the value will be set to false.
  217.          * @return    mixed    Single member name, assoc. array with name/id pairs, or false if the ID(s) could not be found
  218.          * @author            Matthias Reuter
  219.          * @sample
  220.          *  <code>
  221.          *  $ipbwi->member->id2name(55);
  222.          *  $ipbwi->member->id2name(array(55,22,77));
  223.          *  </code>
  224.          * @since            2.0
  225.          */
  226.         public function id2name($userIDs){
  227.             if(is_array($userIDs)){
  228.                 foreach($userIDs as $i => $j){
  229.                     $sql $this->ipbwi->ips_wrapper->DB->query('SELECT name FROM '.$this->ipbwi->board['sql_tbl_prefix'].'members WHERE member_id="'.$this->ipbwi->makeSafe(trim($userIDs)).'"');
  230.                     if($row $this->ipbwi->ips_wrapper->DB->fetch($sql)){
  231.                         $names[$i$row['name'];
  232.                     }else{
  233.                         $names[$ifalse;
  234.                     }
  235.                 }
  236.                 return $ids;
  237.             }else{
  238.                 $sql $this->ipbwi->ips_wrapper->DB->query('SELECT name FROM '.$this->ipbwi->board['sql_tbl_prefix'].'members WHERE member_id="'.$this->ipbwi->makeSafe(trim($userIDs)).'"');
  239.                 if($row $this->ipbwi->ips_wrapper->DB->fetch($sql)){
  240.                     return $row['name'];
  241.                 }else{
  242.                     return false;
  243.                 }
  244.             }
  245.         }
  246.         /**
  247.          * @desc            Gets the Member ID associated with a Display Name.
  248.          * @param    mixed    $names Member Names. If you pass an array with names, the function also returns an array with each name beeing the key and the ID as its value. If a member name could not be found, the value will be set to false.
  249.          * @return    mixed    Single Member ID, assoc. array with id/name pairs, or false if the name(s) could not be found
  250.          * @author            Matthias Reuter
  251.          * @sample
  252.          *  <code>
  253.          *  $ipbwi->member->displayname2id('displayname');
  254.          *  $ipbwi->member->displayname2id(array('displayname2','displayname2','displayname3'));
  255.          *  </code>
  256.          * @since            2.0
  257.          */ 
  258.         public function displayname2id($names){
  259.             if(is_array($names)){
  260.                 foreach($names as $i => $j){
  261.                     $sql $this->ipbwi->ips_wrapper->DB->query('SELECT member_id FROM '.$this->ipbwi->board['sql_tbl_prefix'].'members WHERE LOWER(members_display_name)="'.$this->ipbwi->makeSafe(strtolower(trim($j))).'"');
  262.                     if($row $this->ipbwi->ips_wrapper->DB->fetch($sql)){
  263.                         $ids[$i$row['member_id'];
  264.                     }else{
  265.                         $ids[$ifalse;
  266.                     }
  267.                 }
  268.                 return $ids;
  269.             }else{
  270.                 $sql $this->ipbwi->ips_wrapper->DB->query('SELECT member_id FROM '.$this->ipbwi->board['sql_tbl_prefix'].'members WHERE LOWER(members_display_name)="'.$this->ipbwi->makeSafe(strtolower(trim($names))).'"');
  271.                 if($row $this->ipbwi->ips_wrapper->DB->fetch($sql)){
  272.                     return $row['member_id'];
  273.                 }else{
  274.                     return false;
  275.                 }
  276.             }
  277.         }
  278.         /**
  279.          * @desc            Gets the Member Display Name associated with a Member ID.
  280.          * @param    mixed    $userIDs Member IDs. If you pass an array with IDs, the function also returns an array with each ID beeing the key and the member name as its value. If a member ID could not be found, the value will be set to false.
  281.          * @return    mixed    Single member name, assoc. array with name/id pairs, or false if the ID(s) could not be found
  282.          * @author            Matthias Reuter
  283.          * @sample
  284.          *  <code>
  285.          *  $ipbwi->member->id2displayname(55);
  286.          *  $ipbwi->member->id2displayname(55,77,99));
  287.          *  </code>
  288.          * @since            2.0
  289.          */
  290.         public function id2displayname($userIDs){
  291.             if(is_array($userIDs)){
  292.                 foreach($userIDs as $i => $j){
  293.                     $sql $this->ipbwi->ips_wrapper->DB->query('SELECT members_display_name FROM '.$this->ipbwi->board['sql_tbl_prefix'].'members WHERE member_id="'.$this->ipbwi->makeSafe(trim($userIDs)).'"');
  294.                     if($row $this->ipbwi->ips_wrapper->DB->fetch($sql)){
  295.                         $names[$i$row['members_display_name'];
  296.                     }else{
  297.                         $names[$ifalse;
  298.                     }
  299.                 }
  300.                 return $ids;
  301.             }else{
  302.                 $sql $this->ipbwi->ips_wrapper->DB->query('SELECT members_display_name FROM '.$this->ipbwi->board['sql_tbl_prefix'].'members WHERE member_id="'.$this->ipbwi->makeSafe(trim($userIDs)).'"');
  303.                 if($row $this->ipbwi->ips_wrapper->DB->fetch($sql)){
  304.                     return $row['members_display_name'];
  305.                 }else{
  306.                     return false;
  307.                 }
  308.             }
  309.         }
  310.         /**
  311.          * @desc            Gets the Member ID associated with a Member Email.
  312.          * @param    mixed    $emails Member Emails. If you pass an array with emails, the function also returns an array with each email beeing the key and the ID as its value. If a member email could not be found, the value will be set to false.
  313.          * @return    mixed    Single Member ID, assoc. array with id/email pairs, or false if the email(s) could not be found
  314.          * @author            Matthias Reuter
  315.          * @sample
  316.          *  <code>
  317.          *  $ipbwi->member->email2id('email');
  318.          *  $ipbwi->member->email2id(array('email1','email2','email3'));
  319.          *  </code>
  320.          * @since            2.0
  321.          */
  322.         public function email2id($emails){
  323.             if(is_array($emails)){
  324.                 foreach($emails as $i => $j){
  325.                     $sql $this->ipbwi->ips_wrapper->DB->query('SELECT member_id FROM '.$this->ipbwi->board['sql_tbl_prefix'].'members WHERE LOWER(email)="'.strtolower($j).'"');
  326.                     if($row $this->ipbwi->ips_wrapper->DB->fetch($sql)){
  327.                         $ids[$i$row['member_id'];
  328.                     }else{
  329.                         $ids[$ifalse;
  330.                     }
  331.                 }
  332.                 return $ids;
  333.             }else{
  334.                 $sql $this->ipbwi->ips_wrapper->DB->query('SELECT member_id FROM '.$this->ipbwi->board['sql_tbl_prefix'].'members WHERE LOWER(email)="'.strtolower($emails).'"');
  335.                 if($row $this->ipbwi->ips_wrapper->DB->fetch($sql)){
  336.                     return $row['member_id'];
  337.                 }else{
  338.                     return false;
  339.                 }
  340.             }
  341.         }
  342.         /**
  343.          * @desc            Creates a new account and returns the member ID for further processing.
  344.          * @param    string    $userName Username
  345.          * @param    string    $password In plain text. Will be encrypted with md5()
  346.          * @param    string    $email Mail
  347.          * @param    array    $customFields Optional values for the (existing) custom profile fields.
  348.          * @param    boolean    $validate possible values: user, admin, admin_user, default: board settings
  349.          * @param    string    $displayName Display name, default: false (username = displayname)
  350.          * @param    boolean    $allowAdminMail Whether to allow emails from admins, default: true
  351.          * @param    boolean    $allowMemberMail Whether to allow emails from other members, default: false
  352.          * @param    boolean    $captchaCheck Decide if you want to protect registrations through captcha check. You have to use methods of antispam-class if you have captcha check enabled. Possible values: none, default (GD based), recaptcha. standard settings: board settings
  353.          * @return    long    New Member ID or false on failure
  354.          * @author            Matthias Reuter
  355.          * @sample
  356.          *  <code>
  357.          *  $ipbwi->member->create('name', 'password', 'email@foo.com');
  358.          *  $ipbwi->member->create('name', 'password', 'email@foo.com', array('field_1' => 'content of field 1', 'field_2' => 'content of field 2'), true, 'displayname', true);
  359.          *  </code>
  360.          * @since            2.0
  361.          */
  362.         public function create($userName$password$email$customFields array()$validate false$displayName false$allowAdminMail true$allowMemberMail false$captchaCheck false){
  363.             $member                            $customFields;
  364.             $member['UserName']                $userName;
  365.             $member['PassWord']                $password;
  366.             $member['PassWord_Check']        $password;
  367.             $member['EmailAddress']            $email;
  368.             $member['EmailAddress_two']        $email;
  369.             $member['members_display_name']    $displayName $displayName $userName;
  370.             $member['allow_admin_mail']        $allowAdminMail;
  371.             $member['allow_member_mail']    $allowMemberMail;
  372.             if($validate !== false){
  373.                 $member['reg_auth_type']    $validate;
  374.             }else{
  375.                 $member['reg_auth_type']    $this->ipbwi->getBoardVar('reg_auth_type');
  376.             }
  377.             if($captchaCheck !== false){
  378.                 $member['bot_antispam_type'$captchaCheck;
  379.             }
  380.  
  381.             $this->ipbwi->ips_wrapper->register->create($member);
  382.  
  383.             if(isset($this->ipbwi->ips_wrapper->register->errors)){
  384.                 foreach($this->ipbwi->ips_wrapper->register->errors as $field => $error){
  385.                     if($error[0!= null){
  386.                         $field $this->ipbwi->getLibLang('reg_'.$field);
  387.                         $this->ipbwi->addSystemMessage('Error',$field.$error[0],'Located in file <strong>'.__FILE__.'</strong> at class <strong>'.__CLASS__.'</strong> in function <strong>'.__FUNCTION__.'</strong> on line #<strong>'.__LINE__.'</strong>');
  388.                     }elseif(is_array($error)){
  389.                         foreach($error as $text){
  390.                             $this->ipbwi->addSystemMessage('Error',$text,'Located in file <strong>'.__FILE__.'</strong> at class <strong>'.__CLASS__.'</strong> in function <strong>'.__FUNCTION__.'</strong> on line #<strong>'.__LINE__.'</strong>');
  391.                         }
  392.                     }else{
  393.                         $this->ipbwi->addSystemMessage('Error',$error,'Located in file <strong>'.__FILE__.'</strong> at class <strong>'.__CLASS__.'</strong> in function <strong>'.__FUNCTION__.'</strong> on line #<strong>'.__LINE__.'</strong>');
  394.                     }
  395.                 }
  396.                 return false;
  397.             }else{
  398.                 $this->myInfo = $this->info($this->email2id($member['EmailAddress']));
  399.                 return true;
  400.             }
  401.         }
  402.         /**
  403.          * @desc            Deletes a Member.
  404.          * @param    mixed    $userIDs Member(s) to be deleted. int for single member id, or array for a list of ids
  405.          * @param    string    $password Plaintext password of currently logged in member for more security
  406.          * @return    bool    true on success, false on failure
  407.          * @author            Matthias Reuter
  408.          * @sample
  409.          *  <code>
  410.          *  $ipbwi->member->delete(55);
  411.          *  $ipbwi->member->delete(array(55,22,77));
  412.          *  </code>
  413.          * @since            2.0
  414.          */
  415.          
  416.         public function delete($userIDs=false,$password=false){
  417.             $this->ipbwi->ips_wrapper->memberDelete($userIDs);
  418.         }
  419.         /**
  420.          * @desc            Grab a list of custom profile fields, and their properties.
  421.          * @return    array    custom profile fields and properties, otherwise false
  422.          * @author            Matthias Reuter
  423.          * @sample
  424.          *  <code>
  425.          *  $ipbwi->member->listCustomFields();
  426.          *  </code>
  427.          * @since            2.0
  428.          */
  429.         public function listCustomFields(){
  430.             // Check for cache...
  431.             if($cache $this->ipbwi->cache->get('listCustomFields'1)){
  432.                 return $cache;
  433.             }else{
  434.                 $sql $this->ipbwi->ips_wrapper->DB->query('SELECT * FROM '.$this->ipbwi->board['sql_tbl_prefix'].'pfields_data ORDER BY pf_id');
  435.                 if($this->ipbwi->ips_wrapper->DB->getTotalRows($sql== 0){
  436.                     return false;
  437.                 }else{
  438.                     while($info $this->ipbwi->ips_wrapper->DB->fetch($sql)){
  439.                         $fields['field_'.$info['pf_id']] $info;
  440.                     }
  441.                     $this->ipbwi->cache->save('listCustomFields'1$fields);
  442.                     return $fields;
  443.                 }
  444.             }
  445.         }
  446.         /**
  447.          * @desc            Update properties of a member's record.
  448.          * @param    array    $update Associative array with fieldnames and values to update
  449.          *  The following fields can be used in the $update array:
  450.          *  + members_display_name
  451.          *  + avatar_location
  452.          *  + avatar_type
  453.          *  + avatar_size
  454.          *  + aim_name
  455.          *  + icq_number
  456.          *  + location
  457.          *  + signature
  458.          *  + website
  459.          *  + yahoo
  460.          *  + interests
  461.          *  + msnname
  462.          *  + integ_msg
  463.          *  + title
  464.          *  + allow_admin_mails
  465.          *  + hide_email
  466.          *  + email_pm
  467.          *  + skin
  468.          *  + language
  469.          *  + view_sigs
  470.          *  + view_img
  471.          *  + view_avs
  472.          *  + view_pop
  473.          *  + bday_day
  474.          *  + bday_month
  475.          *  + bday_year
  476.          *  + dst_in_use
  477.          *  + email
  478.          *  + pp_member_id
  479.          *  + pp_profile_update
  480.          *  + pp_bio_content
  481.          *  + pp_last_visitors
  482.          *  + pp_comment_count
  483.          *  + pp_rating_hits
  484.          *  + pp_rating_value
  485.          *  + pp_rating_real
  486.          *  + pp_friend_count
  487.          *  + pp_main_photo
  488.          *  + pp_main_width
  489.          *  + pp_main_height
  490.          *  + pp_thumb_photo
  491.          *  + pp_thumb_width
  492.          *  + pp_thumb_height
  493.          *  + pp_gender
  494.          *  + pp_setting_notify_comments
  495.          *  + pp_setting_notify_friend
  496.          *  + pp_setting_moderate_comments
  497.          *  + pp_setting_moderate_friends
  498.          *  + pp_setting_count_friends
  499.          *  + pp_setting_count_comments
  500.          *  + pp_setting_count_visitors
  501.          *  + pp_profile_views
  502.          * @param    int        $userID The Member ID to update
  503.          * @param    int        $bypassPerms Default: false=use board permissions to allow update, true=bypass permissions
  504.          * @return    bool    true on success, otherwise false
  505.          * @author            Matthias Reuter
  506.          * @sample
  507.          *  <code>
  508.          *  $ipbwi->member->updateMember(array('website' => 'http://ipbwi.com', 'title' => 'mytitle'));
  509.          *  $ipbwi->member->updateMember(array('website' => 'http://ipbwi.com'), 55, true);
  510.          *  </code>
  511.          * @since            2.0
  512.          */
  513.         public function updateMember($update array()$userID false$bypassPerms false){
  514.             // Do we have a member to update or not?
  515.             if(!$userID){
  516.                 $userID $this->myInfo['member_id'];
  517.             }
  518.             $userID intval($userID);
  519.             // Check we are logged in and can update profiles
  520.             $info $this->info($userID);
  521.             if((!$this->isLoggedin(OR !$info['g_edit_profile']AND !$bypassPerms){
  522.                 $this->ipbwi->addSystemMessage('Error',$this->ipbwi->getLibLang('noPerms'),'Located in file <strong>'.__FILE__.'</strong> at class <strong>'.__CLASS__.'</strong> in function <strong>'.__FUNCTION__.'</strong> on line #<strong>'.__LINE__.'</strong>');
  523.                 return false;
  524.             }
  525.             if(isset($update['members_display_name'])){
  526.                 $update['members_l_display_name'$update['members_display_name'];
  527.             }
  528.             if(isset($update['icq_number']&& strlen($update['icq_number']9){
  529.                 $update['icq_number'false;
  530.             }
  531.             
  532.             // make richtext fine for db save
  533.             $this->ipbwi->ips_wrapper->parser->parse_bbcode        $row['use_ibc'];
  534.             $this->ipbwi->ips_wrapper->parser->strip_quotes        0;
  535.             $this->ipbwi->ips_wrapper->parser->parse_nl2br        0;
  536.             $this->ipbwi->ips_wrapper->parser->parse_html        0;
  537.             $this->ipbwi->ips_wrapper->parser->parse_smilies    1;
  538.             
  539.             // Array of allowed array keys in $update we can update
  540.             $allowed                array('members_display_name','members_l_display_name','title','allow_admin_mails','hide_email''email_pm''skin','language','view_sigs''view_img''view_avs''view_pop''bday_day''bday_month''bday_year''dst_in_use','email');
  541.             $ppAllowed                array('signature''avatar_location''avatar_type''avatar_size''pp_member_id''pp_profile_update''pp_about_me''pp_last_visitors''pp_comment_count''pp_rating_hits''pp_rating_value''pp_rating_real''pp_friend_count''pp_main_photo''pp_main_width''pp_main_height''pp_thumb_photo''pp_thumb_width''pp_thumb_height''pp_gender''pp_setting_notify_comments''pp_setting_notify_friend''pp_setting_moderate_comments''pp_setting_moderate_friends''pp_setting_count_friends''pp_setting_count_comments''pp_setting_count_visitors''pp_profile_views');
  542.             // Init
  543.             $ppSQLupdate            false;
  544.             $ppsqlInsert['fields']    false;
  545.             $ppsqlInsert['values']    false;
  546.             $sql                    false;
  547.             $meSQL                    false;
  548.             $ppSQL                    false;
  549.             // If we have something to update
  550.             if(count($update0){
  551.                 foreach($update as $i => $j){
  552.                     if(in_array($i$allowed)){
  553.                         // We can do this!!!!
  554.                         $update[$i$this->ipbwi->makeSafe($j);
  555.                         $cache_update[$i$j;
  556.                         if($sql){
  557.                             $sql .= ','.$i.'="'.$update[$i].'"';
  558.                         }else{
  559.                             $sql .= $i.'="'.$update[$i].'"';
  560.                         }
  561.                     }
  562.                     if(in_array($i$ppAllowed)){
  563.                         // We can do this!!!!
  564.                         $ppUpdate[$i$this->ipbwi->makeSafe($j);
  565.                         $cache_ppUpdate[$i$j;
  566.                         if(isset($ppSQLupdate&& $ppSQLupdate != ''){
  567.                             $ppSQLupdate .= ','.$i.'="'.$ppUpdate[$i].'"';
  568.                         }else{
  569.                             $ppSQLupdate $i.'="'.$ppUpdate[$i].'"';
  570.                         }
  571.                         $ppsqlInsert['fields'.= ','.$i;
  572.                         $ppsqlInsert['values'.= ',"'.$ppUpdate[$i].'"';
  573.                     }
  574.                 }
  575.                 // Check we have something to do again
  576.                 if($sql || $meSQL || $ppSQL){
  577.                     // Update in Database
  578.                     if($sql){
  579.                         $query 'UPDATE '.$this->ipbwi->board['sql_tbl_prefix'].'members SET '.$sql.' WHERE member_id="'.$userID.'"';
  580.                         $this->ipbwi->ips_wrapper->DB->query($query);
  581.                     }
  582.                     if($meSQL){
  583.                         $query 'UPDATE '.$this->ipbwi->board['sql_tbl_prefix'].'members SET '.$meSQL.' WHERE member_id="'.$userID.'"';
  584.                         $this->ipbwi->ips_wrapper->DB->query($query);
  585.                     }
  586.                     if($ppsqlInsert && $ppSQLupdate){
  587.                         $query 'INSERT INTO '.$this->ipbwi->board['sql_tbl_prefix'].'profile_portal (pp_member_id'.$ppsqlInsert['fields'].') VALUES("'.$userID.'"'.$ppsqlInsert['values'].') ON DUPLICATE KEY UPDATE '.$ppSQLupdate;
  588.                         $this->ipbwi->ips_wrapper->DB->query($query);
  589.                     }
  590.                     // Update in get_advinfo() cache.
  591.                     if(isset($update)) $info array_merge($info$cache_update);
  592.                     if(isset($ppUpdate)) $info array_merge($info$cache_ppUpdate);
  593.                     $this->ipbwi->cache->save('memberInfo'$userID$info);
  594.                     return true;
  595.                 }
  596.             }
  597.             return false;
  598.         }
  599.         /**
  600.          * @desc            Changes a user's password.
  601.          * @param    string    $newPass The new Member's password
  602.          * @param    string    $userID The Member's ID. If not set, the currently logged in member will be updated.
  603.          * @param    string    $currentPass Current password check for more security
  604.          * @return    bool    true on success, otherwise false
  605.          * @author            Matthias Reuter
  606.          * @sample
  607.          *  <code>
  608.          *  $ipbwi->member->updatePassword('new password');
  609.          *  $ipbwi->member->updatePassword('new password',55,'old password');
  610.          *  </code>
  611.          * @since            2.0
  612.          */
  613.         public function updatePassword($newPass$userID false$currentPass false){
  614.             // Do we have a member to update or not?
  615.             if($userID){
  616.                 $userID intval($userID);
  617.              }else{
  618.                 $userID $this->myInfo['member_id'];
  619.             }
  620.             // Check we are logged in
  621.             $info $this->info($userID);
  622.             if(!$this->isLoggedIn(&& empty($userID)){
  623.                 $this->ipbwi->addSystemMessage('Error',$this->ipbwi->getLibLang('noPerms'),'Located in file <strong>'.__FILE__.'</strong> at class <strong>'.__CLASS__.'</strong> in function <strong>'.__FUNCTION__.'</strong> on line #<strong>'.__LINE__.'</strong>');
  624.                 return false;
  625.             }
  626.             if(empty($newPassOR strlen($newPassOR strlen($newPass32){
  627.                 $this->ipbwi->addSystemMessage('Error',$this->ipbwi->getLibLang('accPass'),'Located in file <strong>'.__FILE__.'</strong> at class <strong>'.__CLASS__.'</strong> in function <strong>'.__FUNCTION__.'</strong> on line #<strong>'.__LINE__.'</strong>');
  628.                 return false;
  629.             }
  630.             // update password
  631.             if($this->ipbwi->ips_wrapper->changePW($newPass,$userID,$currentPass)){
  632.                 return true;
  633.             }else{
  634.                 return false;
  635.             }
  636.         }
  637.         /**
  638.          * @desc            Updates the value of a custom profile field.
  639.          * @param    int        $ID Custom Profile field's ID
  640.          * @param    string    $newValue New Value for the field
  641.          * @param    bool    $bypassPerms Default: false=use board permissions to allow update, true=bypass permissions
  642.          * @param    bool    $memberID Member ID where the custom profile field should be updated. If no ID is delivered, the currently logged in user will be updated.
  643.          * @return    bool    true on success, otherwise false
  644.          * @author            Matthias Reuter (make it possible to update other member custom pfields) <public@pc-intern.com> http://pc-intern.com | http://straightvisions.com
  645.          * @sample
  646.          *  <code>
  647.          *  $ipbwi->member->updateCustomField(2,'new value);
  648.          *  $ipbwi->member->updateCustomField(1,'new value,true,55);
  649.          *  </code>
  650.          * @since            2.0
  651.          */
  652.         public function updateCustomField($ID$newValue$bypassPerms false$memberID false){
  653.             if(empty($memberID)){
  654.                 $memberID $this->ipbwi->member->myInfo['member_id'];
  655.             }
  656.             $fieldinfo $this->listCustomFields($memberID);
  657.             if($info $fieldinfo['field_' $ID]){
  658.                 if($info['pf_member_edit'OR $bypassPerms){
  659.                     if($info['pf_type'== 'drop'){
  660.                         $allowed array();
  661.                         $i explode ('|'$info['pf_content']);
  662.                         foreach($i as $j){
  663.                             $k explode ('='$j);
  664.                             $allowed[$k['0'];
  665.                         }
  666.                         if(!in_array($newValue$allowed)){
  667.                             $this->ipbwi->addSystemMessage('Error',$this->ipbwi->getLibLang('cfInvalidValue'),'Located in file <strong>'.__FILE__.'</strong> at class <strong>'.__CLASS__.'</strong> in function <strong>'.__FUNCTION__.'</strong> on line #<strong>'.__LINE__.'</strong>');
  668.                             return false;
  669.                         }
  670.                     }
  671.                     if($info['pf_not_null'AND !$newValue){
  672.                         $this->ipbwi->addSystemMessage('Error',$this->ipbwi->getLibLang('cfMustFillIn'),'Located in file <strong>'.__FILE__.'</strong> at class <strong>'.__CLASS__.'</strong> in function <strong>'.__FUNCTION__.'</strong> on line #<strong>'.__LINE__.'</strong>');
  673.                         return false;
  674.                     }
  675.                     $this->ipbwi->ips_wrapper->DB->query('UPDATE '.$this->ipbwi->board['sql_tbl_prefix'].'pfields_content SET field_'.$ID.'="'.$newValue.'" WHERE member_id="'.$memberID.'"');
  676.                     return true;
  677.                 }else{
  678.                     $this->ipbwi->addSystemMessage('Error',sprintf($this->ipbwi->getLibLang('cfCantEdit')$ID),'Located in file <strong>'.__FILE__.'</strong> at class <strong>'.__CLASS__.'</strong> in function <strong>'.__FUNCTION__.'</strong> on line #<strong>'.__LINE__.'</strong>');
  679.                     return false;
  680.                 }
  681.             }else{
  682.                 $this->ipbwi->addSystemMessage('Error',sprintf($this->ipbwi->getLibLang('cfNotExist')$ID),'Located in file <strong>'.__FILE__.'</strong> at class <strong>'.__CLASS__.'</strong> in function <strong>'.__FUNCTION__.'</strong> on line #<strong>'.__LINE__.'</strong>');
  683.                 return false;
  684.             }
  685.         }
  686.         /**
  687.          * @desc            Update the current member's signature
  688.          * @param    string    $newSig New signature text. HTML allowed as per board settings.
  689.          * @return    bool    true on success, otherwise false
  690.          * @author            Matthias Reuter
  691.          * @sample
  692.          *  <code>
  693.          *  $ipbwi->member->updateSig('[b]my sig[/b]');
  694.          *  </code>
  695.          * @since            2.0
  696.          */
  697.         public function updateSig($newSig){
  698.             if(!$this->isLoggedIn()){
  699.                 $this->ipbwi->addSystemMessage('Error',$this->ipbwi->getLibLang('membersOnly'),'Located in file <strong>'.__FILE__.'</strong> at class <strong>'.__CLASS__.'</strong> in function <strong>'.__FUNCTION__.'</strong> on line #<strong>'.__LINE__.'</strong>');
  700.                 return false;
  701.             }
  702.             if(strlen($newSig$this->ipbwi->ips_wrapper->settings['max_sig_length']){
  703.                 $this->ipbwi->addSystemMessage('Error',$this->ipbwi->getLibLang('sigTooLong'),'Located in file <strong>'.__FILE__.'</strong> at class <strong>'.__CLASS__.'</strong> in function <strong>'.__FUNCTION__.'</strong> on line #<strong>'.__LINE__.'</strong>');
  704.                 return false;
  705.             }
  706.             if($this->ipbwi->ips_wrapper->settings['sig_allow_ibc']){
  707.                 $this->ipbwi->ips_wrapper->parser->parse_html        $this->ipbwi->ips_wrapper->settings['sig_allow_html'];
  708.                 $this->ipbwi->ips_wrapper->parser->parse_bbcode        $this->ipbwi->ips_wrapper->settings['sig_allow_ibc'];
  709.                 $this->ipbwi->ips_wrapper->parser->strip_quotes        1;
  710.                 $this->ipbwi->ips_wrapper->parser->parse_nl2br        1;
  711.                 $newSig $this->ipbwi->ips_wrapper->parser->preDbParse(stripslashes($newSig));
  712.             }
  713.             $this->ipbwi->ips_wrapper->DB->query('UPDATE '.$this->ipbwi->board['sql_tbl_prefix'].'profile_portal SET signature="'.$this->ipbwi->makeSafe($newSig).'" WHERE pp_member_id="'.$this->ipbwi->member->myInfo['member_id'].'"');
  714.             return true;
  715.         }
  716.         /**
  717.          * @desc            Update current member's avatar.
  718.          * @param    string    Name of the input upload field which contains avatar file
  719.          * @return    bool    true on success, otherwise false
  720.          * @author            Matthias Reuter
  721.          * @sample
  722.          *  <code>
  723.          *  $ipbwi->member->updateAvatar(); // use standard upload field name ('avatar_new')
  724.          *  $ipbwi->member->updateAvatar('input_field_name'); // set upload field name
  725.          *  $ipbwi->member->updateAvatar(false,true); // delete the avatar
  726.          *  </code>
  727.          * @since            2.01
  728.          */
  729.         public function updateAvatar($fieldName='avatar_new',$deleteAvatar=false){
  730.             if(!$this->isLoggedIn(&& $this->ipbwi->getBoardVar('avatars_on'!= 1){
  731.                 $this->ipbwi->addSystemMessage('Error',$this->ipbwi->getLibLang('membersOnly'),'Located in file <strong>'.__FILE__.'</strong> at class <strong>'.__CLASS__.'</strong> in function <strong>'.__FUNCTION__.'</strong> on line #<strong>'.__LINE__.'</strong>');
  732.                 return false;
  733.             }
  734.             $member $this->info();
  735.             // Remove Photo
  736.             if($deleteAvatar != false){
  737.                 $location explode(':',$member['avatar_location']);
  738.                 if($this->ipbwi->member->updateMember(array('avatar_type' => '''avatar_location' => '''avatar_size' => ''))){
  739.                     if($location[0== 'upload'){
  740.                         unlink($this->ipbwi->getBoardVar('upload_dir').$location[1]);
  741.                     }
  742.                     $this->ipbwi->addSystemMessage('Success'$this->ipbwi->getLibLang('avatarSuccess')'Located in file <strong>'.__FILE__.'</strong> at class <strong>'.__CLASS__.'</strong> in function <strong>'.__FUNCTION__.'</strong> on line #<strong>'.__LINE__.'</strong>');
  743.                     return true;
  744.                 }else{
  745.                     $this->ipbwi->addSystemMessage('Error'$this->ipbwi->getLibLang('avatarError')'Located in file <strong>'.__FILE__.'</strong> at class <strong>'.__CLASS__.'</strong> in function <strong>'.__FUNCTION__.'</strong> on line #<strong>'.__LINE__.'</strong>');
  746.                     return false;
  747.                 }
  748.             }elseif(isset($_FILES[$fieldName]['size']&& $_FILES[$fieldName]['size'&& ($_FILES[$fieldName]['size'<= ($this->ipbwi->getBoardVar('avup_size_max')*1024)) && $deleteAvatar == false){
  749.                 /*
  750.                  * @todo implement check of [avatar_ext] => gif,jpg,jpeg,png
  751.                  */
  752.                 $file_ext strtolower(substr($_FILES[$fieldName]['name'],strrpos($_FILES[$fieldName]['name'],'.')))// exclude file extension of the name
  753.                 $avatarname 'av-'.$member['id'].$file_ext// define avatarname
  754.                 $target_location $this->ipbwi->getBoardVar('upload_dir').$avatarname// define target url
  755.                 list($width$height$type$attrgetimagesize($_FILES[$fieldName]['tmp_name'])// get avatar proberties
  756.                 $avatar_dims explode('x',$this->ipbwi->getBoardVar('avatar_dims'));
  757.                 if($width <= $avatar_dims[0&& $height <= $avatar_dims[1]){
  758.                     if(move_uploaded_file($_FILES[$fieldName]['tmp_name'],$target_location))// move uploaded avatar to target
  759.                         $avatar_img_size $width.'x'.$height// merge avatarsize to IPB compatible format
  760.                         if($this->ipbwi->member->updateMember(array('avatar_type' => 'upload''avatar_location' => 'upload:'.$avatarname'avatar_size' => $avatar_img_size))){
  761.                             $this->ipbwi->addSystemMessage('Success'$this->ipbwi->getLibLang('avatarSuccess')'Located in file <strong>'.__FILE__.'</strong> at class <strong>'.__CLASS__.'</strong> in function <strong>'.__FUNCTION__.'</strong> on line #<strong>'.__LINE__.'</strong>');
  762.                             return true;
  763.                         }else{
  764.                             $this->ipbwi->addSystemMessage('Error'$this->ipbwi->getLibLang('avatarError')'Located in file <strong>'.__FILE__.'</strong> at class <strong>'.__CLASS__.'</strong> in function <strong>'.__FUNCTION__.'</strong> on line #<strong>'.__LINE__.'</strong>');
  765.                             return false;
  766.                         }
  767.                     }else{
  768.                         $this->ipbwi->addSystemMessage('Error'$this->ipbwi->getLibLang('avatarError')'Located in file <strong>'.__FILE__.'</strong> at class <strong>'.__CLASS__.'</strong> in function <strong>'.__FUNCTION__.'</strong> on line #<strong>'.__LINE__.'</strong>');
  769.                         return false;
  770.                     }
  771.                 }else{
  772.                     $this->ipbwi->addSystemMessage('Error'$this->ipbwi->getLibLang('avatarError')'Located in file <strong>'.__FILE__.'</strong> at class <strong>'.__CLASS__.'</strong> in function <strong>'.__FUNCTION__.'</strong> on line #<strong>'.__LINE__.'</strong>');
  773.                     return false;
  774.                 }
  775.             }else{
  776.                 return false;
  777.             }
  778.         }
  779.         /**
  780.          * @desc            Update current member's photograph.
  781.          * @return    bool    true on success, otherwise false
  782.          * @author            Matthias Reuter
  783.          * @sample
  784.          *  <code>
  785.          *  $ipbwi->member->updatePhoto(); // use standard upload field name ('upload_photo')
  786.          *  $ipbwi->member->updatePhoto('photo_new'); // set upload field name
  787.          *  $ipbwi->member->updatePhoto(false,true); // delete the photo
  788.          *  </code>
  789.          * @since            2.0
  790.          */
  791.         public function updatePhoto($fieldName=false,$deletePhoto=false){
  792.             if(!$this->isLoggedIn()){
  793.                 $this->ipbwi->addSystemMessage('Error',$this->ipbwi->getLibLang('membersOnly'),'Located in file <strong>'.__FILE__.'</strong> at class <strong>'.__CLASS__.'</strong> in function <strong>'.__FUNCTION__.'</strong> on line #<strong>'.__LINE__.'</strong>');
  794.                 return false;
  795.             }
  796.             
  797.             return false;
  798.             //$this->ipbwi->ips_wrapper->memberFunctions->uploadPhoto($this->lang->memberData['member_id']);
  799.             
  800. /*
  801.             // Remove Photo
  802.             if(isset($_POST['delete_photo']) || $deletePhoto != false){
  803.                 if(isset($_POST['delete_photo'])){
  804.                     $_POST['delete_photo'] = 1;
  805.                 }elseif(isset($deletePhoto)){
  806.                     $_POST['delete_photo'] = 1;
  807.                 }else{
  808.                     $_POST['delete_photo'] = 0;
  809.                 }
  810.                 $deleted = $this->ipbwi->ips_wrapper->usercp->lib_upload_photo();
  811.                 if($deleted['status'] == 'deleted'){
  812.                     return true;
  813.                 }else{
  814.                     return false;
  815.                 }
  816.             }elseif(isset($_POST['upload_photo']) || isset($fieldName)){
  817.                 $_POST['delete_photo'] = 0;
  818.                 // check first for POST data
  819.                 if(isset($fieldName) && isset($_FILES[$fieldName])){
  820.                     $_FILES['upload_photo'] = $_FILES[$fieldName];
  821.                 }elseif(empty($_FILES['upload_photo'])){
  822.                     return false;
  823.                 }
  824.                 // Get system vars
  825.                 $info = $this->info();
  826.                 $max = explode(':', $info['g_photo_max_vars']);
  827.                 // check if file is empty
  828.                 if(isset($_FILES['upload_photo']['size']) && $_FILES['upload_photo']['size'] > 0){
  829.                     // check if file is too big
  830.                     if($_FILES['upload_photo']['size'] < $max['0']*1024){
  831.                         // check if file has right extension
  832.                         $ext = strtolower(substr($_FILES['upload_photo']['name'],strrpos($_FILES['upload_photo']['name'],'.')));
  833.                         $allowed_ext = explode(',',$this->ipbwi->ips_wrapper->vars['photo_ext']);
  834.                         if(in_array(str_replace('.','',$ext),$allowed_ext)){
  835.                             $photo = $this->ipbwi->ips_wrapper->usercp->lib_upload_photo();
  836.                             if($photo && $this->ipbwi->ips_wrapper->DB->query('INSERT INTO '.$this->ipbwi->board['sql_tbl_prefix'].'profile_portal (pp_member_id,pp_main_photo,pp_main_width,pp_main_height,pp_thumb_photo,pp_thumb_width,pp_thumb_height) VALUES ("'.$this->ipbwi->member->myInfo['member_id'].'","'.$photo['final_location'].'","'.$photo['final_width'].'","'.$photo['final_height'].'","'.$photo['t_final_location'].'","'.$photo['t_final_width'].'","'.$photo['t_final_height'].'") ON DUPLICATE KEY UPDATE pp_main_photo="'.$photo['final_location'].'", pp_main_width="'.$photo['final_width'].'", pp_main_height="'.$photo['final_height'].'", pp_thumb_photo="'.$photo['t_final_location'].'", pp_thumb_width="'.$photo['t_final_width'].'", pp_thumb_height="'.$photo['t_final_height'].'"')){
  837.                             //if($photo && $this->ipbwi->ips_wrapper->DB->query('UPDATE '.$this->ipbwi->board['sql_tbl_prefix'].'profile_portal SET pp_main_photo="'.$photo['final_location'].'", pp_main_width="'.$photo['final_width'].'", pp_main_height="'.$photo['final_height'].'", pp_thumb_photo="'.$photo['t_final_location'].'", pp_thumb_width="'.$photo['t_final_width'].'", pp_thumb_height="'.$photo['t_final_height'].'" WHERE pp_member_id="'.$this->ipbwi->member->myInfo['member_id'].'"')){
  838.                                 return true;
  839.                             }else{
  840.                                 $this->ipbwi->addSystemMessage('Error','Upload failed: Database Update failed.','Located in file <strong>'.__FILE__.'</strong> at class <strong>'.__CLASS__.'</strong> in function <strong>'.__FUNCTION__.'</strong> on line #<strong>'.__LINE__.'</strong>');
  841.                                 return false;
  842.                             }
  843.                         }else{
  844.                             $this->ipbwi->addSystemMessage('Error','Upload failed: File-Extension is not allowed. Use one of the following: '.$this->ipbwi->ips_wrapper->vars['photo_ext'],'Located in file <strong>'.__FILE__.'</strong> at class <strong>'.__CLASS__.'</strong> in function <strong>'.__FUNCTION__.'</strong> on line #<strong>'.__LINE__.'</strong>');
  845.                             return false;
  846.                         }
  847.                     }else{
  848.                         $this->ipbwi->addSystemMessage('Error','Upload failed: File is too big. '.round($_FILES['upload_photo']['size']/1024,2).' KB uploaded and '.$max['0'].' KB allowed.','Located in file <strong>'.__FILE__.'</strong> at class <strong>'.__CLASS__.'</strong> in function <strong>'.__FUNCTION__.'</strong> on line #<strong>'.__LINE__.'</strong>');
  849.                         return false;
  850.                     }
  851.                 }else{
  852.                     //$this->ipbwi->addSystemMessage('Error','Upload failed: File has size of 0 Bytes','Located in file <strong>'.__FILE__.'</strong> at class <strong>'.__CLASS__.'</strong> in function <strong>'.__FUNCTION__.'</strong> on line #<strong>'.__LINE__.'</strong>');
  853.                     return false;
  854.                 }
  855.             }
  856. */
  857.         }
  858.         /**
  859.          * @desc            Gets the value of a custom profile field for a given member. If $userID is ommitted, the last known member id is used.
  860.          * @param    int        $fieldID Field ID (number) to retrieve.
  861.          * @param    int        $userID Member ID to read the custom profile field from.
  862.          * @return    string    Value of memberid's custom profile field field-id
  863.          * @author            Matthias Reuter
  864.          * @sample
  865.          *  <code>
  866.          *  $ipbwi->member->customFieldValue(3,55);
  867.          *  </code>
  868.          * @since            2.0
  869.          */
  870.         public function customFieldValue($fieldID$userID false){
  871.             $info $this->info($userID);
  872.             if(isset($info['field_' $fieldID]&& $info['field_' $fieldID]){
  873.                 $sql $this->ipbwi->ips_wrapper->DB->query('SELECT field_'.intval($fieldID).' FROM '.$this->ipbwi->board['sql_tbl_prefix'].'pfields_content WHERE member_id="'.$info['member_id'].'"');
  874.                 if($field_info $this->ipbwi->ips_wrapper->DB->fetch($sql)){
  875.                     return $info['field_'.$fieldID];
  876.                 }else{
  877.                     return false;
  878.                 }
  879.             }else{
  880.                 return false;
  881.             }
  882.         }
  883.         /**
  884.          * @desc            Get member's sig in BBCode
  885.          * @param    int        $userID Member ID to read the signature from.
  886.          * @return    string    Member Code in BBCode.
  887.          * @author            Matthias Reuter
  888.          * @sample
  889.          *  <code>
  890.          *  $ipbwi->member->rawSig(55);
  891.          *  </code>
  892.          * @since            2.0
  893.          */
  894.         public function rawSig($userID false){
  895.             if(!$userID){
  896.                 $userID $this->ipbwi->member->myInfo['member_id'];
  897.             }
  898.             if($info $this->info($userID)){
  899.                 $this->ipbwi->ips_wrapper->parser->parse_nl2br            1;
  900.                 $this->ipbwi->ips_wrapper->parser->parse_smilies        0;
  901.                 $this->ipbwi->ips_wrapper->parser->parsing_signature    1;
  902.                 $this->ipbwi->ips_wrapper->parser->parse_html            $this->ipbwi->ips_wrapper->vars['sig_allow_html'];
  903.                 $this->ipbwi->ips_wrapper->parser->parse_bbcode        $this->ipbwi->ips_wrapper->vars['sig_allow_ibc'];
  904.                 return $this->ipbwi->ips_wrapper->parser->pre_edit_parse($info['signature']);
  905.             }else{
  906.                 return false;
  907.             }
  908.         }
  909.         /**
  910.          * @desc            Returns the number of new posts of the currently logged in member since its last visit.
  911.          * @return    int        Number of posts since last visit
  912.          * @author            Matthias Reuter
  913.          * @sample
  914.          *  <code>
  915.          *  $ipbwi->member->numNewPosts();
  916.          *  </code>
  917.          * @since            2.0
  918.          */
  919.         public function numNewPosts(){
  920.             if(!$this->isLoggedIn()){
  921.                 $this->ipbwi->addSystemMessage('Error',$this->ipbwi->getLibLang('membersOnly'),'Located in file <strong>'.__FILE__.'</strong> at class <strong>'.__CLASS__.'</strong> in function <strong>'.__FUNCTION__.'</strong> on line #<strong>'.__LINE__.'</strong>');
  922.                 return false;
  923.             }
  924.             $sql $this->ipbwi->ips_wrapper->DB->query('SELECT COUNT(pid) AS new FROM '.$this->ipbwi->board['sql_tbl_prefix'].'posts WHERE post_date > "'.$this->myInfo['last_visit'].'"');
  925.             if($posts $this->ipbwi->ips_wrapper->DB->fetch($sql)){
  926.                 return $posts['new'];
  927.             }else{
  928.                 return false;
  929.             }
  930.         }
  931.         /**
  932.          * @desc            Returns the amount of pips a member has.
  933.          * @param    int        $ID Member's ID
  934.          * @return    int        Member Pips Count
  935.          * @author            Matthias Reuter
  936.          * @sample
  937.          *  <code>
  938.          *  $ipbwi->member->pips(55);
  939.          *  </code>
  940.          * @since            2.0
  941.          */
  942.         public function pips($ID false){
  943.             if($info $this->info($ID)){
  944.                 // Grab Pips
  945.                 $pips '0';
  946.                 $sql $this->ipbwi->ips_wrapper->DB->query('SELECT * FROM '.$this->ipbwi->board['sql_tbl_prefix'].'titles ORDER BY pips ASC');
  947.                 // Loop through pip numbers checking which is good
  948.                 while($row $this->ipbwi->ips_wrapper->DB->fetch($sql)){
  949.                     if(isset($info['posts']&& $row['posts'<= $info['posts']){
  950.                         $pips $row['pips'];
  951.                     }
  952.                 }
  953.                 return $pips;
  954.             }else{
  955.                 $this->ipbwi->addSystemMessage('Error',$this->ipbwi->getLibLang('badMemID'),'Located in file <strong>'.__FILE__.'</strong> at class <strong>'.__CLASS__.'</strong> in function <strong>'.__FUNCTION__.'</strong> on line #<strong>'.__LINE__.'</strong>');
  956.                 return false;
  957.             }
  958.         }
  959.         /**
  960.          * @desc            Returns a member's icon in HTML
  961.          * @param    int        $ID Member's ID
  962.          * @return    string    HTML for member's icon
  963.          * @author            Matthias Reuter
  964.          * @sample
  965.          *  <code>
  966.          *  $ipbwi->member->icon(55);
  967.          *  </code>
  968.          * @since            2.0
  969.          */
  970.         public function icon($userID false){
  971.             if($info $this->info($userID)){
  972.                 $skinInfo $this->ipbwi->skin->info($this->ipbwi->skin->id());
  973.                 if($info['g_icon']){
  974.                     // Use Group Icon
  975.                     if(substr($info['g_icon'],0,7== 'http://'){
  976.                         $info['g_icon''<img src="' $info['g_icon''" alt="'.$this->ipbwi->getLibLang('groupIcon').'" />';
  977.                         $skinInfo $this->ipbwi->skin->info($this->ipbwi->skin->id());
  978.                         $skinInfo['set_image_dir'$skinInfo['set_image_dir'$skinInfo['set_image_dir''1';
  979.                         $info['g_icon'str_replace("<#IMG_DIR#>",$skinInfo['set_image_dir'],$info['g_icon']);
  980.                         return $info['g_icon'];
  981.                     }else{
  982.                         $skinInfo['set_image_dir'$skinInfo['set_image_dir'$skinInfo['set_image_dir''1';
  983.                         $url '<img src="'.$this->ipbwi->getBoardVar('url').$info['g_icon'].'" alt="'.$this->ipbwi->getLibLang('groupIcon').'" />';
  984.                         $url str_replace('<#IMG_DIR#>',$skinInfo['set_image_dir'],$url);
  985.                         return $url;
  986.                     }
  987.                 }else{
  988.                     // Use Pips
  989.                     $pips $this->pips($userID);
  990.                     $pipsc '';
  991.                     while($pips 0){
  992.                         $skinInfo['set_image_dir'$skinInfo['set_image_dir'$skinInfo['set_image_dir''1';
  993.                         $pipsc .= '<img src="'.$this->ipbwi->getBoardVar('url').'style_images/'.$skinInfo['set_image_dir'].'/pip.gif" alt="*" />';
  994.                         $pips $pips '1';
  995.                     }
  996.                     return $pipsc;
  997.                 }
  998.             }else{
  999.                 $this->ipbwi->addSystemMessage('Error',$this->ipbwi->getLibLang('badMemID'),'Located in file <strong>'.__FILE__.'</strong> at class <strong>'.__CLASS__.'</strong> in function <strong>'.__FUNCTION__.'</strong> on line #<strong>'.__LINE__.'</strong>');
  1000.                 return false;
  1001.             }
  1002.         }
  1003.         /**
  1004.          * @desc            Login a user.
  1005.          * @param    string    $userName Member's Username
  1006.          * @param    string    $password Member's Password
  1007.          * @param    integer    $cookie Default: true=Use cookie to save login session, false=no cookies
  1008.          * @param    integer    $anon Default: false=Keep user anonymous on forums, true=keep anon.
  1009.          * @return    bool    true on success, otherwise false
  1010.          * @author            Matthias Reuter
  1011.          * @sample
  1012.          *  <code>
  1013.          *  $ipbwi->member->login(55,'password');
  1014.          *  $ipbwi->member->login(55,'password',true,false,true);
  1015.          *  </code>
  1016.          *  <b>Important</b><br>
  1017.          *  Cookie Settings of your Board<br>
  1018.          *  These Settings should be choosed to make a login on your website possible:<br>
  1019.          *  Cookie Domain: .your-domain.com<br>
  1020.          *  Cookie Name Prefix: {blank}<br>
  1021.          *  Cookie Path: {blank}<br>
  1022.          *  If you want to get the login work on subdomains, you have to turn off "Create a stronghold auto-log in cookie" in your Cookie-Settings of your Board.<br>
  1023.          *  This function sends http-headers, so you have to call it before any output is sent to the browser.
  1024.          * @since            2.0
  1025.          */
  1026.          
  1027.         public function login($user=false,$pw=false,$cookie=true,$anon=false){
  1028.             if(isset($user)){
  1029.                 $_POST['username'$user;
  1030.                 $this->ipbwi->ips_wrapper->request['username'$user;
  1031.             }
  1032.             if(isset($pw)){
  1033.                 $_POST['password'$pw;
  1034.                 $this->ipbwi->ips_wrapper->request['password'$pw;
  1035.             }
  1036.             $_POST['rememberMe'$cookie '1' false;
  1037.             $status $this->ipbwi->ips_wrapper->login->doLogin();
  1038.             if(isset($status[2])){
  1039.                 $this->loggedIn false;
  1040.                 $this->ipbwi->addSystemMessage('Error'$status[2]'Located in file <strong>'.__FILE__.'</strong> at class <strong>'.__CLASS__.'</strong> in function <strong>'.__FUNCTION__.'</strong> on line #<strong>'.__LINE__.'</strong>');
  1041.             }elseif($status[0!= ''){
  1042.                 $this->loggedIn true;
  1043.                 $this->myInfo = $this->info($this->name2id($_POST['username']));
  1044.                 $this->ipbwi->addSystemMessage('Success'$status[0]'Located in file <strong>'.__FILE__.'</strong> at class <strong>'.__CLASS__.'</strong> in function <strong>'.__FUNCTION__.'</strong> on line #<strong>'.__LINE__.'</strong>');
  1045.                 return true;
  1046.             }else{
  1047.                 $this->loggedIn false;
  1048.                 $this->ipbwi->addSystemMessage('Error''Login failed but no error was send out.''Located in file <strong>'.__FILE__.'</strong> at class <strong>'.__CLASS__.'</strong> in function <strong>'.__FUNCTION__.'</strong> on line #<strong>'.__LINE__.'</strong>');
  1049.                 return false;
  1050.             }
  1051.         }
  1052.  
  1053.         /**
  1054.          * @desc            Logout a user.
  1055.          * @return    bool    true on success, otherwise false
  1056.          * @author            Matthias Reuter
  1057.          * @sample
  1058.          *  <code>
  1059.          *  $ipbwi->member->logout();
  1060.          *  </code>
  1061.          * @since            2.0
  1062.          */
  1063.         public function logout(){
  1064.             $status @$this->ipbwi->ips_wrapper->login->doLogout(false)// @ todo: check notices from ip.board
  1065.             if(is_array($status&& count($status0){
  1066.                 $this->loggedIn false;
  1067.                 return true;
  1068.             }else{
  1069.                 return false;
  1070.             }
  1071.         }
  1072.         /**
  1073.          * @desc            Lists the board's members.
  1074.          * @param    array    $options Overwrites default behaviour of SQL query.
  1075.          *  The following options can be used to overwrite the default query results.
  1076.          *  <br>'order' default: 'asc'
  1077.          *  <br>'start' default: '0' start with first record
  1078.          *  <br>'limit' default: '30' no. of members per page
  1079.          *  <br>'orderby' default: 'name' other keys see below
  1080.          *  <br>'group' default: '*' all groups. You can specifiy a number or list of numbers
  1081.          *  <br>'extra_groups' default: false no extra groups. Turn to true to get extra-groups, too.
  1082.          *
  1083.          *  Sort keys: any field from '.$this->ipbwi->board['sql_tbl_prefix'].'members or '.$this->ipbwi->board['sql_tbl_prefix'].'groups.
  1084.          *  To avoid trouble ordering by a field 'xxx', use <b>m.XXX</b> or <b>g.XXX</b> as
  1085.          *  the full qualified fieldname, not just 'xxx'.
  1086.          * @return    array    Members
  1087.          * @author            Matthias Reuter
  1088.          * @sample
  1089.          *  <code>
  1090.          *  $ipbwi->member->getList();
  1091.          *  $ipbwi->member->getList(array('order' => 'asc', 'start' => '0', 'limit' => '30', 'orderby' => 'name', 'group' => '*'));
  1092.          *  </code>
  1093.          * @since            2.0
  1094.          */
  1095.         public function getList($options array('order' => 'asc''start' => '0''limit' => '30''orderby' => 'name''group' => '*''extra_groups' => false)) {
  1096.             // Ordering
  1097.             $orders array('id''name''posts''joined');
  1098.             if(!in_array($options['orderby']$orders)){
  1099.                 $options['orderby''name';
  1100.             }
  1101.             // Order By
  1102.             $options['order'($options['order'== 'desc''DESC' 'ASC';
  1103.             // Start and Limit
  1104.             $filter 'LIMIT '.intval($options['start']).','.intval($options['limit']);
  1105.             // Grouping
  1106.             $where '';
  1107.             if(is_array($options['group']AND $options['group'!= '*'){
  1108.                 foreach($options['group'as $i){
  1109.                     $i = (int)$i;
  1110.                     if($i 0){
  1111.                         if($where){
  1112.                             $where .= 'OR m.member_group_id="'.$i.'" ';
  1113.                         }else{
  1114.                             $where .= 'm.member_group_id="'.$i.'" ';
  1115.                         }
  1116.                         if ($options['extra_groups'])
  1117.                         {
  1118.                             $where .= 'OR FIND_IN_SET('.$i.', m.mgroup_others) ';
  1119.                         }
  1120.                     }
  1121.                 }
  1122.             }
  1123.             if($where){
  1124.                 $where 'WHERE m.member_id != "0" AND ('.$where.')';
  1125.             }else{
  1126.                 $where 'WHERE m.member_id != "0"';
  1127.             }
  1128.             $this->ipbwi->ips_wrapper->DB->query('SELECT m.*, g.*, cf.* FROM '.$this->ipbwi->board['sql_tbl_prefix'].'members m LEFT JOIN '.$this->ipbwi->board['sql_tbl_prefix'].'groups g ON (m.member_group_id=g.g_id) LEFT JOIN '.$this->ipbwi->board['sql_tbl_prefix'].'pfields_content cf ON (cf.member_id=m.member_id) '.$where.' ORDER BY '.$options['orderby'].' '.$options['order'].' '.$filter);
  1129.             $return array();
  1130.             while($row $this->ipbwi->ips_wrapper->DB->fetch()){
  1131.                 $return[$row['member_id']] $row;
  1132.             }
  1133.             return $return;
  1134.         }
  1135.         /**
  1136.          * @desc            Get an array of online members.
  1137.          * @param    bool    $detailed if true, function returns multi-dimensional array containing the result of get_advinfo() for each member. Default false - simple list.
  1138.          * @param    bool    $formatted if true, function will return an html list (string) of display names, each linked to each member's personal profile. Default false - returns array.
  1139.          * @param    bool    $show_anon if true, function will ignore logged-in member's anonymity choice. Default false - normal board action.
  1140.          * @param    string    $order_by choose what to order the results by - choose from 'member_name', 'member_id', 'running_time', 'location'. Default "running_time".
  1141.          * @param    string    $order choose what order to order the results in. Options are ascending; 'ASC', or descending; 'DESC'. Default 'DESC'.
  1142.          * @param    string    $separator - if $formatted set to true, this string will go between each linked display name. Default ', '.
  1143.          * @return    array    online member list
  1144.          * @author            Matthias Reuter
  1145.          * @sample
  1146.          *  <code>
  1147.          *  $ipbwi->member->listOnlineMembers();
  1148.          *  $ipbwi->member->listOnlineMembers(true,true,true,'member_name','ASC',' - ');
  1149.          *  </code>
  1150.          * @since            2.0
  1151.          */
  1152.         public function listOnlineMembers($detailed false$formatted false$show_anon false$order_by 'running_time'$order 'DESC'$separator ', '){
  1153.             // Grab the cut-off length in minutes from the board settings
  1154.             $cutoff $this->ipbwi->ips_wrapper->vars['au_cutoff'$this->ipbwi->ips_wrapper->vars['au_cutoff''15';
  1155.             // Create a timestamp for the current time, and subtract the cut-off length to get a timestamp in the past
  1156.             $timecutoff time()-($cutoff 60);
  1157.             if($formatted){
  1158.                 // the $formatted param is true, so let's return an HTML list of display name links, separated by $separator
  1159.                 // if this function has already been run and has saved a cache, return the cached value from database for speed
  1160.                 if($online $this->ipbwi->cache->get('listOnlineMembers''formatted'&& isset($online&& is_array($online&& count($online0){
  1161.                     // For each key in the $online array we just read from the database, set the value to the html formatted display name link
  1162.                     foreach($online as $key => $value){
  1163.                         // Grab advanced info for the member so we have the display name, prefix and suffix
  1164.                         $member $this->info($value);
  1165.                         // Create the html-formatted string
  1166.                         $link '<a href="'.$this->ipbwi->getBoardVar('url').'index.php?showuser='.$value.'">'.$member['prefix'].$member['members_display_name'].$member['suffix'].'</a>';
  1167.                         $online[$key$link;
  1168.                     }
  1169.                     // Now we have an array full of html links... But that isn't very helpful to a PHP newbie. Lets just return an html string. Implode the array with $separator
  1170.                     $online implode($separator,$online);
  1171.                     return $online;
  1172.                 }
  1173.                 // if we are happy to ignore logged-in members' requests to be anonymous, we need a slightly different database query.
  1174.                 if($show_anon){
  1175.                     $this->ipbwi->ips_wrapper->DB->query('SELECT member_id FROM '.$this->ipbwi->board['sql_tbl_prefix'].'sessions s WHERE s.member_id != "0" AND s.running_time > "'.$timecutoff.'" ORDER BY '.$order_by.' '.$order);
  1176.                 }else{
  1177.                     // ok so this is the normal database query which should return the member IDs of all logged-in members. It does not return guests as they have no member ID :)
  1178.                     $this->ipbwi->ips_wrapper->DB->query('SELECT member_id FROM '.$this->ipbwi->board['sql_tbl_prefix'].'sessions s WHERE s.login_type != "1" AND s.member_id != "0" AND s.running_time > "'.$timecutoff.'" ORDER BY '.$order_by.' '.$order);
  1179.                 }
  1180.                 // For each result from the MySQL query, add the member's ID to the $options array with the key and value both equal to the member's ID
  1181.                 while($row $this->ipbwi->ips_wrapper->DB->fetch()){
  1182.                     $ID $row['member_id'];
  1183.                     $online[$ID$ID;
  1184.                 }
  1185.                 // We didn't do all that just to have to do it again next time. Cache the result to the database for speed next time.
  1186.                 $this->ipbwi->cache->save('listOnlineMembers''formatted'$online);
  1187.                 // For each key in the $online array we just cached to the database, set the value to the html formatted display name link
  1188.                 if(isset($online&& is_array($online&& count($online0){
  1189.                     foreach($online as $key => $value){
  1190.                         // Grab advanced info for the member so we have the display name, prefix and suffix
  1191.                         $member $this->info($value);
  1192.                         // Create the html-formatted string
  1193.                         $link '<a href="'.$this->ipbwi->getBoardVar('url').'index.php?showuser='.$value.'">'.$member['prefix'].$member['members_display_name'].$member['suffix'].'</a>';
  1194.                         $online[$key$link;
  1195.                     }
  1196.                     // Now we have an array full of html links... But that isn't very helpful to a PHP newbie. Lets just return an html string. Implode the array with $separator
  1197.                     $online implode($separator,$online);
  1198.                     // Finally, return the array
  1199.                     return $online;
  1200.                 else{
  1201.                     return false;
  1202.                 }
  1203.             }
  1204.             // if the $detailed param is true, return extra info :)
  1205.             if($detailed){
  1206.                 // if this function has already been run and has saved a cache, return the cached value from database for speed
  1207.                 if($online $this->ipbwi->cache->get('listOnlineMembers''nodetail'&& isset($online&& is_array($online&& count($online0){
  1208.                     // For each key in the $online array we just read from the database, set the value to the result of get_advinfo(value)
  1209.                     foreach($online as $key => $value){
  1210.                         $online[$key$this->info($value);
  1211.                     }
  1212.                     // Return the array which now has extra info :)
  1213.                     return $online;
  1214.                 }
  1215.                 // if we are happy to ignore logged-in members' requests to be anonymous, we need a slightly different database query.
  1216.                 if($show_anon){
  1217.                     $this->ipbwi->ips_wrapper->DB->query('SELECT member_id FROM '.$this->ipbwi->board['sql_tbl_prefix'].'sessions s WHERE s.member_id != "0" AND s.running_time > "'.$timecutoff.'" ORDER BY '.$order_by.' '.$order);
  1218.                 }else{
  1219.                     // ok so this is the normal database query which should return the member IDs of all logged-in members. It does not return guests as they have no member ID :)
  1220.                     $this->ipbwi->ips_wrapper->DB->query('SELECT member_id FROM '.$this->ipbwi->board['sql_tbl_prefix'].'sessions s WHERE s.login_type != "1" AND s.member_id != "0" AND s.running_time > "'.$timecutoff.'" ORDER BY '.$order_by.' '.$order);
  1221.                 }
  1222.                 // For each result from the MySQL query, add the member's ID to the $options array with the key and value both equal to the member's ID
  1223.                 while($row $this->ipbwi->ips_wrapper->DB->fetch()){
  1224.                     $ID $row['member_id'];
  1225.                     $online[$ID$ID;
  1226.                 }
  1227.                 // We didn't do all that just to have to do it again next time. Cache the result to the database for speed next time.
  1228.                 $this->ipbwi->cache->save('listOnlineMembers''nodetail'$online);
  1229.                 // For each key in the $online array we just cached to the database, set the value to the result of get_advinfo(value)
  1230.                 if(isset($online&& is_array($online&& count($online0){
  1231.                     foreach($online as $key => $value){
  1232.                         $online[$key$this->info($value);
  1233.                     }
  1234.                     // Finally, return the array
  1235.                     return $online;
  1236.                 }else{
  1237.                      return false;
  1238.                 }
  1239.             }
  1240.             // neither $detailed or $formatted are true, so return a simple list
  1241.             // if this function has already been run and has saved a cache, return the cached value from database for speed
  1242.             if($online $this->ipbwi->cache->get('listOnlineMembers''simple')){
  1243.                 return $online;
  1244.             }
  1245.             // if we are happy to ignore logged-in members' requests to be anonymous, we need a slightly different database query.
  1246.             if($show_anon){
  1247.                 $this->ipbwi->ips_wrapper->DB->query('SELECT member_id FROM '.$this->ipbwi->board['sql_tbl_prefix'].'sessions s WHERE s.member_id != "0" AND s.running_time > "'.$timecutoff.'" ORDER BY '.$order_by.' '.$order);
  1248.             }else{
  1249.                 // ok so this is the normal database query which should return the member IDs of all logged-in members. It does not return guests as they have no member ID :)
  1250.                 $this->ipbwi->ips_wrapper->DB->query('SELECT member_id FROM '.$this->ipbwi->board['sql_tbl_prefix'].'sessions s WHERE s.login_type != "1" AND s.member_id != "0" AND s.running_time > "'.$timecutoff.'" ORDER BY '.$order_by.' '.$order);
  1251.             }
  1252.             // For each result from the MySQL query, add the member's ID to the $options array with the key and value both equal to the member's ID
  1253.             while($row $this->ipbwi->ips_wrapper->DB->fetch()){
  1254.                 $ID $row['member_id'];
  1255.                 $online[$ID$ID;
  1256.             }
  1257.             // We didn't do all that just to have to do it again next time. Cache the result to the database for speed next time.
  1258.             $this->ipbwi->cache->save('listOnlineMembers''simple'$online);
  1259.             // Finally, return the array
  1260.             return $online;
  1261.         }
  1262.         /**
  1263.          * @desc            Get an array of random members.
  1264.          * @param    int        $limit How many Member should be returned? default: 5
  1265.          * @param    string    $where For advanced requests: SQL-Statement to filter the output
  1266.          * @return    array    Random Members
  1267.          * @author            Matthias Reuter
  1268.          * @sample
  1269.          *  <code>
  1270.          *  $ipbwi->member->listRandomMembers();
  1271.          *  $ipbwi->member->listRandomMembers(5,'posts!=0 AND me.avatar_location != "" AND me.avatar_location != "noavatar"');
  1272.          *  </code>
  1273.          * @since            2.0
  1274.          */
  1275.         public function listRandomMembers($limit 5,$where false){
  1276.             if($where){
  1277.                 $where 'WHERE '.$where;
  1278.             }
  1279.             $this->ipbwi->ips_wrapper->DB->query('SELECT * FROM '.$this->ipbwi->board['sql_tbl_prefix'].'members m LEFT JOIN '.$this->ipbwi->board['sql_tbl_prefix'].'member_extra me ON (me.id=m.id)'.$where.' ORDER BY RAND() LIMIT '.intval($limit));
  1280.             $random array();
  1281.             while($row $this->ipbwi->ips_wrapper->DB->fetch()){
  1282.                 $random[$row['id']] $row;
  1283.             }
  1284.             return $random;
  1285.         }
  1286.         /**
  1287.          * @desc            Removes a friend
  1288.          * @param    int        $userID Member ID to be deleted
  1289.          * @return    bool    true on success, otherwise false
  1290.          * @author            Matthias Reuter
  1291.          * @sample
  1292.          *  <code>
  1293.          *  $ipbwi->member->removeFriend(55);
  1294.          *  </code>
  1295.          * @since            2.0
  1296.          */
  1297.         public function removeFriend($userID){
  1298.             if($this->isLoggedIn()){
  1299.                 $this->ipbwi->ips_wrapper->DB->query('DELETE FROM '.$this->ipbwi->board['sql_tbl_prefix'].'profile_friends WHERE friends_friend_id="'.intval($userID).'" AND friends_member_id="'.$this->ipbwi->member->myInfo['member_id'].'"');
  1300.                 if($this->ipbwi->ips_wrapper->DB->get_affected_rows()){
  1301.                     // recache
  1302.                     $this->ipbwi->ips_wrapper->pack_and_update_member_cache($this->ipbwi->member->myInfo['member_id']array('friends' => $this->friendsList()));
  1303.                     $this->ipbwi->ips_wrapper->pack_and_update_member_cache(intval($userID)array('friends' => $this->friendsList(false,$userID)));
  1304.                     return true;
  1305.                 }else{
  1306.                     return false;
  1307.                 }
  1308.             }else{
  1309.                 return false;
  1310.             }
  1311.         }
  1312.         /**
  1313.          * @desc            Adds a friend
  1314.          * @param    int        $userID Member ID to be added
  1315.          * @return    bool    true on success, otherwise false
  1316.          * @author            Matthias Reuter
  1317.          * @sample
  1318.          *  <code>
  1319.          *  $ipbwi->member->addFriend(55);
  1320.          *  </code>
  1321.          * @since            2.0
  1322.          */
  1323.         public function addFriend($userID){
  1324.             if($this->isLoggedIn()){
  1325.                 // Check user exists
  1326.                 if(!$userID OR !$this->info(intval($userID))){
  1327.                     return false;
  1328.                 }
  1329.                 // o_O. Firstly check if there is already an entry.
  1330.                 $this->ipbwi->ips_wrapper->DB->query('SELECT * FROM '.$this->ipbwi->board['sql_tbl_prefix'].'profile_friends WHERE friends_friend_id="'.intval($userID).'"AND friends_member_id="'.$this->ipbwi->member->myInfo['member_id'].'"');
  1331.                 if($row $this->ipbwi->ips_wrapper->DB->fetch()){
  1332.                     return true;
  1333.                 }else{
  1334.                     // We can just add an entry because theres nothing there.
  1335.                     $friend $this->info($userID);
  1336.                     // support for moderate_friends-field have to be added (including sending confirmation message)
  1337.                     //if($friend['pp_setting_moderate_friends']) $friends_approved = 0; else $friends_approved = 1;
  1338.                     $friends_approved 1;
  1339.                     if($this->ipbwi->ips_wrapper->DB->query('INSERT INTO '.$this->ipbwi->board['sql_tbl_prefix'].'profile_friends VALUES ("", "'.$this->ipbwi->member->myInfo['member_id'].'","'.intval($userID).'","'.$friends_approved.'", "'.time().'")')){
  1340.                         // recache
  1341.                         $this->ipbwi->ips_wrapper->pack_and_update_member_cache($this->ipbwi->member->myInfo['member_id']array('friends' => $this->friendsList()));
  1342.                         $this->ipbwi->ips_wrapper->pack_and_update_member_cache(intval($userID)array('friends' => $this->friendsList(false,$userID)));
  1343.                     }
  1344.                     return true;
  1345.                 }
  1346.             }else{
  1347.                 return false;
  1348.             }
  1349.         }
  1350.         /**
  1351.          * @desc            Returns information on the current user's contacts.
  1352.          * @param    bool    $userID Member-ID to get friends of this member. If not set, friends of currently logged in member will be listed.
  1353.          * @param    bool    $details Detailed Member Information, default: false
  1354.          * @param    bool    $unapproved List unapproved friends, default: false
  1355.          * @return    array    Friends Informations
  1356.          * @author            Matthias Reuter
  1357.          * @sample
  1358.          *  <code>
  1359.          *  $ipbwi->member->friendsList();
  1360.          *  $ipbwi->member->friendsList(55,true,true);
  1361.          *  </code>
  1362.          * @since            2.0
  1363.          */
  1364.         public function friendsList($userID false,$details false,$unapproved false){
  1365.             // check for memberid
  1366.             if(is_string($userID)) {
  1367.                 $member intval($userID);
  1368.             }elseif($this->isLoggedIn()){
  1369.                 $member $this->ipbwi->member->myInfo['member_id'];
  1370.             }else{
  1371.                 return false;
  1372.             }
  1373.             // check if unapproved
  1374.             if(empty($unapproved)){
  1375.                 $approved ' AND friends_approved="1"';
  1376.             }
  1377.             $this->ipbwi->ips_wrapper->DB->query('SELECT * FROM '.$this->ipbwi->board['sql_tbl_prefix'].'profile_friends WHERE friends_member_id="'.$member.'"'.$approved);
  1378.             $friends array();
  1379.             while($row $this->ipbwi->ips_wrapper->DB->fetch()){
  1380.                 $friends[$row['friends_id']] $row;
  1381.             }
  1382.             // check for details
  1383.             if($details === true){
  1384.                 foreach($friends as $friend){
  1385.                     $friends[$friend['friends_id']]['details'$this->info($friend['friends_friend_id']);
  1386.                 }
  1387.             }
  1388.             return $friends;
  1389.         }
  1390.     }
  1391. ?>

Documentation generated on Sat, 23 Oct 2010 23:35:59 +0200 by phpDocumentor 1.4.3