Exemplo n.º 1
0
function rad_add_mac($mac_addr, $password, $expiredate, $configValues)
{
    // add a mac address authentication entry to radius radcheck table
    // mac address authentication requires no password from users for auto login
    // $password is value used in coova-chilli config option HS_MACPASSWD=macpass
    // $mac_addr format example 00:11:22:33:44:55 or 00-11-22-33-44-55
    // $expiredate is in timestamp format seconds since Jan 01 1970 like seen from time()
    // $configValues is from config.php $configValues array values
    // returns values the same as rad_update_users
    $new_mac = preg_replace("/:/", "-", $mac_addr);
    writelog("new_mac = " . $new_mac . "\n");
    rad_update_user($new_mac, $password, $expiredate, $configValues);
}
Exemplo n.º 2
0
function update_account($customers_email, $mysql, $configValues)
{
    writelog("update_account starte \n");
    //$mysql = new_mysql($username,$password,$database,"localhost");
    $query = "SELECT * FROM customers WHERE customers_email_address='{$customers_email}'";
    $result = get_query($query, $mysql);
    if ($result == 0) {
        //echo "<br> Failed Freenet customers_email not found <br>";
        mysql_close();
        writelog("customers_email not found \n");
        return 0;
    }
    $expire = mysql_result($result, 0, "customers_date_account_expires");
    $password = mysql_result($result, 0, "customers_password");
    $timenow = time();
    $expire = strtotime($expire);
    $newexpire = $expire;
    if ($timenow > $expire) {
        $newexpire = $timenow;
    }
    // check account for pending orders status
    $query = "SELECT * FROM orders WHERE customers_email_address='{$customers_email}' AND orders_status = 1";
    $result = get_query($query, $mysql);
    if ($result == 0) {
        // check for promotion package before we give up
        $query = "SELECT * FROM customers WHERE customers_email_address='{$customers_email}' AND customers_promotion_received IS NULL";
        $result = get_query($query, $mysql);
        //$result =mysql_query($query);
        // $num =mysql_numrows($result);
        if ($result == 0) {
            //echo "<b><center> Sorry $first your account has expired. Please go to the Freenet store to correct</center></b><br>";
            mysql_close();
            //$_SESSION['code']= -2;
            writelog(" expired with no promotion \n");
            return $expire;
        }
        // they just stared a new account so give them the 1 day free package 24 hours  = 86400 secounds
        $newexpire = time() + 86400;
        $query = "UPDATE customers SET customers_date_account_expires=FROM_UNIXTIME({$newexpire}) WHERE customers_email_address='{$customers_email}'";
        get_query($query, $mysql);
        //mysql_query($query);
        $query = "UPDATE customers SET customers_promotion_received=NOW() WHERE customers_email_address='{$customers_email}'";
        get_query($query, $mysql);
        //mysql_query($query);
        $_SESSION['expire'] = date("F j, Y, g:i a", $newexpire);
        $_SESSION['promotion'] = 1;
        //echo "Two day promotion package has now been credited to your account<br> Your account now expires: $newexpire<br>";
        $_SESSION['code'] = 1;
        $_SESSION['loggedin'] = 1;
        mysql_close();
        rad_update_user($customers_email, $password, $newexpire, $configValues);
        writelog("update_account completed \n");
        return $newexpire;
    }
    // process new orders
    $num = mysql_numrows($result);
    // echo "<br>num = $num <br>";
    // echo "<br> Processing new orders <br>";
    $i = 0;
    // products bytes expire order process not implemented yet but commented bellow might work
    //$new_bytes = 0;
    while ($i < $num) {
        //$date_purchased=mysql_result($result,$i,"date_purchased");
        //echo "date of purchased = $date_purchased <br>";
        $orders_id = mysql_result($result, $i, "orders_id");
        //echo "orders_id = $orders_id <br>";
        $query = "SELECT * FROM orders_products WHERE orders_id='{$orders_id}'";
        //echo $query ;
        $result2 = get_query($query, $mysql);
        $products_id = mysql_result($result2, 0, "products_id");
        //echo "products_id = $products_id <br>";
        $products_quantity = mysql_result($result2, 0, "products_quantity");
        $query = "SELECT * FROM products WHERE products_id='{$products_id}'";
        $result2 = get_query($query, $mysql);
        $products_hours_to_expire = mysql_result($result2, 0, "products_hours_to_expire");
        //$products_bytes_to_expire=mysql_result($result2,0,"products_bytes_to_expire");
        //$new_bytes = $new_bytes + $products_bytes_to_expire;
        $newexpire = $newexpire + $products_hours_to_expire * $products_quantity * 60 * 60;
        //echo "products_hours_to_expire = $products_hours_to_expire <br>";
        $query = "UPDATE orders SET orders_status=2  WHERE customers_email_address='{$customers_email}' AND orders_status = 1 AND orders_id ='{$orders_id}'";
        get_query($query, $mysql);
        $i++;
    }
    if ($newexpire > $expire) {
        //echo "newexpire = $newexpire <br>";
        $query = "UPDATE customers SET customers_date_account_expires=FROM_UNIXTIME({$newexpire}) WHERE customers_email_address='{$customers_email}'";
        get_query($query, $mysql);
        //mysql_query($query);
        $query = "UPDATE customers SET customers_promotion_received=NOW() WHERE customers_email_address='{$customers_email}'";
        get_query($query, $mysql);
        //$query = "UPDATE customers SET customers_bytes_ordered=customers_bytes_ordered+$new_bytes WHERE customers_email_address='$customers_email'";
        mysql_close();
        rad_update_user($customers_email, $password, $newexpire, $configValues);
        return $newexpire;
    }
    mysql_close();
    return $expire;
}