This commit is contained in:
Kevin Adametz 2024-08-05 12:05:24 +02:00
parent 04d677d37a
commit bfa3bb1df4
1191 changed files with 637397 additions and 10619 deletions

View file

@ -0,0 +1,102 @@
<?php
namespace App\Services\SyS;
use App\Models\Product;
use Request;
use App\Models\TransProduct;
use App\Models\UserCreditItem;
class CleanHTMLProductDescription
{
public static function show()
{
dump("CleanHTMLProductDescription");
// dd('check function');
$TransProducts = TransProduct::limit(2000)->get();
dump(count($TransProducts));
$c = 0;
foreach($TransProducts as $item){
if($item->value){
$item->value = self::cleanHTML($item->value);
$item->save();
//dump($item->value);
$c++;
}
}
dump("counter TransProduct");
dump($c);
$Products = Product::limit(2000)->get();
dump(count($Products));
$c = 0;
foreach($Products as $item){
if($item){
$item->copy = self::cleanHTML($item->copy);
$item->description = self::cleanHTML($item->description);
$item->usage = self::cleanHTML($item->usage);
$item->ingredients = self::cleanHTML($item->ingredients);
$item->save();
//dump($item->value);
$c++;
}
}
dump("counter");
dd($c);
}
public static function cleanHTML($html)
{
// $html = preg_replace("/(</?)div/", "$1p", $html);
$html = str_replace('<p> </p>', '', $html);
$html = str_replace('<p></p>', '', $html);
$html = str_replace('<p><br></p>', '', $html);
$html = str_replace('<p><br></p>', '', $html);
$html = str_replace('<br>', '', $html);
$html = str_replace('text -primary', 'text-primary', $html);
$html = str_replace('fa -check', 'fa-check', $html);
$html = str_replace('text- primary', 'text-primary', $html);
$html = str_replace('fa- check', 'fa-check', $html);
$html = str_replace('<ul class="list-unstyled list-icons" style="padding-left: 15px;"> </ul>', '', $html);
$html = str_replace('</span>', '', $html);
$html = preg_replace('/(<[^>]+) style=".*?"/i', '$1', $html);
$html = str_replace('<li></li>', '', $html);
$html = str_replace('<li> </li>', '', $html);
$html = str_replace('< i', '<i', $html);
$html = str_replace('< li>', '<li>', $html);
$html = str_replace('</ i>', '</i>', $html);
$html = str_replace('</ li>', '</li>', $html);
$html = str_replace('</ b>', '</b>', $html);
$html = str_replace('< /b>', '</b>', $html);
$html = str_replace('</ p>', '</p>', $html);
$html = str_replace('< /p>', '</p>', $html);
$html = str_replace('< /i>', '</i>', $html);
$html = str_replace('< /li>', '</li>', $html);
$html = str_replace('<div>', '', $html);
$html = str_replace('</div>', '', $html);
$html = str_replace('>>', '>', $html);
return $html;
}
public static function store()
{
$data = Request::all();
\Session()->flash('alert-save', true);
return back();
}
}

View file

@ -3,7 +3,7 @@ namespace App\Services\SyS;
use Request;
class Cronjobs
class CronJobs
{
public static function show()

View file

@ -18,19 +18,29 @@ class DomainSSL
//$domain = 'mivita.care';
// $ssl = KasSLLController::getApiSSLParameter();
$SubDomains = [];
$get_subdomains = $kas->action('get_subdomains');
foreach ($get_subdomains as $subdomain){
if(isset($subdomain['subdomain_name'])){
if(strpos($subdomain['subdomain_name'], 'www.') !== false){
continue;
}
if(strpos($subdomain['subdomain_name'], 'api.') !== false){
continue;
}
if(strpos($subdomain['subdomain_name'], 'checkout.') !== false){
continue;
}
$SubDomains[$subdomain['subdomain_name']] =
[
'ssl_certificate_sni' => $subdomain['ssl_certificate_sni'],
'php_version' => $subdomain['php_version'],
];
if(strpos($subdomain['subdomain_name'], 'www.') !== false){
continue;
}else{
@dump($subdomain);
}
if(strpos($subdomain['subdomain_name'], 'api.') !== false){
continue;
}
if(strpos($subdomain['subdomain_name'], 'checkout.') !== false){
continue;
}
$SubDomains[$subdomain['subdomain_name']] = $subdomain['ssl_certificate_sni'];
/* if($subdomain['ssl_certificate_sni'] !== "Y"){
$pra = array(
@ -50,19 +60,32 @@ class DomainSSL
//$text .= "\n";
}
$dobbleDomains = [];
foreach($user_shops as $user_shop){
$user_shop->hasSubdomain = false;
$user_shop->hasSSL = false;
$user_shop->PHPversion = "";
if(array_key_exists($user_shop->slug.'.mivita.care', $SubDomains)){
$user_shop->hasSubdomain = true;
$user_shop->hasSSL = $SubDomains[$user_shop->slug.'.mivita.care'] === 'Y' ? true : false;
$user_shop->hasSSL = $SubDomains[$user_shop->slug.'.mivita.care']['ssl_certificate_sni'] === 'Y' ? true : false;
$user_shop->PHPversion = $SubDomains[$user_shop->slug.'.mivita.care']['php_version'];
unset($SubDomains[$user_shop->slug.'.mivita.care']);
}
$dobbleDomains[$user_shop->user_id][$user_shop->id] = $user_shop->slug.'.mivita.care';
}
foreach($dobbleDomains as $key => $dobbleDomain){
if(count($dobbleDomain) === 1){
unset($dobbleDomains[$key]);
}
}
$data = [
'values' => $user_shops,
'text' => $text,
'SubDomains' => $SubDomains,
'dobbleDomains' => $dobbleDomains,
];
return view('sys.tools.domain-ssl', $data);
@ -98,16 +121,22 @@ class DomainSSL
}
if(isset($data['update_ssl'])){
//prüfen ob subdomain existiert
$user_shop = UserShop::findOrFail($data['update_ssl']);
$subdomain_name = $user_shop->slug.'.mivita.care';
$kas = new KasController();
$ssl = KasSLLController::getApiSSLParameter();
$pra = array(
'hostname' => $subdomain_name
);
$pra = array_merge($pra, $ssl);
$value = $kas->action('update_ssl', $pra);
\Session()->flash('alert-success', 'update SSL: '.$value.'');
$subdomain = $kas->action('get_subdomains', ['subdomain_name' => $subdomain_name]);
if(!isset($subdomain[0]['subdomain_name'])){ //not found
self::makeNewSubDomain($user_shop->slug);
\Session()->flash('alert-danger', 'subdomain: '.$subdomain_name.' nicht gefunden');
return back();
}else{
self::updateSubDomain($subdomain_name);
}
}
@ -115,4 +144,55 @@ class DomainSSL
return back();
}
private static function updateSubDomain($subdomain_name){
$kas = new KasController();
$ssl = KasSLLController::getApiSSLParameter();
$pra = array(
'hostname' => $subdomain_name
);
$pra = array_merge($pra, $ssl);
$value = $kas->action('update_ssl', $pra);
\Session()->flash('alert-success', 'update SSL: '.$value.'');
return $value;
}
private static function makeNewSubDomain($slug){
$kas = new KasController();
$domain = 'mivita.care';
//check if exisist
$subdomains = $kas->action('get_subdomains');
foreach ($subdomains as $subdomain){
if(!isset($subdomain['subdomain_name'])){
continue;
}
$sub = str_replace(".".$domain, '', $subdomain['subdomain_name']);
if($sub == $slug){
\Session()->flash('alert-danger', __('shop.error_subdomain_exists'));
return;
}
}
//add
$full_subdomain_name = $slug.".".$domain;
$pra = array(
'subdomain_name' => $slug,
'domain_name' => $domain,
'subdomain_path' => '/mein.mivita.care/public/',
'php_version' => config('app.php_version'),
//'ssl_proxy' => 'Y',
//'redirect_status' => 0
);
$add_subdomain = $kas->action('add_subdomain', $pra);
if($add_subdomain == $full_subdomain_name){
\Session()->flash('alert-success', 'Add Subdomain: '.$add_subdomain.'');
return $add_subdomain;
}
\Session()->flash('alert-danger', 'Fehler: '.$add_subdomain.'');
return $add_subdomain;
}
}

View file

@ -0,0 +1,84 @@
<?php
namespace App\Services\SyS;
use App\Models\DbipLookup;
use App\Services\dbip\DBIP;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
use Request;
class ImportDbipCountry
{
public static function show()
{
dump("ImportDbipCountry");
// dd('check function');
self::read('dbip-country-lite-2024-07.csv', 0, 0);
$c = 0;
dump("okay counter");
dd($c);
}
public static function read($filename, $skip = 0, $limit = 0)
{
/*$find = inet_pton("1.10.128.0");
dump($find);
dd(DbipLookup::where('ip_start', "<=", $find)->orderBy('ip_start', 'desc')->first());
if(!Storage::disk('import')->has($filename)){
die("File not found in import folder: ".$filename);
}*/
$path = Storage::disk('import')->path($filename);
$fileContents = file($path);
$c = 0;
foreach ($fileContents as $line) {
$row = str_getcsv($line);
$row[] = self::addrType($row[0]);
//
//base64_encode(file_get_contents($path))
// dump($row);
\DB::table('dbip_lookup')->insert([
'ip_start' => inet_pton($row[0]),
'ip_end' => inet_pton($row[1]),
'country' => $row[2],
'addr_type' => $row[3]
]);
//dump(inet_pton($row[0]));
/* DbipLookup::create([
'ip_start' => ,
'ip_end' => inet_pton($row[1]),
'country' => $row[2],
'addr_type' => $row[3]
]);*/
}
return true;
}
private static function addrType($addr) {
if (ip2long($addr) !== false) {
return "ipv4";
} else if (preg_match('/^[0-9a-fA-F:]+$/', $addr) && @inet_pton($addr)) {
return "ipv6";
}
die("unknown address type for {$addr}");
}
public static function store()
{
$data = Request::all();
\Session()->flash('alert-save', true);
return back();
}
}

View file

@ -0,0 +1,45 @@
<?php
namespace App\Services\SyS;
use Request;
use App\Models\UserBusiness;
use App\Models\UserInvoice;
use App\Models\UserSalesVolume;
class RepairSalesVolumeInvoice
{
public static function show()
{
dump("RepairSalesVolumeInvoice");
dd('check function');
$UserSalesVolumes = UserSalesVolume::where('status', '<', 3)->where('user_invoice_id', null)->orderBy('id', 'desc')->limit(1000)->get();
dump(count($UserSalesVolumes));
$c = 0;
foreach($UserSalesVolumes as $user_sales_volume){
if($user_sales_volume->shopping_order_id){
$UserInvoice = UserInvoice::where('shopping_order_id', $user_sales_volume->shopping_order_id)->first();
if($UserInvoice){
$user_sales_volume->user_invoice_id = $UserInvoice->id;
$user_sales_volume->save();
$c++;
}
}
}
dump("counter");
dd($c);
}
public static function store()
{
$data = Request::all();
\Session()->flash('alert-save', true);
return back();
}
}

View file

@ -0,0 +1,48 @@
<?php
namespace App\Services\SyS;
use Request;
use Carbon;
use App\Models\SySetting;
use App\Models\ShoppingOrder;
use App\Models\UserCreditItem;
use App\User;
class UserCreditItemsAddFrom
{
public static function show()
{
UserCreditItem::all()->each(function($item){
$date = self::getExplodeMessage($item);
$item->from_month = $date['n'];
$item->from_year = $date['Y'];
$item->save();
});
dd("done");
}
private static function getExplodeMessage($item){
$date = [];
if(strpos($item->message, '#')){
$em = explode("#", $item->message);
if(isset($em[1])){ //month
$data['n'] =$em[1];
}
if(isset($em[2])){ //year
$data['Y'] =$em[2];
}
}
return $data;
}
public static function store()
{
abort(403, 'STOP funtion not online');
dd("");
}
}

View file

@ -0,0 +1,88 @@
<?php
namespace App\Services\SyS;
use Request;
use App\Models\UserBusiness;
use App\Models\UserCreditItem;
use App\Models\UserInvoice;
use App\Models\UserSalesVolume;
class UserCreditItemsChangeMessage
{
public static function show()
{
dump("UserCreditItemsChangeMessage");
dd('check function');
$UserCreditItems = UserCreditItem::orderBy('id', 'desc')->limit(1000)->get();
dump(count($UserCreditItems));
$c = 0;
foreach($UserCreditItems as $item){
if($item->message){
$item->message = self::convertMessage($item->message);
$item->save();
$c++;
}
}
dump("counter");
dd($c);
}
public static function convertMessage($message){
$months = [
'Januar' => "1#",
'Februar' => "2#",
'März' => "3#",
'April' => "4#",
'Mai' => "5#",
'Juni' => "6#",
'Juli' => "7#",
'August' => "8#",
'September' => "9#",
'Oktober' => "10#",
'November' => "11#",
'Dezember' => "12#",
];
$em = explode(" ", $message);
$new_message = "";
if($em[0] === "Provision"){
switch ($em[1]) {
case 'Shop':
$new_message .= 'payment.commission_shop#';
break;
case 'Team':
$new_message .= 'payment.commission_team#';
break;
case 'Payline':
$new_message .= 'payment.commission_payline#';
break;
case 'Wachstumsbonus':
$new_message .= 'payment.commission_growth_bonus#';
break;
default:
dd("Error: ".$message);
break;
}
if(isset($months[$em[2]])){
$new_message .= $months[$em[2]];
}
$new_message .= $em[3];
return $new_message;
}
return $message;
}
public static function store()
{
$data = Request::all();
\Session()->flash('alert-save', true);
return back();
}
}