Plugin Directory

Changeset 3414077


Ignore:
Timestamp:
12/08/2025 10:06:11 AM (4 months ago)
Author:
enkic
Message:

v2.3.10

Location:
ai-builder
Files:
5 edited
48 copied

Legend:

Unmodified
Added
Removed
  • ai-builder/tags/2.3.10/aibui-builder.php

    r3414040 r3414077  
    44 * Plugin URI:        https://website-ai-builder.com/
    55 * Description: This plugin is used to build your website with AI.
    6  * Version: 2.3.9
     6 * Version: 2.3.10
    77 * Author: enkic
    88 * Author URI:        https://enkicorbin.fr/
     
    1818
    1919// Définir la version du plugin
    20 define('AIBUI_VERSION', '2.3.9');
     20define('AIBUI_VERSION', '2.3.10');
    2121
    2222// Simple CSS minifier (safe whitespace/comment removal)
  • ai-builder/tags/2.3.10/assets/js/chat-widget.js

    r3413458 r3414077  
    430430    }
    431431
     432    let timeoutId;
    432433    try {
     434      // Create AbortController for timeout
     435      const controller = new AbortController();
     436      timeoutId = setTimeout(() => controller.abort(), 20000); // 20 second timeout
     437
    433438      const res = await fetch(window.ajaxurl, {
    434439        method: "POST",
    435440        headers: { "Content-Type": "application/x-www-form-urlencoded" },
    436441        body: `action=aibui_get_token&nonce=${window.aiBuilderNonce}`,
     442        signal: controller.signal,
    437443      });
    438444
     445      clearTimeout(timeoutId);
     446
    439447      if (!res.ok) {
     448        // Handle 500 errors specifically
     449        if (res.status === 500) {
     450          throw new Error("Server error: The request took too long or encountered an error. Please try again.");
     451        }
    440452        throw new Error(`HTTP error! status: ${res.status}`);
    441453      }
     
    451463      );
    452464    } catch (error) {
     465      if (timeoutId) {
     466        clearTimeout(timeoutId);
     467      }
    453468      console.error("Error fetching JWT token:", error);
     469
     470      // Handle timeout/abort errors
     471      if (error.name === 'AbortError' || error.message.includes('timeout')) {
     472        throw new Error("Request timeout: The server took too long to respond. Please check your connection and try again.");
     473      }
     474
    454475      showAIMissingAccountToast();
    455476      throw error;
  • ai-builder/tags/2.3.10/assets/js/multi-page.js

    r3414040 r3414077  
    7575async function ensurePremiumAccess() {
    7676    try {
     77        // Create AbortController for timeout
     78        const controller = new AbortController();
     79        const timeoutId = setTimeout(() => controller.abort(), 20000); // 10 second timeout
     80
    7781        const tokenResponse = await fetch(ajaxurl, {
    7882            method: "POST",
    7983            headers: { "Content-Type": "application/x-www-form-urlencoded" },
    8084            body: "action=aibui_get_token&nonce=" + aiBuilderVars.nonce,
     85            signal: controller.signal,
    8186        });
     87
     88        if (!tokenResponse.ok) {
     89            if (tokenResponse.status === 500) {
     90                disableMultiPageAccess("Server error: The request took too long. Please refresh the page and try again.");
     91            } else {
     92                disableMultiPageAccess("Unable to verify authentication. Please refresh the page.");
     93            }
     94            return false;
     95        }
     96
     97        clearTimeout(timeoutId);
    8298
    8399        const tokenData = await tokenResponse.json();
     
    113129        return true;
    114130    } catch (error) {
     131        if (typeof timeoutId !== 'undefined' && timeoutId) {
     132            clearTimeout(timeoutId);
     133        }
    115134        console.error("Error verifying premium access:", error);
    116         disableMultiPageAccess("Unable to verify your subscription at this time. Please try again later.");
     135
     136        // Handle timeout/abort errors
     137        if (error.name === 'AbortError' || error.message.includes('timeout')) {
     138            disableMultiPageAccess("Request timeout: The server took too long to respond. Please check your connection and try again.");
     139        } else {
     140            disableMultiPageAccess("Unable to verify your subscription at this time. Please try again later.");
     141        }
    117142        return false;
    118143    }
     
    408433    const progressSimulator = simulateProgress(fillElement);
    409434
     435    let timeoutId;
    410436    try {
    411         // Get JWT token
     437        // Get JWT token with timeout
     438        const controller = new AbortController();
     439        timeoutId = setTimeout(() => controller.abort(), 10000); // 10 second timeout
     440
    412441        const tokenResponse = await fetch(ajaxurl, {
    413442            method: "POST",
    414443            headers: { "Content-Type": "application/x-www-form-urlencoded" },
    415444            body: "action=aibui_get_token&nonce=" + aiBuilderVars.nonce,
     445            signal: controller.signal,
    416446        });
     447
     448        clearTimeout(timeoutId);
     449
     450        if (!tokenResponse.ok) {
     451            if (tokenResponse.status === 500) {
     452                progressSimulator.complete();
     453                throw new Error("Server error: The request took too long or encountered an error. Please try again.");
     454            }
     455            progressSimulator.complete();
     456            throw new Error(`HTTP error! status: ${tokenResponse.status}`);
     457        }
    417458
    418459        const tokenData = await tokenResponse.json();
     
    480521
    481522    } catch (error) {
     523        if (timeoutId) {
     524            clearTimeout(timeoutId);
     525        }
    482526        console.error("Error generating page:", error);
    483527        progressSimulator.complete();
     528
     529        // Handle timeout/abort errors
     530        if (error.name === 'AbortError' || error.message.includes('timeout')) {
     531            return { success: false, error: "Request timeout: The server took too long to respond. Please check your connection and try again." };
     532        }
     533
    484534        return { success: false, error: error.message };
    485535    }
  • ai-builder/tags/2.3.10/includes/class-ajax-handler.php

    r3414040 r3414077  
    9999    public function get_token()
    100100    {
     101        // Increase timeout for this request (in case DB is slow)
     102        // Default is usually 30s, but some hosts have shorter limits
     103        @set_time_limit(60); // Allow up to 60 seconds
     104       
    101105        // Vérifier que les données POST existent
    102106        if (!isset($_POST['nonce'])) {
  • ai-builder/tags/2.3.10/readme.txt

    r3414040 r3414077  
    55Tested up to: 6.9
    66Requires PHP: 7.4
    7 Stable tag: 2.3.9
     7Stable tag: 2.3.10
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
  • ai-builder/trunk/aibui-builder.php

    r3414040 r3414077  
    44 * Plugin URI:        https://website-ai-builder.com/
    55 * Description: This plugin is used to build your website with AI.
    6  * Version: 2.3.9
     6 * Version: 2.3.10
    77 * Author: enkic
    88 * Author URI:        https://enkicorbin.fr/
     
    1818
    1919// Définir la version du plugin
    20 define('AIBUI_VERSION', '2.3.9');
     20define('AIBUI_VERSION', '2.3.10');
    2121
    2222// Simple CSS minifier (safe whitespace/comment removal)
  • ai-builder/trunk/assets/js/chat-widget.js

    r3413458 r3414077  
    430430    }
    431431
     432    let timeoutId;
    432433    try {
     434      // Create AbortController for timeout
     435      const controller = new AbortController();
     436      timeoutId = setTimeout(() => controller.abort(), 20000); // 20 second timeout
     437
    433438      const res = await fetch(window.ajaxurl, {
    434439        method: "POST",
    435440        headers: { "Content-Type": "application/x-www-form-urlencoded" },
    436441        body: `action=aibui_get_token&nonce=${window.aiBuilderNonce}`,
     442        signal: controller.signal,
    437443      });
    438444
     445      clearTimeout(timeoutId);
     446
    439447      if (!res.ok) {
     448        // Handle 500 errors specifically
     449        if (res.status === 500) {
     450          throw new Error("Server error: The request took too long or encountered an error. Please try again.");
     451        }
    440452        throw new Error(`HTTP error! status: ${res.status}`);
    441453      }
     
    451463      );
    452464    } catch (error) {
     465      if (timeoutId) {
     466        clearTimeout(timeoutId);
     467      }
    453468      console.error("Error fetching JWT token:", error);
     469
     470      // Handle timeout/abort errors
     471      if (error.name === 'AbortError' || error.message.includes('timeout')) {
     472        throw new Error("Request timeout: The server took too long to respond. Please check your connection and try again.");
     473      }
     474
    454475      showAIMissingAccountToast();
    455476      throw error;
  • ai-builder/trunk/assets/js/multi-page.js

    r3414040 r3414077  
    7575async function ensurePremiumAccess() {
    7676    try {
     77        // Create AbortController for timeout
     78        const controller = new AbortController();
     79        const timeoutId = setTimeout(() => controller.abort(), 20000); // 10 second timeout
     80
    7781        const tokenResponse = await fetch(ajaxurl, {
    7882            method: "POST",
    7983            headers: { "Content-Type": "application/x-www-form-urlencoded" },
    8084            body: "action=aibui_get_token&nonce=" + aiBuilderVars.nonce,
     85            signal: controller.signal,
    8186        });
     87
     88        if (!tokenResponse.ok) {
     89            if (tokenResponse.status === 500) {
     90                disableMultiPageAccess("Server error: The request took too long. Please refresh the page and try again.");
     91            } else {
     92                disableMultiPageAccess("Unable to verify authentication. Please refresh the page.");
     93            }
     94            return false;
     95        }
     96
     97        clearTimeout(timeoutId);
    8298
    8399        const tokenData = await tokenResponse.json();
     
    113129        return true;
    114130    } catch (error) {
     131        if (typeof timeoutId !== 'undefined' && timeoutId) {
     132            clearTimeout(timeoutId);
     133        }
    115134        console.error("Error verifying premium access:", error);
    116         disableMultiPageAccess("Unable to verify your subscription at this time. Please try again later.");
     135
     136        // Handle timeout/abort errors
     137        if (error.name === 'AbortError' || error.message.includes('timeout')) {
     138            disableMultiPageAccess("Request timeout: The server took too long to respond. Please check your connection and try again.");
     139        } else {
     140            disableMultiPageAccess("Unable to verify your subscription at this time. Please try again later.");
     141        }
    117142        return false;
    118143    }
     
    408433    const progressSimulator = simulateProgress(fillElement);
    409434
     435    let timeoutId;
    410436    try {
    411         // Get JWT token
     437        // Get JWT token with timeout
     438        const controller = new AbortController();
     439        timeoutId = setTimeout(() => controller.abort(), 10000); // 10 second timeout
     440
    412441        const tokenResponse = await fetch(ajaxurl, {
    413442            method: "POST",
    414443            headers: { "Content-Type": "application/x-www-form-urlencoded" },
    415444            body: "action=aibui_get_token&nonce=" + aiBuilderVars.nonce,
     445            signal: controller.signal,
    416446        });
     447
     448        clearTimeout(timeoutId);
     449
     450        if (!tokenResponse.ok) {
     451            if (tokenResponse.status === 500) {
     452                progressSimulator.complete();
     453                throw new Error("Server error: The request took too long or encountered an error. Please try again.");
     454            }
     455            progressSimulator.complete();
     456            throw new Error(`HTTP error! status: ${tokenResponse.status}`);
     457        }
    417458
    418459        const tokenData = await tokenResponse.json();
     
    480521
    481522    } catch (error) {
     523        if (timeoutId) {
     524            clearTimeout(timeoutId);
     525        }
    482526        console.error("Error generating page:", error);
    483527        progressSimulator.complete();
     528
     529        // Handle timeout/abort errors
     530        if (error.name === 'AbortError' || error.message.includes('timeout')) {
     531            return { success: false, error: "Request timeout: The server took too long to respond. Please check your connection and try again." };
     532        }
     533
    484534        return { success: false, error: error.message };
    485535    }
  • ai-builder/trunk/includes/class-ajax-handler.php

    r3414040 r3414077  
    9999    public function get_token()
    100100    {
     101        // Increase timeout for this request (in case DB is slow)
     102        // Default is usually 30s, but some hosts have shorter limits
     103        @set_time_limit(60); // Allow up to 60 seconds
     104       
    101105        // Vérifier que les données POST existent
    102106        if (!isset($_POST['nonce'])) {
  • ai-builder/trunk/readme.txt

    r3414040 r3414077  
    55Tested up to: 6.9
    66Requires PHP: 7.4
    7 Stable tag: 2.3.9
     7Stable tag: 2.3.10
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
Note: See TracChangeset for help on using the changeset viewer.