|
@@ -59,7 +59,7 @@ public final class Utils {
|
|
}
|
|
}
|
|
|
|
|
|
static func getIconCenterAnim2() -> String? {
|
|
static func getIconCenterAnim2() -> String? {
|
|
- UserDefaults.standard.string(forKey: "pb_fb_icon_center_self_mode2") ?? "https://nexilis.io/dashboardv2/uploads/logofloat/525_411217560576.gif"
|
|
|
|
|
|
+ UserDefaults.standard.string(forKey: "pb_fb_icon_center_self_mode2") ?? Utils.getURLBase() + "get_file_from_path?img=525_411217560576.gif"
|
|
}
|
|
}
|
|
|
|
|
|
static func setIconCenterAnim4(value: String){
|
|
static func setIconCenterAnim4(value: String){
|
|
@@ -67,7 +67,7 @@ public final class Utils {
|
|
}
|
|
}
|
|
|
|
|
|
static func getIconCenterAnim4() -> String? {
|
|
static func getIconCenterAnim4() -> String? {
|
|
- UserDefaults.standard.string(forKey: "pb_fb_icon_center_self_mode4") ?? "https://nexilis.io/dashboardv2/uploads/logofloat/semut1.gif"
|
|
|
|
|
|
+ UserDefaults.standard.string(forKey: "pb_fb_icon_center_self_mode4") ?? Utils.getURLBase() + "get_file_from_path?img=semut1.gif"
|
|
}
|
|
}
|
|
|
|
|
|
static func setURLFirstTab(value: String) {
|
|
static func setURLFirstTab(value: String) {
|
|
@@ -225,7 +225,7 @@ public final class Utils {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- static func getURLBase() -> String? {
|
|
|
|
|
|
+ static func getURLBase() -> String {
|
|
return UserDefaults.standard.string(forKey: "app_builder_url_base") ?? "https://nexilis.io/"
|
|
return UserDefaults.standard.string(forKey: "app_builder_url_base") ?? "https://nexilis.io/"
|
|
}
|
|
}
|
|
|
|
|
|
@@ -234,7 +234,7 @@ public final class Utils {
|
|
}
|
|
}
|
|
|
|
|
|
static func getUrlDock() -> String? {
|
|
static func getUrlDock() -> String? {
|
|
- return Utils.getURLBase()! + "dashboardv2/uploads/logofloat/" + Utils.getIconDock()
|
|
|
|
|
|
+ return Utils.getURLBase() + "get_file_from_path?img=" + Utils.getIconDock()
|
|
}
|
|
}
|
|
|
|
|
|
static func setDefaultCC(value: String){
|
|
static func setDefaultCC(value: String){
|
|
@@ -269,7 +269,162 @@ public final class Utils {
|
|
return UserDefaults.standard.string(forKey: "fb_item_with_bg") ?? "1"
|
|
return UserDefaults.standard.string(forKey: "fb_item_with_bg") ?? "1"
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ static func setDomainOpr(value: String){
|
|
|
|
+ UserDefaults.standard.set(value, forKey: "domain_opr")
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ static func getDomainOpr() -> String {
|
|
|
|
+ return UserDefaults.standard.string(forKey: "domain_opr") ?? "https://nexilis.io/"
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ static func setIpPortOpr(value: String){
|
|
|
|
+ UserDefaults.standard.set(value, forKey: "ip_opr")
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ static func getIpOpr() -> String {
|
|
|
|
+ return UserDefaults.standard.string(forKey: "ip_opr") ?? "34.101.172.194:42823"
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ static func setHarcodedIp(value: String){
|
|
|
|
+ UserDefaults.standard.set(value, forKey: "harcoded_ip")
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ static func getHarcodedIp() -> String {
|
|
|
|
+ return UserDefaults.standard.string(forKey: "harcoded_ip") ?? ""
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ static func setUserAgent(value: String){
|
|
|
|
+ UserDefaults.standard.set(value, forKey: "user_agent")
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static func getUserAgent() -> String {
|
|
|
|
+ return UserDefaults.standard.string(forKey: "user_agent") ?? "easySoftIndonesia"
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static func fetchDataWithCookiesAndUserAgent(from url: URL, completion: @escaping (Data?, URLResponse?, Error?) -> ()) {
|
|
|
|
+ var request = URLRequest(url: url)
|
|
|
|
+ request.httpMethod = "GET"
|
|
|
|
+ request.setValue(Utils.getUserAgent(), forHTTPHeaderField: "User-Agent")
|
|
|
|
+ let cookies = HTTPCookieStorage.shared.cookies ?? []
|
|
|
|
+ if let cookieHeader = HTTPCookie.requestHeaderFields(with: cookies)["Cookie"] {
|
|
|
|
+// print("listCookiee: \(cookieHeader)")
|
|
|
|
+ request.setValue(cookieHeader, forHTTPHeaderField: "Cookie")
|
|
|
|
+ }
|
|
|
|
+ let task = URLSession.shared.dataTask(with: request, completionHandler: completion)
|
|
|
|
+ task.resume()
|
|
|
|
+ }
|
|
|
|
+
|
|
public static var inTabChats = false
|
|
public static var inTabChats = false
|
|
|
|
+
|
|
|
|
+ private static let I_BB = 48 // 0
|
|
|
|
+ private static let I_BBT_1 = 57 // 9
|
|
|
|
+ private static let I_BAT_1 = 65 // A
|
|
|
|
+ private static let I_BBT_2 = 90 // Z
|
|
|
|
+ private static let I_BAT_2 = 97 // a
|
|
|
|
+ private static let I_BA = 122 // z
|
|
|
|
+
|
|
|
|
+ private static let IC_BB = 33 // !
|
|
|
|
+ private static let IC_BBT_1 = 47 // /
|
|
|
|
+ private static let IC_BAT_1 = 58 // :
|
|
|
|
+ private static let IC_BBT_2 = 64 // @
|
|
|
|
+ private static let IC_BAT_2 = 91 // [
|
|
|
|
+ private static let IC_BBT_3 = 96 // @
|
|
|
|
+ private static let IC_BAT_3 = 123 // [
|
|
|
|
+ private static let IC_BA = 126 // `
|
|
|
|
+
|
|
|
|
+ private static var icIGNORE = Set<Int>()
|
|
|
|
+
|
|
|
|
+ private static func initIcIgnore() {
|
|
|
|
+ icIGNORE.insert(10)// \r
|
|
|
|
+ icIGNORE.insert(13)// \n
|
|
|
|
+ icIGNORE.insert(32)// <space>
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static func decrypt(str: String) -> String {
|
|
|
|
+ var arr: [Character]
|
|
|
|
+ var iRandom = 0
|
|
|
|
+ var sDecrypt: String
|
|
|
|
+ iRandom = Int(str.substring(from: 0, to: 0)) ?? 0
|
|
|
|
+ sDecrypt = getPalindrom(str: str.substring(from: 1, to: nil))
|
|
|
|
+ arr = Array(sDecrypt)
|
|
|
|
+ for i in 0..<arr.count {
|
|
|
|
+ if (isSpecialChar(ch: arr[i])) {
|
|
|
|
+ arr[i] = getBeforecChar(ch: arr[i], inc: iRandom)
|
|
|
|
+ } else {
|
|
|
|
+ arr[i] = getBeforeChar(ch: arr[i], inc: iRandom)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return String(arr)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static func isSpecialChar(ch: Character) -> Bool {
|
|
|
|
+ let ch = Int(ch.asciiValue ?? 0)
|
|
|
|
+ return (ch >= IC_BB && ch <= IC_BBT_1) || (ch >= IC_BAT_1 && ch <= IC_BBT_2) || (ch >= IC_BAT_2 && ch <= IC_BBT_3) || (ch >= IC_BAT_3 && ch <= IC_BA)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static func getPalindrom(str: String) -> String {
|
|
|
|
+ let arr: [Character] = Array(str)
|
|
|
|
+ var arr2: [Character] = Array(arr)
|
|
|
|
+
|
|
|
|
+ for i in 0..<arr.count {
|
|
|
|
+ arr2[i] = arr[arr.count - (i + 1)]
|
|
|
|
+ }
|
|
|
|
+ return String(arr2)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static func getBeforeChar(ch: Character, inc: Int) -> Character {
|
|
|
|
+ if icIGNORE.isEmpty {
|
|
|
|
+ initIcIgnore()
|
|
|
|
+ }
|
|
|
|
+ var iAscii = ch
|
|
|
|
+ let iAsciiBefore = iAscii
|
|
|
|
+
|
|
|
|
+ if (icIGNORE.contains(Int(iAscii.asciiValue ?? 0))) {
|
|
|
|
+ return iAscii;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if Int(iAscii.asciiValue ?? 0) > I_BA || Int(iAscii.asciiValue ?? 0) < I_BB {
|
|
|
|
+ } else {
|
|
|
|
+ if !icIGNORE.contains(Int(iAscii.asciiValue ?? 0)) {
|
|
|
|
+ iAscii = Character(UnicodeScalar(Int(iAscii.asciiValue ?? 0) - inc)!)
|
|
|
|
+ if (I_BAT_1 > Int(iAscii.asciiValue ?? 0) && Int(iAsciiBefore.asciiValue ?? 0) >= I_BAT_1) {
|
|
|
|
+ iAscii = Character(UnicodeScalar((I_BBT_1 + 1) - (I_BAT_1 - Int(iAscii.asciiValue ?? 0)))!)
|
|
|
|
+ }
|
|
|
|
+ if (I_BAT_2 > Int(iAscii.asciiValue ?? 0) && Int(iAsciiBefore.asciiValue ?? 0) >= I_BAT_2) {
|
|
|
|
+ iAscii = Character(UnicodeScalar((I_BBT_2 + 1) - (I_BAT_2 - Int(iAscii.asciiValue ?? 0)))!)
|
|
|
|
+ }
|
|
|
|
+ if (Int(iAscii.asciiValue ?? 0) < I_BB) {
|
|
|
|
+ iAscii = Character(UnicodeScalar((I_BA + 1) + (Int(iAscii.asciiValue ?? 0) - I_BB))!)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return iAscii
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static func getBeforecChar(ch: Character, inc: Int) -> Character {
|
|
|
|
+ var iAscii = ch
|
|
|
|
+ let iAsciiBefore = iAscii
|
|
|
|
+ if (Int(iAscii.asciiValue ?? 0) > IC_BA || Int(iAscii.asciiValue ?? 0) < IC_BB) {
|
|
|
|
+ } else {
|
|
|
|
+ iAscii = Character(UnicodeScalar(Int(iAscii.asciiValue ?? 0) - inc)!)
|
|
|
|
+ if (Int(iAscii.asciiValue ?? 0) < IC_BB) {
|
|
|
|
+ iAscii = Character(UnicodeScalar((IC_BA + 1) + (Int(iAscii.asciiValue ?? 0) - IC_BB))!)
|
|
|
|
+ if (Int(iAscii.asciiValue ?? 0) < IC_BAT_3 && Int(iAscii.asciiValue ?? 0) > IC_BBT_3) {
|
|
|
|
+ iAscii = Character(UnicodeScalar((IC_BBT_3 + 1) - (IC_BAT_3 - Int(iAscii.asciiValue ?? 0)))!)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (IC_BAT_3 > Int(iAscii.asciiValue ?? 0) && Int(iAsciiBefore.asciiValue ?? 0) >= IC_BAT_3) {
|
|
|
|
+ iAscii = Character(UnicodeScalar((IC_BBT_3 + 1) - (IC_BAT_3 - Int(iAscii.asciiValue ?? 0)))!)
|
|
|
|
+ }
|
|
|
|
+ if (IC_BAT_2 > Int(iAscii.asciiValue ?? 0) && Int(iAsciiBefore.asciiValue ?? 0) >= IC_BAT_2) {
|
|
|
|
+ iAscii = Character(UnicodeScalar((IC_BBT_2 + 1) - (IC_BAT_2 - Int(iAscii.asciiValue ?? 0)))!)
|
|
|
|
+ }
|
|
|
|
+ if (IC_BAT_1 > Int(iAscii.asciiValue ?? 0) && Int(iAsciiBefore.asciiValue ?? 0) >= IC_BAT_1) {
|
|
|
|
+ iAscii = Character(UnicodeScalar((IC_BBT_1 + 1) - (IC_BAT_1 - Int(iAscii.asciiValue ?? 0)))!)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return iAscii
|
|
|
|
+ }
|
|
}
|
|
}
|
|
public extension UIImage {
|
|
public extension UIImage {
|
|
var jpeg: Data? { jpegData(compressionQuality: 1) } // QUALITY min = 0 / max = 1
|
|
var jpeg: Data? { jpegData(compressionQuality: 1) } // QUALITY min = 0 / max = 1
|