-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlicense_manager.py
More file actions
257 lines (197 loc) · 8.46 KB
/
license_manager.py
File metadata and controls
257 lines (197 loc) · 8.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
"""
SpineRip Trader - License Key Manager
Prevents unauthorized use of PRO features
"""
import os
import json
import hashlib
from datetime import datetime, timedelta
class LicenseManager:
"""Manage license keys and verification"""
def __init__(self):
self.license_file = os.path.join(os.path.dirname(__file__), '.license')
self.master_key = "SPINERIP_MASTER_2026" # Secret key for validation
def generate_license_key(self, email, plan='monthly'):
"""Generate unique license key"""
# Create unique hash from email + timestamp + master key
timestamp = datetime.now().isoformat()
raw = f"{email}{timestamp}{self.master_key}"
hash_obj = hashlib.sha256(raw.encode())
hash_hex = hash_obj.hexdigest()[:16].upper()
# Format: SPINERIP-XXXX-XXXX-XXXX-XXXX
key = f"SPINERIP-{hash_hex[0:4]}-{hash_hex[4:8]}-{hash_hex[8:12]}-{hash_hex[12:16]}"
# Save license
expiration = None if plan == 'lifetime' else (datetime.now() + timedelta(days=30)).isoformat()
license_data = {
'key': key,
'email': email,
'plan': plan,
'activated': datetime.now().isoformat(),
'expiration': expiration,
'status': 'active'
}
self.save_license(license_data)
return key
def save_license(self, license_data):
"""Save license to file"""
with open(self.license_file, 'w') as f:
json.dump(license_data, f, indent=2)
def load_license(self):
"""Load license from file"""
if not os.path.exists(self.license_file):
return None
try:
with open(self.license_file, 'r') as f:
return json.load(f)
except:
return None
def verify_license(self):
"""Verify if license is valid and active"""
license_data = self.load_license()
if not license_data:
return False, "No license found. Please activate PRO subscription."
# Check if expired
if license_data.get('expiration'):
expiration = datetime.fromisoformat(license_data['expiration'])
if datetime.now() > expiration:
return False, f"License expired on {expiration.strftime('%Y-%m-%d')}. Please renew."
# Check if active
if license_data.get('status') != 'active':
return False, "License inactive. Please contact support."
return True, f"✅ PRO Active - {license_data['plan'].title()} Plan"
def activate_license(self, license_key, email):
"""Activate license with key"""
# Validate key format
if not license_key.startswith('SPINERIP-'):
return False, "Invalid license key format"
# In production, verify key with server
# For now, save locally
# Determine plan from key (you'd track this on your end)
plan = 'monthly' # Default
license_data = {
'key': license_key,
'email': email,
'plan': plan,
'activated': datetime.now().isoformat(),
'expiration': (datetime.now() + timedelta(days=30)).isoformat() if plan == 'monthly' else None,
'status': 'active'
}
self.save_license(license_data)
return True, "License activated successfully!"
def deactivate_license(self):
"""Deactivate license (for testing)"""
if os.path.exists(self.license_file):
os.remove(self.license_file)
return True
def get_license_info(self):
"""Get current license information"""
license_data = self.load_license()
if not license_data:
return {
'status': 'inactive',
'plan': 'free',
'message': 'No active license'
}
valid, message = self.verify_license()
return {
'status': 'active' if valid else 'expired',
'plan': license_data.get('plan', 'unknown'),
'email': license_data.get('email'),
'activated': license_data.get('activated'),
'expiration': license_data.get('expiration'),
'message': message
}
def check_license_and_prompt():
"""Check license and prompt if needed"""
manager = LicenseManager()
valid, message = manager.verify_license()
if not valid:
print("\n" + "="*70)
print("🔒 SPINERIP TRADER PRO - LICENSE REQUIRED")
print("="*70 + "\n")
print(f"❌ {message}\n")
print("💰 Upgrade to PRO:")
print(" • Monthly: $19/month")
print(" • Lifetime: $99 one-time\n")
print("💳 Payment: Cash App $JustinHawpetoss7")
print("📧 Email: justinhawpetoss7@gmail.com\n")
print("After payment, you'll receive a license key.")
print("="*70 + "\n")
# Ask if they have a key
response = input("Do you have a license key? (y/n): ").strip().lower()
if response == 'y':
key = input("\nEnter your license key: ").strip()
email = input("Enter your email: ").strip()
success, msg = manager.activate_license(key, email)
if success:
print(f"\n✅ {msg}")
print("🚀 You now have full PRO access!\n")
return True
else:
print(f"\n❌ {msg}")
print("Please contact support: justinhawpetoss7@gmail.com\n")
return False
else:
print("\n👉 Visit: https://github.com/YOURUSERNAME/spinerip-trader")
print(" Or pay via Cash App: $JustinHawpetoss7\n")
return False
print(f"\n✅ {message}\n")
return True
# Command line tool
if __name__ == "__main__":
import sys
manager = LicenseManager()
print("\n" + "="*70)
print("🔑 SPINERIP TRADER - LICENSE MANAGER")
print("="*70 + "\n")
if len(sys.argv) > 1:
command = sys.argv[1].lower()
if command == 'generate':
# Generate new key
email = input("Enter email: ").strip()
plan = input("Plan (monthly/lifetime): ").strip().lower()
if plan not in ['monthly', 'lifetime']:
print("❌ Invalid plan. Use 'monthly' or 'lifetime'")
sys.exit(1)
key = manager.generate_license_key(email, plan)
print(f"\n✅ License Key Generated!\n")
print(f"📧 Email: {email}")
print(f"💎 Plan: {plan.title()}")
print(f"🔑 Key: {key}\n")
print("Send this key to the customer!")
print("="*70 + "\n")
elif command == 'activate':
# Activate license
if len(sys.argv) < 4:
print("Usage: python license_manager.py activate <key> <email>")
sys.exit(1)
key = sys.argv[2]
email = sys.argv[3]
success, message = manager.activate_license(key, email)
print(f"\n{message}\n")
elif command == 'info':
# Show license info
info = manager.get_license_info()
print(f"Status: {info['status'].upper()}")
print(f"Plan: {info['plan'].title()}")
if info.get('email'):
print(f"Email: {info['email']}")
if info.get('activated'):
print(f"Activated: {info['activated']}")
if info.get('expiration'):
print(f"Expires: {info['expiration']}")
print(f"\n{info['message']}\n")
elif command == 'deactivate':
# Deactivate license
manager.deactivate_license()
print("✅ License deactivated\n")
else:
print(f"❌ Unknown command: {command}\n")
print("Available commands:")
print(" generate - Generate new license key")
print(" activate - Activate license with key")
print(" info - Show current license info")
print(" deactivate - Remove license (testing)\n")
else:
# Show current status
check_license_and_prompt()