e107 plugin function help

Discussion in 'Customization & add-ons' started by gl3nw4rk, Nov 29, 2007.

  1. gl3nw4rk

    gl3nw4rk New Member

    Joined:
    Oct 31, 2007
    Messages:
    2
    hello, i need some help making a function to work within e107 amember plugin for the purpose to use the GET and POST methods to add data into mysql tables.

    The reason for this script is to use with a Loader that i want to activate when the member pays for the subscription and deactivated it when the membership subscription has expired.

    i know that e107cms uses its "member classes" feature to manage the members logins, data and restrictions, but know amember is controling the "member classes" of e107 and i need some help writing this script, even i can pay through paypal to help me doing this.

    This is what i need, a table with 2 fields inside e107 or amember database to use for this reason:

    field 1 - is to be used to store userid that the script will convert from username to the userid generated by amember, and the other field, field 2, is to insert a hardware ID HASH that the Loader is going to POST into the field
    if the user id is activated, so if is not activated, then it doenst let the member use the loader.

    The database table fields names that i need to insert data is USERID and HWID.

    im going to show an example of the script that i want to use with e107 and amember plugin, the following code is to use with vbuletin boards:

    <?php

    error_reporting(E_ALL & ~E_NOTICE);
    define('THIS_SCRIPT', 'login');
    $phrasegroups = array();
    $specialtemplates = array();
    $globaltemplates = array();
    $actiontemplates = array(
    'lostpw' => array(
    'lostpw'
    )
    );

    // ######################### REQUIRE BACK-END ############################
    require_once('./global.php');
    require_once(DIR . '/includes/functions_login.php');

    // #######################################################################
    // ######################## START MAIN SCRIPT ############################
    // #######################################################################

    $vbulletin->input->clean_gpc('r', 'a', TYPE_STR);

    if (empty($_REQUEST['do']) AND empty($vbulletin->GPC['a']))
    {
    exec_header_redirect($vbulletin->options['forumhome'] . '.php');
    }


    if ($_POST['do'] == 'login')
    {
    $vbulletin->input->clean_array_gpc('p', array(
    'vb_login_username' => TYPE_STR,
    'vb_login_password' => TYPE_STR,
    'vb_login_md5password' => TYPE_STR,
    'vb_login_md5password_utf' => TYPE_STR,
    'postvars' => TYPE_STR,
    'cookieuser' => TYPE_BOOL,
    'logintype' => TYPE_STR,
    'cssprefs' => TYPE_STR,
    'HWID' => TYPE_STR,
    ));

    // can the user login?
    $strikes = verify_strike_status($vbulletin->GPC['vb_login_username']);

    if ($vbulletin->GPC['vb_login_username'] == '')
    {
    echo 'LOGIN_BAD_USERNAME';
    }

    if (!verify_authentication($vbulletin->GPC['vb_login_username'], $vbulletin->GPC['vb_login_password'], $vbulletin->GPC['vb_login_md5password'], $vbulletin->GPC['vb_login_md5password_utf'], $vbulletin->GPC['cookieuser'], true))
    {
    // this is the bad password section. Should we enable strikes? like 5 bad password attemps, and your ID is locked?
    echo '0';
    } else {
    // THIS IS THE PASSWORD PASSED AUTHENTICATION SECTION
    // create new session
    process_new_login($vbulletin->GPC['logintype'], $vbulletin->GPC['cookieuser'], $vbulletin->GPC['cssprefs']);
    //Read VIP UserTitle
    $userid = $vbulletin->userinfo['userid'];
    $getuserstats = $db->query("SELECT * FROM " . TABLE_PREFIX . "user WHERE userid = $userid");
    while ($userstats = $db->fetch_array($getuserstats)) {
    $title = $userstats['usertitle'];
    }

    // This is the subscription area, we need to put the titles we dont want access to inside the switch/case
    $i = 0;
    switch ($title) {
    case "Junior Member":
    $i = 1;
    break;
    case "Banned":
    $i = 1;
    break;
    case "Member":
    $i = 1;
    break;
    }

    if ($i==0) {
    $hardtemp= $db->query_first("SELECT hardwareid FROM hardwareid where userid = $userid");
    $hardwareid=$hardtemp['hardwareid'];
    //Set the GUID if not in the database
    if ($hardwareid == "") {
    if (!trim($vbulletin->GPC['HWID'])=="") {
    $db->query_write("INSERT INTO hardwareid (userid, hardwareid) VALUES ('" . $userid . "','" . $vbulletin->GPC['HWID'] . "')");
    $hardwareid= $vbulletin->GPC['HWID'];
    }
    }

    if ($hardwareid == $vbulletin->GPC['HWID']) {
    echo '3';
    } else {
    echo '2';

    }

    }
    else {
    echo '1';
    }

    }
    }
    ?>

Share This Page