Opera8 commited on
Commit
2171757
·
verified ·
1 Parent(s): f043da3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +104 -19
app.py CHANGED
@@ -132,7 +132,7 @@ def consume_quota(fingerprint):
132
  return user_record["count"]
133
 
134
  # ==========================================
135
- # 3. سیستم ایمنی (Safety)
136
  # ==========================================
137
  print("Loading Safety Checker...")
138
  safety_classifier = pipeline("image-classification", model="Falconsai/nsfw_image_detection", device=-1)
@@ -443,6 +443,7 @@ async (image) => {
443
 
444
  js_upgrade_func = """() => { window.parent.postMessage({ type: 'NAVIGATE_TO_PREMIUM' }, '*'); }"""
445
 
 
446
  js_global = """
447
  <script>
448
  document.addEventListener('DOMContentLoaded', () => {
@@ -510,31 +511,82 @@ document.addEventListener('DOMContentLoaded', () => {
510
 
511
  init();
512
 
513
- // GPU QUOTA MODAL
514
- window.retryGeneration = function() { document.getElementById('custom-quota-modal')?.remove(); document.getElementById('run-btn')?.click(); };
515
- window.closeErrorModal = function() { document.getElementById('custom-quota-modal')?.remove(); };
 
 
 
 
 
 
 
 
 
 
516
 
517
  const showQuotaModal = () => {
518
  if (document.getElementById('custom-quota-modal')) return;
 
519
  const modalHtml = `
520
  <div id="custom-quota-modal" style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); backdrop-filter: blur(5px); z-index: 99999; display: flex; align-items: center; justify-content: center; font-family: 'Vazirmatn', sans-serif;">
521
- <div class="ip-reset-guide-container" style="background: rgba(255, 255, 255, 0.98); padding: 20px; border-radius: 16px; width: 90%; max-width: 420px; text-align: right; direction: rtl;">
522
- <h2 style="color: #2d3748; margin-bottom: 10px;">یک قدم تا ساخت تصاویر جدید</h2>
523
- <p style="color: #4a5568; font-size: 0.9rem;">نیازمند تغییر نقطه دستیابی (IP) هستید.</p>
524
- <div style="background: #FFF0E5; padding: 12px; border-radius: 8px; margin: 10px 0; border: 1px solid #FF8533;">
525
- <p style="margin:0; font-size: 0.85rem; color: #992900;">از اینترنت سیم‌کارت استفاده کنید، VPN را خاموش کرده، نقطه دستیابی را طبق ویدیو تغییر دهید و «تلاش مجدد» بزنید.</p>
 
 
 
 
 
 
 
 
 
526
  </div>
527
- <div style="text-align:center; margin: 15px 0;">
528
- <button onclick="parent.postMessage({ type: 'NAVIGATE_TO_URL', url: '#/nav/online/news/getSingle/1149635/eyJpdiI6IjhHVGhPQWJwb3E0cjRXbnFWTW5BaUE9PSIsInZhbHVlIjoiS1V0dTdvT21wbXAwSXZaK1RCTG1pVXZqdlFJa1hXV1RKa2FLem9zU3pXMjd5MmlVOGc2YWY0NVdNR3h3Smp1aSIsIm1hYyI6IjY1NTA5ZDYzMjAzMTJhMGQyMWQ4NjA4ZDgyNGZjZDVlY2MyNjdiMjA2NWYzOWRjY2M4ZmVjYWRlMWNlMWQ3ODEiLCJ0YWciOiIifQ==/21135210' }, '*')" style="padding: 8px 16px; background: white; border: 1px solid #ccc; border-radius: 20px; cursor: pointer;">ویدیو آموزشی</button>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
529
  </div>
530
- <div style="display: flex; gap: 10px;">
531
- <button onclick="window.closeErrorModal()" style="flex:1; padding: 10px; background: white; border: 1px solid #ccc; border-radius: 8px; cursor: pointer;">بازگشت</button>
532
- <button onclick="window.retryGeneration()" style="flex:1; padding: 10px; background: linear-gradient(135deg, #FF4500, #FF8533); color: white; border: none; border-radius: 8px; cursor: pointer;">تلاش مجدد</button>
 
 
 
 
 
 
 
533
  </div>
534
  </div>
535
- </div>`;
 
 
536
  document.body.insertAdjacentHTML('beforeend', modalHtml);
537
- setTimeout(() => window.closeErrorModal(), 10000);
538
  };
539
 
540
  setInterval(() => {
@@ -563,9 +615,7 @@ css_code = """
563
  #col-container { margin: 0 auto; max-width: 1100px; direction: rtl; text-align: right; background: white; padding: 30px; border-radius: 20px; }
564
 
565
  /* Centered Titles */
566
- #main-title, #main-description {
567
- text-align: center !important;
568
- }
569
 
570
  #badge-container { text-align: center; margin-bottom: 20px; height: 30px; }
571
  #user-sub-badge { padding: 6px 16px; border-radius: 20px; font-size: 0.9em; color: white; display: none; }
@@ -573,6 +623,41 @@ css_code = """
573
  .upgrade-btn { width: 100%; margin-top: 15px; background: linear-gradient(135deg, #f59e0b, #d97706); color: white; border: none; animation: pulse 2s infinite; }
574
  @keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.02); } 100% { transform: scale(1); } }
575
  footer { display: none !important; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
576
  </style>
577
  """
578
 
 
132
  return user_record["count"]
133
 
134
  # ==========================================
135
+ # 3. سیستم ایمنی (Safety - Strict Mode)
136
  # ==========================================
137
  print("Loading Safety Checker...")
138
  safety_classifier = pipeline("image-classification", model="Falconsai/nsfw_image_detection", device=-1)
 
443
 
444
  js_upgrade_func = """() => { window.parent.postMessage({ type: 'NAVIGATE_TO_PREMIUM' }, '*'); }"""
445
 
446
+ # جاوا اسکریپت با مودال دقیق و استایل دار
447
  js_global = """
448
  <script>
449
  document.addEventListener('DOMContentLoaded', () => {
 
511
 
512
  init();
513
 
514
+ // ---------------------------------------------
515
+ // GPU QUOTA HANDLER (Exact Styled Modal)
516
+ // ---------------------------------------------
517
+ window.retryGeneration = function() {
518
+ const modal = document.getElementById('custom-quota-modal');
519
+ if (modal) modal.remove();
520
+ const runBtn = document.getElementById('run-btn');
521
+ if(runBtn) runBtn.click();
522
+ };
523
+ window.closeErrorModal = function() {
524
+ const modal = document.getElementById('custom-quota-modal');
525
+ if (modal) modal.remove();
526
+ };
527
 
528
  const showQuotaModal = () => {
529
  if (document.getElementById('custom-quota-modal')) return;
530
+
531
  const modalHtml = `
532
  <div id="custom-quota-modal" style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); backdrop-filter: blur(5px); z-index: 99999; display: flex; align-items: center; justify-content: center; font-family: 'Vazirmatn', sans-serif;">
533
+ <div class="ip-reset-guide-container">
534
+ <div class="guide-header">
535
+ <svg class="guide-header-icon" viewbox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
536
+ <defs><lineargradient id="grad1" x1="0%" y1="0%" x2="100%" y2="100%"><stop offset="0%" style="stop-color: #667eea; stop-opacity: 1;"></stop><stop offset="100%" style="stop-color: #764ba2; stop-opacity: 1;"></stop></lineargradient></defs>
537
+ <circle cx="50" cy="50" r="45" fill="url(#grad1)" opacity="0.1"></circle>
538
+ <circle cx="50" cy="50" r="35" fill="none" stroke="url(#grad1)" stroke-width="2" opacity="0.3"></circle>
539
+ <path d="M35 50 L45 60 L65 40" stroke="url(#grad1)" stroke-width="4" fill="none" stroke-linecap="round" stroke-linejoin="round"></path>
540
+ <circle cx="65" cy="35" r="8" fill="#fee140"></circle>
541
+ <path d="M62 35 L68 35 M65 32 L65 38" stroke="white" stroke-width="2" stroke-linecap="round"></path>
542
+ </svg>
543
+ <div>
544
+ <h2>یک قدم تا ساخت تصاویر جدید</h2>
545
+ <p>نیازمند تغییر نقطه دستیابی</p>
546
+ </div>
547
  </div>
548
+
549
+ <div class="guide-content">
550
+ <div class="info-card">
551
+ <div class="info-card-header">
552
+ <svg class="info-card-icon" viewbox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M13 2L3 14h9l-1 8 10-12h-9l1-8z" fill="#667eea" opacity="0.2"></path><path d="M13 2L3 14h9l-1 8 10-12h-9l1-8z" stroke="#667eea" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg>
553
+ <span class="info-card-title">راه حل سریع</span>
554
+ </div>
555
+ <p>طبق ویدیو آموزشی پایین بین نقطه دستیابی جابجا شوید تلاش مجدد بزنید تا تصاویر مجدداً تولید بشه.</p>
556
+ </div>
557
+
558
+ <div class="summary-section">
559
+ <div class="summary-header">
560
+ <svg class="summary-icon" viewbox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="12" cy="12" r="10" fill="#56ab2f" opacity="0.2"></circle><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2z" stroke="#56ab2f" stroke-width="2"></path><path d="M9 12l2 2 4-4" stroke="#56ab2f" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg>
561
+ <span class="summary-title">خلاصه راهنما</span>
562
+ </div>
563
+ <div class="summary-text">هربار که این صفحه را مشاهده کردید: از اینترنت سیم‌کارت استفاده کنید، VPN را خاموش کرده و طبق ویدیو آموزشی پایین نقطه دستیابی رو تغییر دهید. «تلاش مجدد» کلیک کنید. با این روش ساده می‌توانید به صورت نامحدود تصویر بسازید! ☘️</div>
564
+ </div>
565
+
566
+ <div class="video-button-container">
567
+ <button onclick="parent.postMessage({ type: 'NAVIGATE_TO_URL', url: '#/nav/online/news/getSingle/1149635/eyJpdiI6IjhHVGhPQWJwb3E0cjRXbnFWTW5BaUE9PSIsInZhbHVlIjoiS1V0dTdvT21wbXAwSXZaK1RCTG1pVXZqdlFJa1hXV1RKa2FLem9zU3pXMjd5MmlVOGc2YWY0NVdNR3h3Smp1aSIsIm1hYyI6IjY1NTA5ZDYzMjAzMTJhMGQyMWQ4NjA4ZDgyNGZjZDVlY2MyNjdiMjA2NWYzOWRjY2M4ZmVjYWRlMWNlMWQ3ODEiLCJ0YWciOiIifQ==/21135210' }, '*')" class="elegant-video-button">
568
+ <svg class="elegant-video-button-icon" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 24 24"><path d="M8 5v14l11-7z"></path></svg>
569
+ <span>دیدن ویدیو آموزشی استفاده نامحدود</span>
570
+ </button>
571
+ </div>
572
  </div>
573
+
574
+ <div class="guide-actions">
575
+ <button class="action-button back-button" onclick="window.closeErrorModal()">
576
+ <svg class="action-button-icon" viewbox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M19 12H5M12 19l-7-7 7-7" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg>
577
+ <span>بازگشت</span>
578
+ </button>
579
+ <button class="action-button retry-button" onclick="window.retryGeneration()">
580
+ <svg class="action-button-icon" viewbox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M23 4v6h-6M1 20v-6h6" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path><path d="M20.49 9A9 9 0 0 0 5.64 5.64L1 10m22 4l-4.64 4.36A9 9 0 0 1 3.51 15" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg>
581
+ <span>تلاش مجدد</span>
582
+ </button>
583
  </div>
584
  </div>
585
+ </div>
586
+ `;
587
+
588
  document.body.insertAdjacentHTML('beforeend', modalHtml);
589
+ setTimeout(() => { window.closeErrorModal(); }, 10000);
590
  };
591
 
592
  setInterval(() => {
 
615
  #col-container { margin: 0 auto; max-width: 1100px; direction: rtl; text-align: right; background: white; padding: 30px; border-radius: 20px; }
616
 
617
  /* Centered Titles */
618
+ #main-title, #main-description { text-align: center !important; }
 
 
619
 
620
  #badge-container { text-align: center; margin-bottom: 20px; height: 30px; }
621
  #user-sub-badge { padding: 6px 16px; border-radius: 20px; font-size: 0.9em; color: white; display: none; }
 
623
  .upgrade-btn { width: 100%; margin-top: 15px; background: linear-gradient(135deg, #f59e0b, #d97706); color: white; border: none; animation: pulse 2s infinite; }
624
  @keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.02); } 100% { transform: scale(1); } }
625
  footer { display: none !important; }
626
+
627
+ /* Modal CSS (Copied Exactly) */
628
+ :root { --guide-bg: rgba(255, 255, 255, 0.98); --guide-border: rgba(102, 126, 234, 0.2); --guide-text-title: #2d3748; --guide-text-body: #4a5568; --guide-accent: #667eea; --primary-gradient-guide: linear-gradient(135deg, #667eea 0%, #764ba2 100%); --success-gradient-guide: linear-gradient(135deg, #56ab2f 0%, #a8e063 100%); --radius-md-guide: 12px; --radius-lg-guide: 16px; --shadow-xl: 0 20px 25px -5px rgba(26, 32, 44, 0.07), 0 8px 10px -6px rgba(26, 32, 44, 0.05); }
629
+ @keyframes float { 0%, 100% { transform: translateY(0px); } 50% { transform: translateY(-10px); } }
630
+ @keyframes slideInUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }
631
+ .ip-reset-guide-container { text-align: right; direction: rtl; background: var(--guide-bg); backdrop-filter: blur(10px); padding: 20px; border-radius: var(--radius-lg-guide); box-shadow: var(--shadow-xl); border: 1px solid var(--guide-border); animation: slideInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1) both; width: 90%; max-width: 420px; max-height: 90vh; overflow-y: auto; position: relative; box-sizing: border-box; }
632
+ .ip-reset-guide-container::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: var(--primary-gradient-guide); }
633
+ .guide-header { display: flex; align-items: center; margin-bottom: 15px; }
634
+ .guide-header-icon { width: 45px; height: 45px; margin-left: 15px; animation: float 3s ease-in-out infinite; flex-shrink: 0; }
635
+ .guide-header h2 { font-size: 1.2rem; color: var(--guide-text-title); font-weight: 700; margin: 0; }
636
+ .guide-header p { color: var(--guide-text-body); font-size: 0.8rem; margin-top: 3px; margin-bottom: 0; }
637
+ .guide-content { font-size: 0.9rem; color: var(--guide-text-body); line-height: 1.6; }
638
+ .info-card { background: linear-gradient(135deg, #667eea15 0%, #764ba215 100%); border: 1px solid rgba(102, 126, 234, 0.2); border-radius: var(--radius-md-guide); padding: 12px; margin: 12px 0; position: relative; overflow: hidden; }
639
+ .info-card p { font-size: 0.85rem; line-height: 1.6; margin: 0; }
640
+ .info-card::before { content: ''; position: absolute; top: 0; right: 0; width: 3px; height: 100%; background: var(--primary-gradient-guide); }
641
+ .info-card-header { display: flex; align-items: center; margin-bottom: 8px; }
642
+ .info-card-icon { width: 18px; height: 18px; margin-left: 8px; }
643
+ .info-card-title { font-weight: 600; color: var(--guide-text-title); font-size: 0.95rem; }
644
+ .summary-section { margin-top: 12px; padding: 12px; border-radius: var(--radius-md-guide); background: linear-gradient(135deg, #56ab2f15 0%, #a8e06315 100%); border: 1px solid rgba(86, 171, 47, 0.2); position: relative; overflow: hidden; }
645
+ .summary-section::before { content: ''; position: absolute; top: 0; right: 0; width: 3px; height: 100%; background: var(--success-gradient-guide); }
646
+ .summary-header { display: flex; align-items: center; margin-bottom: 8px; }
647
+ .summary-icon { width: 18px; height: 18px; margin-left: 8px; }
648
+ .summary-title { font-weight: 600; color: #2f5a33; font-size: 0.95rem; }
649
+ .summary-text { color: #2f5a33; font-size: 0.85rem; line-height: 1.6; }
650
+ .video-button-container { text-align: center; margin: 20px 0 15px 0; width: 100%; }
651
+ .elegant-video-button { display: inline-flex !important; align-items: center; justify-content: center; padding: 10px 20px !important; background-color: #fff !important; color: var(--guide-accent) !important; border: 1px solid #e2e8f0 !important; text-decoration: none; border-radius: 50px !important; font-weight: 600 !important; font-size: 0.9rem !important; cursor: pointer !important; font-family: inherit; transition: all 0.3s ease !important; box-shadow: 0 2px 10px rgba(0,0,0,0.05) !important; width: auto !important; }
652
+ .elegant-video-button:hover { background: var(--primary-gradient-guide) !important; color: white !important; border-color: transparent !important; transform: translateY(-2px); box-shadow: 0 6px 16px rgba(102, 126, 234, 0.3) !important; }
653
+ .elegant-video-button-icon { width: 18px; height: 18px; margin-left: 8px; fill: currentColor; }
654
+ .guide-actions { display: flex !important; gap: 12px !important; margin-top: 20px; padding-top: 20px; border-top: 1px solid #e2e8f0; width: 100% !important; }
655
+ .action-button { padding: 12px 15px !important; border: none !important; border-radius: 12px !important; font-size: 0.95rem !important; font-weight: 600 !important; cursor: pointer !important; flex: 1 !important; transition: all 0.3s ease !important; display: flex !important; align-items: center; justify-content: center; font-family: inherit; height: 48px !important; }
656
+ .action-button-icon { width: 20px; height: 20px; margin-right: 0; margin-left: 8px; }
657
+ .back-button { background: white !important; color: var(--guide-text-body) !important; border: 2px solid #e2e8f0 !important; }
658
+ .back-button:hover { background: #f7fafc !important; border-color: var(--guide-accent) !important; transform: translateY(-2px); }
659
+ .retry-button { background: var(--primary-gradient-guide) !important; color: white !important; box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3) !important; }
660
+ .retry-button:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4) !important; }
661
  </style>
662
  """
663