first commit

This commit is contained in:
2024-12-17 13:43:22 +01:00
commit 8e6cd8b410
21292 changed files with 3514826 additions and 0 deletions

View File

@@ -0,0 +1,96 @@
<?php
/**
* 2019-2020 MDWeb
*
* @author MDWeb
* @copyright 2019-2020 MDWeb
* @license Commercial
*/
class APIWeglot
{
/**
* Array of Weglot URL
*
* @var array
*/
private static $urls = [
'CDN' => 'https://cdn.weglot.com/weglot.min.js',
'ENDPOINT' => 'https://api.weglot.com/translate?api_key='
];
/**
* @var string
*/
private $apiKey;
/**
* Current API URL
*
* @var string
*/
private $url;
public function __construct($api = null)
{
if ($api) {
$this->apiKey = $api;
} else {
$this->apiKey = Configuration::get('MD_WEGLOT_API_KEY');
}
$this->url = self::$urls['ENDPOINT'] . $this->apiKey;
}
/**
* Call Weglot API to check API Key
*
* @param string $type
* @return boolean
*/
public function run()
{
$opts = array(
CURLOPT_POST => true,
CURLOPTurls => $this->url,
CURLOPT_HEADER => "Content-Type: application/json",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => json_encode([])
);
$returnAPI = $this->callAPI($opts);
if ($returnAPI != "API Key {$this->apiKey} does not exist.") {
return true;
}
return false;
}
/**
* Call Weglot API
*
* @param array $opts cURL Options
* @return array
*/
private function callAPI($opts)
{
try {
$ch = curl_init();
curl_setopt_array($ch, $opts);
$result = curl_exec($ch);
curl_close($ch);
return $result;
} catch (Exception $e) {
die($e->getMessage());
}
}
/**
* Retun URL of the Weglot Script
*
* @return string
*/
public static function getWeglotCDNScript()
{
return self::$urls['CDN'];
}
}

View File

@@ -0,0 +1,35 @@
<?php
/**
* 2007-2017 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2017 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;