'*** No integration ***'); foreach($groups as $i => $n){ if (in_array($i, (array)$this_config['denied_levels'])) continue; $res[$i] = $n; } return $res; } // return max level of access for given user status // if not found any, return -1 // then calling script must assign $this_config['default_level'] function smf_get_max($status){ global $plugin_config, $db; $nuke_products = smf_get_products(); foreach ((array)$status as $product_id => $s){ if ($s && in_array($product_id, $nuke_products)){ $p = $db->get_product($product_id); if ($p['smf_access'] > $max) $max = $p['smf_access']; } } return $max; } add_product_field('smf_access', 'SMF access', 'select', "users ordered this product will
get the following group in SMF", '', array('options' => smf_get_groups() )); function smf_get_products(){ global $db; ## find products # which allow access to invision $nuke_products = array(); foreach ($db->get_products_list() as $p) if ($p['smf_access']) $nuke_products[] = $p['product_id']; return $nuke_products; } function get_smf_levels1(){ global $db, $config; $smfdb = $config['protect']['smf']['db']; if(!$smfdb) return array(); $groups=array(); $qry = $db->query("select * from {$smfdb}membergroups"); while($res = mysql_fetch_assoc($qry)){ $groups[$res[ID_GROUP]] = $res[groupName]; } //print_r($groups); return $groups; } function smf_added($member_id, $product_id, $member){ global $db, $config, $plugin_config; $max = smf_get_max($member['data']['status']); if ($max == '') return; foreach ($member as $k=>$v) $member[$k] = $db->escape($v); $profile=array(); if(smf_user_exists($member[login])){ $profile = smf_get_profile($member[login]); $profile[realName] = $member[login]; $profile[emailAddress] = $member[email]; $profile[ID_GROUP] = $max; // $profile[passwd] = md5_hmac($member[pass], strtolower($member[login])); $profile[passwd] = sha1(strtolower($member[login]) . $member[pass]); // $newPassword = substr(preg_replace('/\W/', '', md5(rand())), 0, 10); // $newPassword_sha1 = sha1(strtolower($user) . $newPassword); // if($member[hideemail]){ $profile[hideEmail] = 1; // } if($member[displayedname]){ $profile[realName] = $member[displayedname]; } smf_update_profile($member[login], $profile); }else{ $profile[realName] = $member[login]; $profile[emailAddress] = $member[email]; $profile[ID_GROUP] = $max; $profile[personalText] = "aMember user"; // $profile[passwd] = md5_hmac($member[pass], strtolower($member[login])); $profile[passwd] = sha1(strtolower($member[login]) . $member[pass]); $profile[dateRegistered] = time(); // if($member[hideemail]){ $profile[hideEmail] = 1; // } if($member[displayedname]){ $profile[realName] = $member[displayedname]; } smf_create_profile($member[login], $profile); } $member = $db->get_user($member_id); $member[hideemail] = 1; $db->update_user($member_id, $member); smf_update_stats(); } function smf_user_exists($login){ global $db, $config, $plugin_config; $this_config = $plugin_config['protect']['smf']; $ydb = $this_config['db']; $qry = mysql_query("select count(*) from {$ydb}members where memberName='$login'"); list($exists) = mysql_fetch_row($qry); return $exists; } function smf_get_profile($login){ global $db, $config, $plugin_config; $this_config = $plugin_config['protect']['smf']; $ydb = $this_config['db']; $qry = mysql_query("select * from {$ydb}members where memberName = '$login'"); $profile = mysql_fetch_assoc($qry); return $profile; } function smf_create_profile($login, $profile){ global $db, $config, $plugin_config; $this_config = $plugin_config['protect']['smf']; $ydb = $this_config['db']; $qry=$db->query("insert into {$ydb}members (memberName, realName, emailAddress, ID_GROUP, personalText, passwd, dateRegistered, hideEmail) values ('$login', '$profile[realName]', '$profile[emailAddress]', '$profile[ID_GROUP]', '$profile[personalText]', '$profile[passwd]', '$profile[dateRegistered]', '1')"); } function smf_update_profile($login, $profile){ global $db, $config, $plugin_config; $this_config = $plugin_config['protect']['smf']; $ydb = $this_config['db']; foreach($profile as $k=>$v){ $res[] = "$k = '".$db->escape($v)."'"; } $res = join(", ", $res); $qry = $db->query("update {$ydb}members set $res where memberName = '$login'"); } function smf_check_uniq_login($login, $email, $pass){ global $db, $config, $plugin_config; $this_config = $plugin_config['protect']['smf']; $login = $db->escape($login); $email = $db->escape($email); if(!smf_user_exists($login)) return 1; $profile = smf_get_profile($login); // print_r($profile); if( (strtolower($profile[emailAddress])==strtolower($email)) and ($profile[passwd] == sha1(strtolower($login) . $pass))) return 1; // Unic = 1; return 0; } function smf_updated($member_id, $oldmember, $newmember){ global $db, $config, $plugin_config; $this_config = $plugin_config['protect']['smf']; $max = smf_get_max($oldmember['data']['status']); if ($max == 0) $max = $this_config['default_level']; // print "test $max"; $profile = smf_get_profile($oldmember[login]); if(in_array($profile[ID_GROUP], $this_config['denied_levels'])) return; $profile[emailAddress] = $newmember[email]; // $profile[passwd] = md5_hmac($newmember[pass], strtolower($newmember[login])); $profile[passwd] = sha1(strtolower($newmember[login]) . $newmember[pass]); $profile[realName] = $newmember[login]; $profile[ID_GROUP] = $max; $profile[hideEmail] = $newmember[hideemail]; if($newmember[displayedname]){ $profile[realName] = $newmember[displayedname]; } smf_update_profile($oldmember[login], $profile); smf_update_stats(); } function smf_deleted($member_id, $product_id, $member){ global $db, $config, $plugin_config; $this_config = $plugin_config['protect']['smf']; $max = smf_get_max($member['data']['status']); if ($max == 0) $max = $this_config['default_level']; // print "test $max"; $profile = smf_get_profile($member[login]); if(in_array($profile[ID_GROUP], $this_config['denied_levels'])) return; $profile[ID_GROUP] = $max; smf_update_profile($member[login], $profile); } function smf_removed($member_id, $member){ global $db, $config, $plugin_config; $this_config = $plugin_config['protect']['smf']; $profile = smf_get_profile($member[login]); if(in_array($profile[ID_GROUP], $this_config['denied_levels'])) return; $profile[ID_GROUP] = $this_config['default_level']; smf_update_profile($member[login], $profile); } function smf_rebuild(&$members){ global $config, $db, $plugin_config; $this_config = $plugin_config['protect']['smf']; $ydb = $this_config['db']; $ib_products = smf_get_products(); ## get list from yabbse $ib_users = array(); $qry = $db->query("select memberName, ID_GROUP from {$ydb}members"); while($res = mysql_fetch_assoc($qry)){ $ib_users[$res[memberName]] = $res[ID_GROUP]; } // print_r($ib_users); ## $nuke_products = smf_get_products(); foreach ($members as $l=>$m){ $status = array(); foreach ($m['product_id'] as $i) $status[$i] = 1; $max = smf_get_max($status); if ($max > $ib_users[$l]){ // $member = $db->users_find_by_string($l,'login',1); $member = $member[0]; if (!$member['member_id']) continue; smf_added($member['member_id'], $nuke_products[0], $member); } elseif (($max == 0) && !isset($ib_users[$l])){ continue; } elseif ($max < $ib_users[$l]) { // check that really enabled $member = $db->users_find_by_string($l,'login',1); $member = $member[0]; if (!$member['member_id']) continue; smf_deleted($member['member_id'], $nuke_products[0], $member); } } ## smf_update_stats(); } function smf_get_user_by_id($id){ global $plugins, $plugin_config, $HTTP_COOKIE_VARS; global $db; $this_config = $plugin_config['protect']['smf']; $ydb = $this_config['db']; $qry = $db->query("select * from {$ydb}members where ID_MEMBER = '$id'"); $profile = mysql_fetch_assoc($qry); return $profile; } function smf_update_stats(){ global $plugins, $plugin_config, $HTTP_COOKIE_VARS; global $db; $this_config = $plugin_config['protect']['smf']; $ydb = $this_config['db']; $qry = $db->query("select count(*) from {$ydb}members"); list($cnt) = mysql_fetch_row($qry); $qry = $db->query("select * from {$ydb}members order by ID_MEMBER desc limit 1"); $last = mysql_fetch_assoc($qry); $qry = mysql_query("update {$ydb}settings set value=$cnt where variable='memberCount'"); $qry = mysql_query("update {$ydb}settings set value='".$last[memberName]."' where variable='latestMember'"); $qry = mysql_query("update {$ydb}settings set value='".$last[realName]."' where variable='latestRealName'"); } function smf_check_logged_in(){ // check if user already logged-in with invision // must return array($login, $pass) // of logged-in invision customer or empty values global $plugins, $plugin_config, $HTTP_COOKIE_VARS; global $db; $this_config = $plugin_config['protect']['yabbse']; // print_r($HTTP_COOKIE_VARS); $cookie = $HTTP_COOKIE_VARS[SMFCookie548]; list($cl, $cp) = @unserialize(stripslashes($cookie)); $profile = smf_get_user_by_id($cl); // print_r($profile); $cl = $profile[memberName]; if (in_array('smf', $plugins['protect']) && $cl && $cp){ $members = $db->users_find_by_string($cl, 'login', 1); $member = $members[0]; // print_r($member); $correct = (sha1(sha1(strtolower($member[login]).$member[pass]).$profile[passwordSalt])==$cp); if ($correct){ global $HTTP_SESSION_VARS; session_start(); session_register('_amember_logged_from_smf'); $HTTP_SESSION_VARS['_amember_logged_from_smf']=1; $GLOBALS['_amember_logged_from_smf']=1; $l = $member[login]; $p = $member[pass]; } else { $l = $p = ''; } } return array($l,$p); } function smf_after_login($user){ global $db, $config, $plugin_config; global $HTTP_COOKIE_VARS, $HTTP_SESSION_VARS; $this_config = $plugin_config['protect']['smf']; session_start(); session_register('_amember_smf_cookies_set'); $profile = smf_get_profile($user[login]); if($profile[passwd] != sha1(strtolower($user[login]) . $user[pass])){ return; } $profile[passwordSalt] = substr(md5(rand()), 0, 4); smf_update_profile($user[login], $profile); //sha1($user_settings['passwd'] . $user_settings['passwordSalt']) setcookie("SMFCookie548",serialize(array($profile['ID_MEMBER'], sha1($profile[passwd].$profile[passwordSalt]), time() + 3600*24*30, 2)), time()+3600*24*30, "/"); $GLOBALS['_amember_smf_cookies_set'] = 1; $HTTP_SESSION_VARS['_amember_smf_cookies_set'] = 1; session_register('_amember_smf_cookies_set'); $GLOBALS['_amember_smf_cookies_set'] = 1; $HTTP_SESSION_VARS['_amember_smf_cookies_set'] = 1; } function smf_after_logout(){ global $db, $plugins, $plugin_config, $HTTP_COOKIE_VARS; global $HTTP_SESSION_VARS; $this_config = $plugin_config['protect']['smf']; $ib_db = $this_config['db']; session_start(); setcookie("SMFCookie548", "", 0, "/"); } function md5_hmac($data, $key) { $key = str_pad(strlen($key) <= 64 ? $key : pack('H*', md5($key)), 64, chr(0x00)); return md5(($key ^ str_repeat(chr(0x5c), 64)) . pack('H*', md5(($key ^ str_repeat(chr(0x36), 64)). $data))); } ?> Sign-up

Sign-up


Membership Type *






Payment System *

Your Name *
Your First & Last name
Your E-Mail Address *
A confirmation email will be sent
to you at this address
Choose a Login Name (User ID) *
It must be 4 or more characters in length and may
only contain small letters, numbers, and
the underscore '_'
check for uniqueness
Choose a Password *
Must be 4 or more characters
Confirm your password *
Enter password again
ADDRESS INFO








Powered by aMember Pro membership software






© CGI-Central.NET, 2002-2006