Location: PHPKode > scripts > WebsiteMemberManager > members-section/php-lib/member-class.php
<?php
class WMMmembers{
 function create($auto_activate,$post_array)
 {
  $WMMAdmin= new WMMAdmin();
  if ($WMMAdmin->totalMembers==11) $WMMAdmin->notifyAtMax();
  foreach ($post_array AS $key => $value) $$key = clean_input($value);//clean ALL input
  // check vars not set - to enable removal of unwanted inputs from join page
  if (!isset($companyname)) $companyname="";
  if (!isset($address1)) $address1="";
  if (!isset($address2)) $address2="";
  if (!isset($postcode)) $postcode="";
  if (!isset($country)) $country="";
  if (!isset($tel)) $tel="";
  if (!isset($mobile)) $mobile="";
  if (!isset($heardaboutusfrom)) $heardaboutusfrom="";
  if (!isset($comments)) $comments="";
  $address = $address1." ".$address2;
  $their_username = $email;
  $their_password = random_password(8);
  $cpass = WMMcrypt($their_password,$their_username);
  $join_date = time();
  if ($auto_activate==1) $activated_date=$join_date;
  else $activated_date=-1;
  if (!isset($duration)) $duration=0;//where PayPal is not used  
  $expire_date = mktime (0,0,0,date("m")+12, date("d"), date("Y"));//required when PayPal not used
  if (paypal_enabled())
  {
   $expire_date = $join_date;
   $auto_activate=0;
  }
  else $duration=31556926;//ensures new accounts expire date is 12 months in future
  $query = "
      INSERT INTO `wmm_members` (`id`, `name`, `companyname`, `email` , `address` , `country` , `postcode` , `tel` , `mobile` , `heardaboutusfrom` , `their_username` , `their_password` , `comments` , `activated` , `activated_date` , `duration` , `expire_date` )
                      VALUES (:join_date,:name,:companyname, :email, :address, :country, :postcode,:tel,:mobile,:heardaboutusfrom,:their_username,:cpass, :comments, :auto_activate,:activated_date,:duration, :expire_date) ";
  $dbc = dbc::instance();              
  $result = $dbc->prepare($query);
  $result->bindParam(':join_date', $join_date, PDO::PARAM_INT);
  $result->bindParam(':name', $name, PDO::PARAM_STR);
  $result->bindParam(':companyname', $companyname, PDO::PARAM_STR);
  $result->bindParam(':email', $email, PDO::PARAM_STR);
  $result->bindParam(':address', $address, PDO::PARAM_STR);
  $result->bindParam(':country', $country, PDO::PARAM_STR);
  $result->bindParam(':postcode', $postcode, PDO::PARAM_STR);
  $result->bindParam(':tel', $tel, PDO::PARAM_STR);
  $result->bindParam(':mobile', $mobile, PDO::PARAM_STR);
  $result->bindParam(':heardaboutusfrom', $heardaboutusfrom, PDO::PARAM_STR);
  $result->bindParam(':their_username', $their_username, PDO::PARAM_STR);
  $result->bindParam(':cpass', $cpass, PDO::PARAM_STR);
  $result->bindParam(':comments', $comments, PDO::PARAM_STR);
  $result->bindParam(':auto_activate', $auto_activate, PDO::PARAM_INT);
  $result->bindParam(':activated_date', $activated_date, PDO::PARAM_INT);
  $result->bindParam(':duration', $duration, PDO::PARAM_INT);
  $result->bindParam(':expire_date', $expire_date, PDO::PARAM_INT);
  $result = $dbc->execute($result);
  if (CREATE_PRIVATE_FOLDERS)
  {
   $privateFolders= new privateFolders();
   $privateFolders->create($their_username);
  }        
  return $join_date;// new members id
 }
 
 function update($id,$post_array)
 {
  foreach ($post_array AS $key => $value) $$key = clean_input($value);//clean ALL input
  $dbc = dbc::instance();
  $update_query = "
    UPDATE wmm_members
     SET companyname=:companyname,
        name=:name,
        address=:address,
        email=:email,
        tel=:tel,
        mobile=:mobile,
        postcode=:postcode,
        comments=:comments,
        subscribed=:subscribed
     WHERE id=:id ";
  //echo $update_query."<hr>";
  $result = $dbc->prepare($update_query);
  $result->bindParam(':companyname', $companyname, PDO::PARAM_STR);
  $result->bindParam(':name', $name, PDO::PARAM_STR);
  $result->bindParam(':address', $address, PDO::PARAM_STR);
  $result->bindParam(':email', $email, PDO::PARAM_STR);
  $result->bindParam(':tel', $tel, PDO::PARAM_STR);
  $result->bindParam(':mobile', $mobile, PDO::PARAM_STR);
  $result->bindParam(':postcode', $postcode, PDO::PARAM_STR);
  $result->bindParam(':comments', $comments, PDO::PARAM_STR);
  $result->bindParam(':subscribed', $subscribed, PDO::PARAM_INT);
  $result->bindParam(':id', $id, PDO::PARAM_INT);
  $result = $dbc->execute($result);  
 }
 function get($id)
 {
  $dbc = dbc::instance();
  $get_query = "SELECT * from wmm_members where id=:id ";
  $result = $dbc->prepare($get_query);
  $result->bindParam(':id', $id, PDO::PARAM_INT);
  $rows = $dbc->executeGetRows($result);
  return $rows[0];
 }
 function delete($id)
 {
   if (CREATE_PRIVATE_FOLDERS)
   {
    $privateFolders= new privateFolders();
    $privateFolders->delete($id);
   }
   $update_query = "delete from wmm_logins where member_id=:id ";
   $result = $dbc->prepare($update_query);
   $result->bindParam(':id', $id, PDO::PARAM_INT);
   $result = $dbc->execute($result);
   $update_query = "delete from wmm_paypal_subscriptions where member_id=:id ";
   $result = $dbc->prepare($update_query);
   $result->bindParam(':id', $id, PDO::PARAM_INT);
   $result = $dbc->execute($result);
   $update_query = "DELETE from wmm_members where id=:id ";
   $result = $dbc->prepare($update_query);
   $result->bindParam(':id', $id, PDO::PARAM_INT);
   $result = $dbc->execute($result);
   $update_query="DELETE from wmm_phpbb_user_ids where wmm_member_id=:id ";
   $result = $dbc->prepare($update_query);
   $result->bindParam(':id', $id, PDO::PARAM_INT);
   $result = $dbc->execute($result);   
 }   
} 
?>
Return current item: WebsiteMemberManager