Privates MODX und LINUX BLOG, User Registrierung ist deaktiviert! Fragen oder Tipps? Bitte per Matrix: @jolichter:tchncs.de
$thead['link_prev'] = $self.'?action=refreshCalendar&month='.$prev_month.'&year='.$prev_year;
$thead['link_next'] = $self.'?action=refreshCalendar&month='.$next_month.'&year='.$next_year;
$thead['link_prev'] = $self.'?action=refreshCalendar&month='.$prev_month.'&year='.$prev_year;
$thead['link_next'] = $self.'?action=refreshCalendar&month='.$next_month.'&year='.$next_year;
sudo add-apt-repository ppa:libreoffice/ppa
sudo apt-get update && sudo apt-get dist-upgrade
sudo apt-get install libreoffice libreoffice-l10n-de libreoffice-pdfimport libreoffice-style-breeze
sudo apt-get install ppa-purge
sudo ppa-purge -d trusty ppa:libreoffice/ppa
<?php
// RSS-Feed Time must be in english!
// we need this time format, e.g.: Wed, 02 Oct 2002 15:00:00 +0200
// unix timestamp to english rss-Date
// usage e.g.: [[+publishedon:getRSSdate]]
setlocale(LC_TIME,'en_GB.UTF8');
$format ='D, d M Y H:i:s O';
return date($format, strtotime($input));
<item>
<title>[[+pagetitle:cdata]]</title>
<link>[[~[[+id]]? &scheme=`full`]]</link>
<description>
[[+introtext:default=`[[+content:ellipsis=`600`]]`:cdata]]
</description>
<pubDate>[[+publishedon:getRSSdate]]</pubDate>
<guid isPermaLink="false">[[~[[+id]]? &scheme=`full`]]</guid>
<dc:creator>
[[+createdby:userinfo=`fullname`]]
</dc:creator>
</item>
ZitatAdobe Flash Player 11.2 ist die letzte Version, die noch die Linux-Plattform unterstützt. Adobe bietet weiterhin Sicherheits-Backports zu Flash Player 11.2 für Linux an.
<?php
/*
* V 23.11.019
*
* cleanUpload is a MODX Revolution FileManager Plugin when uploading with Media Browser
* Clean up and optimize data, JPEG and PDF Metadata will be removed, GDPR compliant (DSGVO Konform)
*
* Testet with MODX 2.8.5 (PHP 7.4.x) and 3.0.4 (PHP 8.1.x)
* File name transliteration and customizing the picture size
* Same file names are NOT overwritten, instead a uniq ID is appended to these files
* Two system events need to be enabled: OnFileManagerBeforeUpload, OnFileManagerUpload
*
* Since MODX 3: Transliterate (upload_translit) must be disabled in the settings for this (cleanUpload uses its own).
* - Transliterate names of uploading files
* - Type: Yes/No (default: Yes)
* - if 'Yes' name of any uploading file will be transliterated by global transliteration rules
*
* Reference and inspiration:
* https://www.php.net/manual/de/function.image-type-to-extension.php
* https://forums.modx.com/?action=thread&thread=73940&page=2
*/
// Settings
$maxWidth = 1280; // Maximum pixel width | Maximale Pixelbreite
$maxHeight = 1280; // Maximum pixel height | Maximale Pixelhöhe
$quality = 80; // JPEG quality in % (default 80) | JPEG Qualität in % (Vorgabe 80)
$slug ='_'; // Replacement character | Ersetzungszeichen
global $modx;
$eventName = $modx->event->name;
// Checks if GD extension is loaded
if (!extension_loaded('gd') && !extension_loaded('gd2')) {
$modx->log(modX::LOG_LEVEL_ERROR, '[cleanUpload] Error: GD extension not loaded');
return false;
}
// ###################################
// Cleaning filename function
if (!function_exists('cleanFilename')) {
function cleanFilename($modx, $filename, $slug) {
// trim, replace special chars, transliterate
// Replace German Umlaute (no problem if use meta charset="UTF-8")
# $filename = str_replace(array('ä', 'ö', 'ü', 'Ä', 'Ö', 'Ü', 'ß'), array('ae', 'oe', 'ue', 'Ae', 'Oe', 'Ue', 'ss'), $filename);
// Trying to use iconv (I've disabled this because I want to have German Umlaute)
# if (function_exists('iconv')) {
# setlocale(LC_ALL, strtolower($modx->getOption('cultureKey')) . '_' . strtoupper($modx->getOption('cultureKey')));
# $filename = trim(preg_replace('~[^a-zA-Z0-9-' . preg_quote(null, '~') . ']+~i', $slug, iconv('UTF-8', 'ASCII//TRANSLIT', $filename)), $slug);
# } else {
// Without transliterate (If you don't want to have Umlaute, remove: äöüÄÖÜß)
$filename = trim(preg_replace('~[^a-zA-Z0-9äöüÄÖÜß-' . preg_quote(null, '~') . ']+~i', $slug, $filename), $slug);
# }
if (empty($filename)) {return false;}
return $filename;
}
}
// ###################################
// Resize JPEG function
if (!function_exists('imgResize')) {
function imgResize($modx, $source, $target, $maxWidth, $maxHeight, $quality) {
list($source_width, $source_height, $source_type) = getimagesize($source);
$source_gd_image = '';
switch ($source_type) {
case IMAGETYPE_JPEG:
$source_gd_image = imagecreatefromjpeg($source);
// Rotate image, if info available, because metadata will be removed
$exif = exif_read_data($source);
if ($exif === false) {
// No EXIF-Metadata
} else {
// Check if the value of the Orientation variable would really rotate the image
if ($exif && isset($exif['Orientation']) && $exif['Orientation'] !== 1) {
// Rotate image
switch ($exif['Orientation']) {
case 3:
$source_gd_image = imagerotate($source_gd_image, 180, 0);
break;
case 6:
$source_gd_image = imagerotate($source_gd_image, -90, 0);
break;
case 8:
$source_gd_image = imagerotate($source_gd_image, 90, 0);
break;
}
$source_width = imagesx($source_gd_image);
$source_height = imagesy($source_gd_image);
}
}
break;
case IMAGETYPE_GIF:
$source_gd_image = imagecreatefromgif($source);
break;
case IMAGETYPE_PNG:
$source_gd_image = imagecreatefrompng($source);
break;
}
if ($source_gd_image === false) {return false;}
$source_aspect_ratio = $source_width / $source_height;
$aspect_ratio = $maxWidth / $maxHeight;
if ($source_width <= $maxWidth && $source_height <= $maxHeight) {
$image_width = $source_width;
$image_height = $source_height;
} elseif ($aspect_ratio > $source_aspect_ratio) {
$image_width = (int) ($maxHeight * $source_aspect_ratio);
$image_height = $maxHeight;
} else {
$image_width = $maxWidth;
$image_height = (int) ($maxWidth / $source_aspect_ratio);
}
// Create a new temporary image
$gd_image = imagecreatetruecolor($image_width, $image_height);
// Copy and resize old image into new image
imagecopyresampled($gd_image, $source_gd_image, 0, 0, 0, 0, $image_width, $image_height, $source_width, $source_height);
// Save gd_image into a file
imagejpeg($gd_image, $target, $quality);
// Destroy the images to free up memory
imagedestroy($source_gd_image);
imagedestroy($gd_image);
}
}
// ###################################
// Resize images if necessary
foreach($files as $file) {
// Checks if an error occurred while uploading the file
if ($file['error'] != 0) {
$modx->log(modX::LOG_LEVEL_ERROR, '[cleanUpload] Error: '.$file);
return false;
}
$dir = $directory;
$fileDir = $directory.$file['name']; # Directory + Filename.ext
$bases = $source->getBases($directory); # Array
$fullPath = $bases['pathAbsolute'].ltrim($directory, '/'); # pathAbsolute + Directory
$pathInfo = pathinfo($file['name']); # Array
$fileName = $pathInfo['filename']; # Filename without extension
$fileNameNew = cleanFilename($modx, $fileName, $slug); # Function
$fileExt = '.'.$pathInfo['extension']; # File extension
$fileExtLow = strtolower($fileExt); # File extension to low
$fullNameNewLow = $fileNameNew.$fileExtLow;
$fullPathNameNew = $fullPath.$fileNameNew.$fileExtLow;
# $modx->log(modX::LOG_LEVEL_ERROR, '[cleanUpload] '.$fileName.' <----> '.$fileNameNew);
switch($eventName) {
case 'OnFileManagerBeforeUpload':
// If the file exist, add an unique-ID Number in file
if (file_exists($fullPathNameNew)) {
$uni = uniqid();
$fileTemp= $fileNameNew.'_'.$uni;
$fileTemp = $fileTemp.$fileExtLow;
$source->renameObject($dir.$fullNameNewLow, $fileTemp);
}
break;
case 'OnFileManagerUpload':
// Transliteration necessary?
if ($fileName != $fileNameNew) {
$source->renameObject($fileDir, $fullNameNewLow);
}
else {
// Or is only the extension to lower necessary?
if ($fileExt != $fileExtLow) {
$source->renameObject($fileDir, $fullNameNewLow);
}
}
// If file is a JPEG-Picture
if ($fileExtLow == '.jpg' || $fileExtLow == '.jpeg') {
imgResize($modx, $fullPathNameNew, $fullPathNameNew, $maxWidth, $maxHeight, $quality);
}
// This code checks if Ghostscript is installed and then converts a PDF file to PostScript and then back to PDF to remove the metadata.
// The resulting PDF file is optimized with the -dPDFSETTINGS=/ebook option to reduce the file size.
// Check if shell_exec is enabled
if (!function_exists('shell_exec')) {
$modx->log(modX::LOG_LEVEL_ERROR, '[cleanUpload] Error: shell_exec function is not enabled -> PDF metadata cannot remove!');
return false;
}
// Check if Ghostscript is installed
$gsVersion = shell_exec('gs -v');
if (!$gsVersion) {
// Log error with MODX
$modx->log(modX::LOG_LEVEL_ERROR, '[cleanUpload] Error: Ghostscript is not installed -> PDF metadata cannot remove!');
return false;
}
// If file is a PDF
if ($fileExtLow == '.pdf') {
// Path to the input PDF file
$inputPDF = $fullPathNameNew;
// Temporary path for the output PDF file
$outputPDF = $fullPathNameNew . '.tmp';
$tempPS = $fullPathNameNew . '.ps';
// Command to convert PDF to PostScript and then back to PDF
$command1 = "pdf2ps $inputPDF $tempPS";
$command2 = "ps2pdf -dPDFSETTINGS=/prepress $tempPS $outputPDF";
// The options '/screen', '/ebook', '/prepress', and '/printer' are settings for ps2pdf that control the quality and type of compression of PDF files.
// Execute commands
exec($command1);
exec($command2);
// Replace the original file with the new file
rename($outputPDF, $inputPDF);
// Remove temporary PostScript file
unlink($tempPS);
}
break;
} }
<?php
#
# dumme Fragen per Zufall erstellen
#
$strIntro1 = array('Dumme Frage: ', 'Blöde Frage: ', 'Nur eine Frage: ', 'Fangfrage: ');
$strIntro2 = array('Wie lautet der Vorname von ', 'Das erste Wort von ', 'Wie lautet der Nachname von ', 'Das letzte Wort von ');
$strName = array('Peter Maffay', 'Martin Luther', 'Anne Hathaway', 'Eva Rosenberg', 'Rosi Musterfrau', 'Alfred Neumann');
$randIntro1 = $strIntro1[array_rand($strIntro1)];
$randIntro2 = $strIntro2[array_rand($strIntro2)];
$randName = $strName[array_rand($strName)];
# Frage zusammen setzen
$randFrage = $randIntro2.$randName.'?';
# Session erstellen
if (!isset($_SESSION['dummeFrage']))
{
$_SESSION['dummeFrage'] = $randFrage;
}
# Platzhalter [[+dummeFrage]]
$modx->setPlaceholder('dummeFrage', $randIntro1.$_SESSION['dummeFrage']);
#
# dumme Antwort in Platzhalter schreiben
#
# den Zufallsnamen in ein Array (Position 0=Vorname und 1=Nachnahme)
$randName = explode(' ', $randName);
$intPosition = array_search($randIntro2, $strIntro2);
if ($intPosition !== false) {
# die ersten 2 Variablen im Array $strIntro2 wird nach dem Vornamen gefragt
if ($intPosition < 2) {
$strAntwort = $randName[0]; #Vorname
} else {
$strAntwort = $randName[1]; #Nachname
}
}
# Session erstellen
if (!isset($_SESSION['dummeAntwort']))
{
$_SESSION['dummeAntwort'] = $strAntwort;
}
# Platzhalter [[+dummeAntwort]]
$modx->setPlaceholder('dummeAntwort', $_SESSION['dummeAntwort']);
$dummeAntwort = $modx->getPlaceholder('dummeAntwort');
unset($_SESSION['dummeFrage']);
unset($_SESSION['dummeAntwort']);
[[!detectMobileBrowsers]]
[[+getBrowser:is=`mobile`:then=`[[$tmpMobile]]`:else=`[[$tmpStandard]]`]]
<a href="[[!~[[*id]]]]?browser=mobile" target="_self">Mobile Version</a>
oder<a href="[[!~[[*id]]]]?browser=standard" target="_self">Standard Version</a>
<?php
# V 23.02.002
# [[!detectMobileBrowsers]]
# [[+getBrowser:is=`mobile`:then=`[[$tmpMobile]]`:else=`[[$tmpStandard]]`]]
#
# e.g.: http://www.yourwebsite.de?browser=mobile
# or
# http://www.yourwebsite.de?browser=standard
#
# Quelle: http://detectmobilebrowsers.com
#
#
$useragent=$_SERVER['HTTP_USER_AGENT'];
if(preg_match('/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i',$useragent)||preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i',substr($useragent,0,4)))
$_SESSION['mobile'] = 1;
if (isset($_GET['browser'])) {
$browser = $_GET['browser'];
} else {
$browser = '';
}
switch ($browser) {
case 'standard':
unset($_SESSION['mobile']);
$modx->setPlaceholder('getBrowser', $browser);
break;
case 'mobile':
$_SESSION['mobile'] = 1;
$modx->setPlaceholder('getBrowser', $browser);
break;
default:
if (isset($_SESSION['mobile']) && $_SESSION['mobile'] == 1) {
$modx->setPlaceholder('getBrowser', 'mobile');
}
break;
}