function account_delete($account_id, $username)
 {
     $db_map = new db_mapping();
     $remote_account_id = $db_map->MAP_account_delete($account_id, $username, $this);
     ### Update the remote account:
     $dbm = new db_mapping();
     $db2 = $dbm->DB_connect(false, $this->map['map']);
     eval('@$db_prefix = DB2_PREFIX' . strtoupper($this->map['map']) . ';');
     $sql = "DELETE FROM " . $db_prefix . "userfield WHERE userid =  " . $db2->qstr($remote_account_id);
     $group_result = $db2->Execute($sql);
 }
 function install()
 {
     ### Add the 'customers_username' field:
     $dbm = new db_mapping();
     $db = $dbm->DB_connect(false, $this->map['map']);
     eval('@$db_prefix = DB2_PREFIX' . strtoupper($this->map['map']) . ';');
     $sql = "ALTER TABLE customers ADD customers_username VARCHAR( 128 ) NOT NULL";
     $result = $db->Execute($sql);
     ### move the customer's email to the username field...
     $sql = "SELECT customers_id, customers_email_address FROM customers";
     $result = $db->Execute($sql);
     while (!$result->EOF) {
         $sql = 'UPDATE customers SET
                     customers_username = '******'customers_email_address']) . '
                     WHERE customers_id = ' . $db->qstr($result->fields['customers_id']);
         $update = $db->Execute($sql);
         $result->MoveNext();
     }
 }
Example #3
0
 function account_group_sync($account_id)
 {
     $db_map = new db_mapping();
     $db_map->MAP_account_group_sync_db_status($account_id);
     ### Get the local account details
     $db =& DB();
     $sql = 'SELECT username,email FROM ' . AGILE_DB_PREFIX . 'account WHERE
                 site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND
                 id      = ' . $db->qstr($account_id);
     $result = $db->Execute($sql);
     if ($result === false) {
         global $C_debug;
         $C_debug->error('Mambo_4_5.php', 'account_group_sync:1', $db->ErrorMsg());
         return;
     }
     $user = $result->fields['username'];
     $email = $result->fields['email'];
     ### Get the remote account id, username, and group ID:
     $dbm = new db_mapping();
     $db2 = $dbm->DB_connect(false, $this->map['map']);
     eval('@$db_prefix = DB2_PREFIX' . strtoupper($this->map['map']) . ';');
     $sql = "SELECT id,gid,username FROM " . $db_prefix . "" . $this->map['account_map_field'] . ' WHERE ' . $this->map['account_fields']['username']['map_field'] . " = " . $db2->qstr($user);
     $result = $db2->Execute($sql);
     if ($result === false) {
         global $C_debug;
         $C_debug->error('Mambo_4_5.php', 'account_group_sync:2', $db2->ErrorMsg());
         return;
     }
     $id = $result->fields['id'];
     $user = $result->fields['username'];
     $gid = $result->fields['gid'];
     # Clear old values:
     $sql = "DELETE FROM  " . $db_prefix . "core_acl_aro WHERE value = {$id}";
     $result = $db2->Execute($sql);
     # add the core_acl_aro record
     $sql = "INSERT INTO " . $db_prefix . "core_acl_aro SET \n                        section_value \t= 'users',\n                        value\t\t\t= {$id},\n                        name\t\t\t= " . $db2->qstr($user);
     $result = $db2->Execute($sql);
     # Get the ID just inserted:
     $sql = "SELECT aro_id FROM " . $db_prefix . "core_acl_aro WHERE value = {$id}";
     $result = $db2->Execute($sql);
     $aro_id = $result->fields['aro_id'];
     $sql = "DELETE FROM  " . $db_prefix . "core_acl_groups_aro_map WHERE aro_id = {$aro_id}";
     $result = $db2->Execute($sql);
     if ($gid > 0 && $aro_id > 0) {
         # add the core_acl_groups_aro_map record
         $sql = "INSERT INTO " . $db_prefix . "core_acl_groups_aro_map SET \n\t            \t\t\tgroup_id\t\t= {$gid},\n\t            \t\t\taro_id\t\t\t= {$aro_id}";
         $result = $db2->Execute($sql);
         # unblock
         $sql = "UPDATE  " . $db_prefix . $this->map['account_map_field'] . "\n\t                        SET block = 0\n\t                        WHERE id = {$id}";
         $result = $db2->Execute($sql);
     } else {
         /*
         	            	This member gets access to nothing.
         	            	
         	            	Mambo doesn't have a group we can grant the users
         	            	that allows them only public access articles. Lame. 
         	            	
         	            	After studying mambo's group system in depth, 
         	            	it makes no sense how something so complicated (6 tables?) can not
         	            	be used to control access to the articles?! Wit a CMS system, it is 
         	            	all about the content and if you have groups, you should be able to
         	            	display/hide content based on the user's group membership.
         	            	
         	            	However, with mambo, apparently you can set the articles so they can 
         	            	be viewed by a) all users, (b) registered users, (c) Special.
         	            	
         	            	Since I can find no way to map the users to option (c), and obviously 
         	            	non-paying members will still be registered after their subscription
         	            	expires, our options are now to delete the user entirely (NO!)
         	            	or set the user to blocked (lesser of two evils but will cause confusion
         	            	since mambo will tell the user the login info they submitted is invalid)
         	            	
         	Lets block the user and be done with it... Sigh...
         */
         $sql = "UPDATE  " . $db_prefix . $this->map['account_map_field'] . "\n\t                        SET block = 1\n\t                        WHERE id = {$id}";
         $result = $db2->Execute($sql);
     }
 }
 function MAP_account_logout($account_id, $MAP_this)
 {
     ### Clear the session info in IBF
     $dbm = new db_mapping();
     $db = $dbm->DB_connect(false, $MAP_this->map['map']);
     eval('@$db_prefix = DB2_PREFIX' . strtoupper($MAP_this->map['map']) . ';');
     $sql = 'UPDATE ' . $db_prefix . 'sessions SET
     			member_name		=' . $db->qstr('NULL') . ',
     			member_id 		=' . $db->qstr(0) . ',
     			login_type 		=' . $db->qstr(0) . ',
     			member_group	=' . $db->qstr(2) . ' 
     			WHERE id 		=' . $db->qstr(SESS);
     $result = $db->Execute($sql);
     ### error reporting:
     if ($result === false) {
         global $C_debug;
         $C_debug->error('db_mapping.inc.php', 'Map_account_logout_delete_account_session', $db->ErrorMsg());
         $smarty->assign('db_mapping_result', $db->ErrorMsg());
         return;
     }
     ### Clear the IBF cookies
     setcookie("session_id", 0, 0, '/');
     setcookie("member_id", 0, 0, '/');
     setcookie("pass_hash", 0, 0, '/');
     return;
 }
Example #5
0
    function MAP_account_group_sync_db_status($account_id, $MAP_this)
    {
        ### Get the local account details
        $db =& DB();
        $sql = 'SELECT username,email FROM ' . AGILE_DB_PREFIX . 'account WHERE
				site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND
				id      = ' . $db->qstr($account_id);
        $result = $db->Execute($sql);
        if ($result === false) {
            global $C_debug;
            $C_debug->error('db_mapping.inc.php', 'MAP_account_group_sync_status', $db->ErrorMsg());
            return;
        }
        $user = $result->fields['username'];
        $email = $result->fields['email'];
        ### Get the remote account id:
        $dbm = new db_mapping();
        $db2 = $dbm->DB_connect(false, $MAP_this->map['map']);
        eval('@$db_prefix = DB2_PREFIX' . strtoupper($MAP_this->map['map']) . ';');
        $sql = "SELECT " . $MAP_this->map['account_fields']['id']['map_field'] . " FROM " . $db_prefix . "" . $MAP_this->map['account_map_field'] . ' WHERE ' . $MAP_this->map['account_fields']['username']['map_field'] . " = " . $db2->qstr($user);
        $result = $db2->Execute($sql);
        if ($result === false) {
            global $C_debug;
            $C_debug->error('db_mapping.inc.php', 'MAP_account_group_sync_status', $db2->ErrorMsg());
            return;
        }
        $fld_remote_id = $MAP_this->map['account_fields']['id']['map_field'];
        $remote_account_id = $result->fields[$fld_remote_id];
        ### Get the group_map array for this database map:
        if (!isset($this->group_arr)) {
            $db =& DB();
            $sql = "SELECT group_map,group_rank FROM " . AGILE_DB_PREFIX . "db_mapping WHERE\n\t\t\t\t\tmap_file = " . $db->qstr($MAP_this->map['map']) . " AND\n\t\t\t\t\tsite_id  = " . $db->qstr(DEFAULT_SITE);
            $result = $db->Execute($sql);
            if ($result === false) {
                global $C_debug;
                $C_debug->error('db_mapping.inc.php', 'MAP_account_group_sync_status', $db->ErrorMsg());
                return;
            }
            @($MAP_this->group_arr = unserialize($result->fields['group_map']));
            @($MAP_this->group_rank = unserialize($result->fields['group_rank']));
        }
        ### Determine the groups the selected account is authorize for:
        $db =& DB();
        $sql = "SELECT group_id,date_start,date_expire FROM " . AGILE_DB_PREFIX . "account_group WHERE\n\t\t\t\taccount_id  =  " . $db->qstr($account_id) . " AND\n\t\t\t\tactive      =  " . $db->qstr(1) . " AND\n\t\t\t\tsite_id     =  " . $db->qstr(DEFAULT_SITE);
        $result = $db->Execute($sql);
        ### error reporting:
        if ($result === false) {
            global $C_debug;
            $C_debug->error('db_mapping.inc.php', 'MAP_account_group_sync_status', $db->ErrorMsg());
            return;
        }
        if ($result->RecordCount() == 0) {
            return;
        }
        $MAP_this->status = 0;
        if ($result->RecordCount() == 0) {
            return;
        }
        $rank = 0;
        while (!$result->EOF) {
            $start = $result->fields['date_start'];
            $expire = $result->fields['date_expire'];
            $group = $result->fields['group_id'];
            ### Group access started and not expired:
            if (($expire >= time() || $expire == '' || $expire == '0') && ($start <= time() || $start == '' || $start == '0')) {
                ### Group is authorized:
                ### Get the associated remote group(s) this account needs
                ### to be added to:
                if (!empty($MAP_this->group_arr) && is_array($MAP_this->group_arr)) {
                    reset($MAP_this->group_arr);
                    foreach ($MAP_this->group_arr as $key => $val) {
                        if ($key == $group) {
                            ### what remote group(s) is this group mapped to?
                            foreach ($val as $remote_group => $add) {
                                if (!empty($add) && $MAP_this->group_rank[$key]['rank'] > $rank) {
                                    $MAP_this->status = $add;
                                    $rank = $MAP_this->group_rank[$key]['rank'];
                                }
                            }
                        }
                    }
                }
            }
            $result->MoveNext();
        }
        ### Update the remote account:
        $dbm = new db_mapping();
        $db2 = $dbm->DB_connect(false, $MAP_this->map['map']);
        eval('@$db_prefix = DB2_PREFIX' . strtoupper($MAP_this->map['map']) . ';');
        $sql = "UPDATE " . $db_prefix . "" . $MAP_this->map['account_map_field'] . ' SET ' . $MAP_this->map['account_status_field'] . " = " . $db2->qstr($MAP_this->status) . " WHERE " . $MAP_this->map['account_fields']['id']['map_field'] . " = " . $db2->qstr($remote_account_id);
        $group_result = $db2->Execute($sql);
        if ($group_result === false) {
            global $C_debug;
            $C_debug->error('db_mapping.inc.php', 'MAP_account_group_sync_status', $db->ErrorMsg());
            return;
        }
        return $remote_account_id;
    }
Example #6
0
 function login($account_id)
 {
     # Get the remote account details:
     $db =& DB();
     $sql = 'SELECT username FROM ' . AGILE_DB_PREFIX . 'account WHERE
                 id      = ' . $db->qstr($account_id) . ' AND
                 site_id = ' . $db->qstr(DEFAULT_SITE);
     $result = $db->Execute($sql);
     if ($result === false) {
         global $C_debug;
         $C_debug->error('db_mapping.inc.php', 'login', $db->ErrorMsg());
         return;
     }
     $username = $result->fields['username'];
     ### Get the remote account id from the username
     $dbm = new db_mapping();
     $db2 = $dbm->DB_connect(false, $this->map['map']);
     eval('@$db_prefix = DB2_PREFIX' . strtoupper($this->map['map']) . ';');
     $sql = 'SELECT user_id,user_pass FROM flyspray_users
                 WHERE user_name = ' . $db2->qstr($username);
     $result = $db2->Execute($sql);
     if ($result === false) {
         global $C_debug;
         echo $db2->ErrorMsg();
         $C_debug->error('db_mapping.inc.php', 'login', $db2->ErrorMsg());
         return;
     }
     $remote_account_id = $result->fields['user_id'];
     $remote_user_pass = $result->fields['user_pass'];
     #session_start();
     setcookie('flyspray_userid', $remote_account_id, time() + 60 * 60 * 24 * 30, "/");
     setcookie('flyspray_passhash', crypt("{$remote_user_pass}", "4t6dcHiefIkeYcn48B"), time() + 60 * 60 * 24 * 30, "/");
     return true;
 }
Example #7
0
    function MAP_account_delete($account_id, $username, $MAP_this)
    {
        global $C_debug;
        ### Get the remote account id from the username
        $dbm = new db_mapping();
        $db2 = $dbm->DB_connect(false, $MAP_this->map['map']);
        eval('@$db_prefix = DB2_PREFIX' . strtoupper($MAP_this->map['map']) . ';');
        $sql = 'SELECT userid FROM ' . $db_prefix . 'user
				WHERE username = '******'vBulletin_3.php', 'MAP_account_delete (1)', $db2->ErrorMsg() . '  ' . $sql);
            return false;
        }
        $vb_user_id = $result->fields['userid'];
        # Suspend the user user:
        $sql = "UPDATE " . $db_prefix . "user SET usergroupid = '1' WHERE userid =  " . $db2->qstr($vb_user_id);
        $result = $db2->Execute($sql);
        if ($result === false) {
            $C_debug->error('vBulletin_3.php', 'MAP_account_delete (2)', $db2->ErrorMsg() . '  ' . $sql);
        }
    }
    function login($account_id, $cookie_name)
    {
        ### Get the username login/account creation:
        global $VAR;
        @($username = $VAR['_username']);
        if (empty($username)) {
            @($username = $VAR['account_username']);
        }
        ### Get the cookie-string value from Mantis:
        $dbm = new db_mapping();
        $db = $dbm->DB_connect(false, $this->map['map']);
        eval('@$db_prefix = DB2_PREFIX' . strtoupper($this->map['map']) . ';');
        $sql = 'SELECT cookie_string FROM ' . $db_prefix . '_user_table WHERE
	        			username ='******'db_mapping.inc.php', 'Map_account_logout_add_account_session', $db->ErrorMsg());
            $smarty->assign('db_mapping_result', $db->ErrorMsg());
            return;
        }
        # Create/Update the cookie
        $string = $result->fields['cookie_string'];
        return setcookie($cookie_name, $string, 0, '/');
    }