private void updateAccountInfo(final Account account, final Browser br) { if (account == null || br == null) { return; } AccountInfo ai = account.getAccountInfo(); if (ai == null) { ai = new AccountInfo(); account.setAccountInfo(ai); } /* let hoster report traffic limit reached! */ // ai.setSpecialTraffic(true); /* reset expired flag */ ai.setExpired(false); ai.setValidUntil(-1); account.setValid(true); ai.setUnlimitedTraffic(); try { final String[][] matches = br.getRegex("(\\w+)=([^\r^\n]+)").getMatches(); final HashMap<String, String> data = this.getMap(matches); final long rapids = Long.parseLong(data.get("rapids")); /* account infos */ ai.setFilesNum(Long.parseLong(data.get("curfiles"))); ai.setPremiumPoints(Long.parseLong(data.get("rapids"))); ai.setUsedSpace(Long.parseLong(data.get("curspace"))); boolean autoextend = "1".equals(data.get("autoextend")); final String billedUntilTime = data.get("billeduntil"); final String serverTimeString = data.get("servertime"); long nextBill = 0; if (billedUntilTime != null && serverTimeString != null) { /* next billing in */ nextBill = Long.parseLong(billedUntilTime) - Long.parseLong(serverTimeString); if (nextBill <= 0) { String possible = ""; if (autoextend) { long days = (rapids / 495) * 30; if (days > 0) { possible = "(enough rapids for " + days + " days RapidPro left)"; } } ai.setStatus("No RapidPro" + possible); ai.setExpired(true); account.setValid(false); } else { if (autoextend) { long days = (rapids / 495) * 30; if (days > 0) { nextBill = nextBill + (days * 24 * 60); } } final String left = Formatter.formatSeconds(nextBill, false); ai.setValidUntil((Long.parseLong(serverTimeString) + nextBill) * 1000l); ai.setStatus("Valid for " + left); } } } catch (final Throwable e) { logger.severe("RS-API change detected, please inform support!"); } }
@Override public AccountInfo fetchAccountInfo(Account account) throws Exception { AccountInfo ai = new AccountInfo(); try { login(account, true); } catch (PluginException e) { account.setValid(false); return ai; } String hostedFiles = br.getRegex("<td>Files Hosted:</td>[\t\r\n ]+<td>(\\d+)</td>").getMatch(0); if (hostedFiles != null) ai.setFilesNum(Integer.parseInt(hostedFiles)); String space = br.getRegex("<td>Spaced Used:</td>[\t\n\r ]+<td>(.*?) " + PREMIUMLIMIT).getMatch(0); if (space != null) ai.setUsedSpace(space.trim()); account.setValid(true); ai.setUnlimitedTraffic(); ai.setStatus("Premium User"); return ai; }
@Override public AccountInfo fetchAccountInfo(Account account) throws Exception { AccountInfo ai = new AccountInfo(); try { login(account, true); } catch (PluginException e) { account.setValid(false); return ai; } if (!br.getURL().endsWith("/members.php")) br.getPage(COOKIE_HOST + "/members.php"); String expired = getData("Expired\\?"); if (expired != null) { expired = expired.trim(); if (expired.equalsIgnoreCase("No")) ai.setExpired(false); else if (expired.equalsIgnoreCase("Yes")) ai.setExpired(true); } String expires = getData("Package Expire Date"); if (expires != null) { String[] e = expires.split("/"); Calendar cal = new GregorianCalendar( Integer.parseInt("20" + e[2]), Integer.parseInt(e[0]) - 1, Integer.parseInt(e[1])); ai.setValidUntil(cal.getTimeInMillis()); } String create = getData("Register Date"); if (create != null) { String[] c = create.split("/"); Calendar cal = new GregorianCalendar( Integer.parseInt("20" + c[2]), Integer.parseInt(c[0]) - 1, Integer.parseInt(c[1])); ai.setCreateTime(cal.getTimeInMillis()); } String files = getData("Hosted Files"); if (files != null) { ai.setFilesNum(Integer.parseInt(files.trim())); } ai.setStatus("Premium User"); account.setValid(true); return ai; }