Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -402,6 +402,20 @@ custom_css = """
|
|
| 402 |
.url-test-btn:hover {
|
| 403 |
background: #4338ca !important;
|
| 404 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 405 |
"""
|
| 406 |
|
| 407 |
# Create Gradio interface
|
|
@@ -418,6 +432,39 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as demo:
|
|
| 418 |
</div>
|
| 419 |
""")
|
| 420 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 421 |
with gr.Row():
|
| 422 |
with gr.Column(scale=1):
|
| 423 |
# Input Section
|
|
@@ -427,25 +474,25 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as demo:
|
|
| 427 |
url_input = gr.Textbox(
|
| 428 |
label="Enter your URL:",
|
| 429 |
placeholder="Paste URL here...",
|
| 430 |
-
value="https://
|
| 431 |
lines=3
|
| 432 |
)
|
| 433 |
|
| 434 |
single_ip_input = gr.Textbox(
|
| 435 |
label="Single IP Address:",
|
| 436 |
-
placeholder="e.g., 192.168.1.
|
| 437 |
max_lines=1
|
| 438 |
)
|
| 439 |
|
| 440 |
multiple_ips_input = gr.Textbox(
|
| 441 |
label="Multiple IP Addresses:",
|
| 442 |
-
placeholder="Enter one IP per line\n192.168.1.
|
| 443 |
lines=4
|
| 444 |
)
|
| 445 |
|
| 446 |
test_connectivity = gr.Checkbox(
|
| 447 |
label="π Test URL connectivity after swapping",
|
| 448 |
-
value=
|
| 449 |
info="Test if the modified URLs are accessible"
|
| 450 |
)
|
| 451 |
|
|
@@ -529,6 +576,20 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as demo:
|
|
| 529 |
# Instructions
|
| 530 |
with gr.Accordion("π How It Works", open=False):
|
| 531 |
gr.Markdown("""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 532 |
**Step-by-step process:**
|
| 533 |
1. **Paste your URL** containing IP addresses
|
| 534 |
2. **Enter IP address(es)** - single or multiple (one per line)
|
|
@@ -657,7 +718,7 @@ def generate_url_buttons(modified_url, single_ip, multiple_ips):
|
|
| 657 |
|
| 658 |
# Generate buttons HTML
|
| 659 |
buttons_html = '<div class="url-test-buttons">'
|
| 660 |
-
buttons_html += '<strong>Test URLs:</strong><br>'
|
| 661 |
|
| 662 |
for i, (url, ip) in enumerate(zip(urls, ips)):
|
| 663 |
button_id = f"url-btn-{i}"
|
|
|
|
| 402 |
.url-test-btn:hover {
|
| 403 |
background: #4338ca !important;
|
| 404 |
}
|
| 405 |
+
.example-box {
|
| 406 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 407 |
+
color: white;
|
| 408 |
+
padding: 15px;
|
| 409 |
+
border-radius: 10px;
|
| 410 |
+
margin: 10px 0;
|
| 411 |
+
}
|
| 412 |
+
.example-steps {
|
| 413 |
+
background: #f8f9fa;
|
| 414 |
+
border-left: 4px solid #4f46e5;
|
| 415 |
+
padding: 15px;
|
| 416 |
+
margin: 15px 0;
|
| 417 |
+
border-radius: 0 8px 8px 0;
|
| 418 |
+
}
|
| 419 |
"""
|
| 420 |
|
| 421 |
# Create Gradio interface
|
|
|
|
| 432 |
</div>
|
| 433 |
""")
|
| 434 |
|
| 435 |
+
# Example Section
|
| 436 |
+
with gr.Accordion("π― Real Example - Try This!", open=True):
|
| 437 |
+
gr.Markdown("""
|
| 438 |
+
<div class="example-box">
|
| 439 |
+
<h3>π Quick Start Example</h3>
|
| 440 |
+
<p><strong>We've pre-loaded a real URL for you to test:</strong></p>
|
| 441 |
+
</div>
|
| 442 |
+
|
| 443 |
+
<div class="example-steps">
|
| 444 |
+
<h4>π Try This Example:</h4>
|
| 445 |
+
<ol>
|
| 446 |
+
<li><strong>URL is already loaded</strong> below (contains IP <code>51.158.55.104</code>)</li>
|
| 447 |
+
<li><strong>Enter new IPs</strong> in either field:
|
| 448 |
+
<ul>
|
| 449 |
+
<li>Single IP: <code>192.168.1.100</code></li>
|
| 450 |
+
<li>Multiple IPs (one per line):
|
| 451 |
+
<pre>192.168.1.100
|
| 452 |
+
10.0.0.50
|
| 453 |
+
172.16.0.25</pre>
|
| 454 |
+
</li>
|
| 455 |
+
</ul>
|
| 456 |
+
</li>
|
| 457 |
+
<li><strong>Check "Test connectivity"</strong> to automatically test URLs</li>
|
| 458 |
+
<li><strong>Click "Swap IP(s)"</strong> to generate and test new URLs</li>
|
| 459 |
+
<li><strong>Test live</strong> using the iframe preview buttons</li>
|
| 460 |
+
</ol>
|
| 461 |
+
</div>
|
| 462 |
+
|
| 463 |
+
<div style="background: #fffbeb; padding: 10px; border-radius: 5px; border-left: 4px solid #f59e0b;">
|
| 464 |
+
<strong>π‘ What happens:</strong> The tool will replace <code>51.158.55.104</code> with your new IP(s) in both the main URL AND the encoded 'r' parameter!
|
| 465 |
+
</div>
|
| 466 |
+
""")
|
| 467 |
+
|
| 468 |
with gr.Row():
|
| 469 |
with gr.Column(scale=1):
|
| 470 |
# Input Section
|
|
|
|
| 474 |
url_input = gr.Textbox(
|
| 475 |
label="Enter your URL:",
|
| 476 |
placeholder="Paste URL here...",
|
| 477 |
+
value="https://51.158.55.104/__cpi.php?s=UkQ2YXlSaWJuc3ZoeGR2dG04WW9LamZUQTBwaG1wTzM1aCtMajhkTXRaV1BwQ3lCSG0vWmxUV2lkVDVlc2pveHFuM0RaY0ZDaUgwNzdkMnFMWVJnY1pzSFNXYXB6c1EzRXpqVFViNzBqSlE9&r=aHR0cHM6Ly81MS4xNTguNTUuMTA0L3B0cC8%2FdXNlcj1wbGF0Zm9ybXNpbmNvbWUmc3ViaWQ9MTMxMzcwJl9fY3BvPWFIUjBjSE02THk5aFpHNWhaR1V1Ym1WMA%3D%3D&__cpo=1",
|
| 478 |
lines=3
|
| 479 |
)
|
| 480 |
|
| 481 |
single_ip_input = gr.Textbox(
|
| 482 |
label="Single IP Address:",
|
| 483 |
+
placeholder="e.g., 192.168.1.100",
|
| 484 |
max_lines=1
|
| 485 |
)
|
| 486 |
|
| 487 |
multiple_ips_input = gr.Textbox(
|
| 488 |
label="Multiple IP Addresses:",
|
| 489 |
+
placeholder="Enter one IP per line\n192.168.1.100\n10.0.0.50\n172.16.0.25",
|
| 490 |
lines=4
|
| 491 |
)
|
| 492 |
|
| 493 |
test_connectivity = gr.Checkbox(
|
| 494 |
label="π Test URL connectivity after swapping",
|
| 495 |
+
value=True,
|
| 496 |
info="Test if the modified URLs are accessible"
|
| 497 |
)
|
| 498 |
|
|
|
|
| 576 |
# Instructions
|
| 577 |
with gr.Accordion("π How It Works", open=False):
|
| 578 |
gr.Markdown("""
|
| 579 |
+
## π― Real Example Walkthrough
|
| 580 |
+
|
| 581 |
+
**Original URL Analysis:**
|
| 582 |
+
```
|
| 583 |
+
https://51.158.55.104/__cpi.php?s=...&r=aHR0cHM6Ly81MS4xNTguNTUuMTA0L3B0cC8...
|
| 584 |
+
```
|
| 585 |
+
|
| 586 |
+
**What the tool does:**
|
| 587 |
+
1. **Extracts main IP**: `51.158.55.104`
|
| 588 |
+
2. **Decodes 'r' parameter**: Contains another URL with the same IP
|
| 589 |
+
3. **Replaces IP in both places** with your new IP(s)
|
| 590 |
+
4. **Re-encodes 'r' parameter** with new IP
|
| 591 |
+
5. **Generates final URL** with swapped IPs
|
| 592 |
+
|
| 593 |
**Step-by-step process:**
|
| 594 |
1. **Paste your URL** containing IP addresses
|
| 595 |
2. **Enter IP address(es)** - single or multiple (one per line)
|
|
|
|
| 718 |
|
| 719 |
# Generate buttons HTML
|
| 720 |
buttons_html = '<div class="url-test-buttons">'
|
| 721 |
+
buttons_html += '<strong>Test URLs in Live Preview:</strong><br>'
|
| 722 |
|
| 723 |
for i, (url, ip) in enumerate(zip(urls, ips)):
|
| 724 |
button_id = f"url-btn-{i}"
|