/** * checks permissions of all required filesystem resources. * * @return array An array of error messages */ public static function checkFilesystem() { // -------------------------- SCHREIBRECHTE $writables = [rex_path::media(), rex_path::assets(), rex_path::cache(), rex_path::data(), rex_path::src()]; $func = function ($dir) use(&$func) { if (!rex_dir::isWritable($dir)) { return ['setup_304' => [$dir]]; } $res = []; foreach (rex_finder::factory($dir) as $path => $file) { if ($file->isDir()) { $res = array_merge_recursive($res, $func($path)); } elseif (!$file->isWritable()) { $res['setup_305'][] = $path; } } return $res; }; $res = []; foreach ($writables as $dir) { if (@is_dir($dir)) { $res = array_merge_recursive($res, $func($dir)); } else { $res['setup_306'][] = $dir; } } return $res; }
function executeAction() { $template_name = $this->getElement(2); if ($etpl = rex_yform_email_template::getTemplate($template_name)) { $mail_to = rex::getErrorEmail(); if ($this->getElement(3) != false && $this->getElement(3) != '') { foreach ($this->params['value_pool']['email'] as $key => $value) { if ($this->getElement(3) == $key) { $mail_to = $value; break; } } } // ---- fix mailto from definition if ($this->getElement(4) != false && $this->getElement(4) != '') { $mail_to = $this->getElement(4); } if ($this->params['debug']) { echo '<hr /><pre>'; var_dump($etpl); echo '</pre><hr />'; } $etpl = rex_yform_email_template::replaceVars($etpl, $this->params['value_pool']['email']); if ($this->params['debug']) { echo '<hr /><pre>'; var_dump($etpl); echo '</pre><hr />'; } $etpl['mail_to'] = $mail_to; $etpl['mail_to_name'] = $mail_to; if ($etpl['attachments'] != '') { $f = explode(',', $etpl['attachments']); $etpl['attachments'] = array(); foreach ($f as $v) { $etpl['attachments'][] = array('name' => $v, 'path' => rex_path::media($v)); } } else { $etpl['attachments'] = array(); } if (!rex_yform_email_template::sendMail($etpl, $template_name)) { if ($this->params['debug']) { echo 'email could be sent'; } return false; } else { if ($this->params['debug']) { echo 'email sent'; } return true; } } else { if ($this->params['debug']) { echo '<p>Template: "' . htmlspecialchars($template_name) . '" not found'; } } return false; }
public function fileExists() { return file_exists(rex_path::media($this->getFileName())); }
foreach (['title'] as $col) { if ($files->hasValue($col) && $files->getValue($col) != '') { $alt = htmlspecialchars($files->getValue($col)); break; } } // Eine beschreibende Spalte schätzen $desc = ''; foreach (['med_description'] as $col) { if ($files->hasValue($col) && $files->getValue($col) != '') { $desc = '<p>' . htmlspecialchars($files->getValue($col)) . '</p>'; break; } } // wenn datei fehlt if (!file_exists(rex_path::media($file_name))) { $thumbnail = '<i class="rex-mime rex-mime-error" title="' . rex_i18n::msg('pool_file_does_not_exist') . '"></i><span class="sr-only">' . $file_name . '</span>'; } else { $file_ext = substr(strrchr($file_name, '.'), 1); $icon_class = ' rex-mime-default'; if (rex_media::isDocType($file_ext)) { $icon_class = ' rex-mime-' . $file_ext; } $thumbnail = '<i class="rex-mime' . $icon_class . '" title="' . $alt . '" data-extension="' . $file_ext . '"></i><span class="sr-only">' . $file_name . '</span>'; if (rex_media::isImageType(rex_file::extension($file_name)) && $thumbs) { $thumbnail = '<img class="thumbnail" src="' . rex_url::media($file_name) . '" alt="' . $alt . '" title="' . $alt . '" />'; if ($media_manager) { $thumbnail = '<img class="thumbnail" src="' . rex_url::backendController(['rex_media_type' => 'rex_mediapool_preview', 'rex_media_file' => $encoded_file_name]) . '" alt="' . $alt . '" title="' . $alt . '" />'; } } }
/** * @param string $filename * * @return bool */ function rex_mediapool_deleteMedia($filename) { if ($uses = rex_mediapool_mediaIsInUse($filename)) { $msg = '<strong>' . rex_i18n::msg('pool_file_delete_error_1', $filename) . ' ' . rex_i18n::msg('pool_file_delete_error_2') . '</strong><br />' . $uses; return ['ok' => false, 'msg' => $msg]; } $sql = rex_sql::factory(); $sql->setQuery('DELETE FROM ' . rex::getTable('media') . ' WHERE filename = ? LIMIT 1', [$filename]); rex_file::delete(rex_path::media($filename)); rex_media_cache::delete($filename); rex_extension::registerPoint(new rex_extension_point('MEDIA_DELETED', '', ['filename' => $filename])); return ['ok' => true, 'msg' => rex_i18n::msg('pool_file_deleted')]; }
/** * Fügt einem Tar-Archiv ein Ordner von Dateien hinzu. */ private static function addFolderToTar(rex_backup_tar $tar, $path, $dir) { $handle = opendir($path . $dir); $isMediafolder = realpath($path . $dir) . '/' == rex_path::media(); while (false !== ($file = readdir($handle))) { // Alles exportieren, außer ... // - addons verzeichnis im mediafolder (wird bei addoninstallation wiedererstellt) // - svn infos // - tmp prefix Dateien if ($file == '.' || $file == '..' || $file == '.svn') { continue; } if (substr($file, 0, strlen(rex::getTempPrefix())) == rex::getTempPrefix()) { continue; } if ($isMediafolder && $file == 'addons') { continue; } if (is_dir($path . $dir . '/' . $file)) { self::addFolderToTar($tar, $path . $dir . '/', $file); } else { $tar->addFile($path . $dir . '/' . $file); } } closedir($handle); }
public function execute() { $this->media->asImage(); // -------------------------------------- CONFIG $brandimage = rex_path::media($this->params['brandimage']); if (!file_exists($brandimage) || !is_file($brandimage)) { return; } // Abstand vom Rand $padding_x = -10; if (isset($this->params['padding_x'])) { $padding_x = (int) $this->params['padding_x']; } $padding_y = -10; if (isset($this->params['padding_y'])) { $padding_y = (int) $this->params['padding_y']; } // horizontale ausrichtung: left/center/right $hpos = 'right'; if (isset($this->params['hpos'])) { $hpos = (string) $this->params['hpos']; } // vertikale ausrichtung: top/center/bottom $vpos = 'bottom'; if (isset($this->params['vpos'])) { $vpos = (string) $this->params['vpos']; } // -------------------------------------- /CONFIG $brand = new rex_managed_media($brandimage); $brand->prepare(); $gdbrand = $brand->getImage(); $gdimage = $this->media->getImage(); $image_width = $this->media->getWidth(); $image_height = $this->media->getHeight(); $brand_width = $brand->getWidth(); $brand_height = $brand->getHeight(); switch ($hpos) { case 'left': $dstX = 0; break; case 'center': $dstX = (int) (($image_width - $brand_width) / 2); break; case 'right': default: $dstX = $image_width - $brand_width; } switch ($vpos) { case 'top': $dstY = 0; break; case 'middle': $dstY = (int) (($image_height - $brand_height) / 2); break; case 'bottom': default: $dstY = $image_height - $brand_height; } imagealphablending($gdimage, true); imagecopy($gdimage, $gdbrand, $dstX + $padding_x, $dstY + $padding_y, 0, 0, $brand_width, $brand_height); $brand->destroy(); $this->media->setImage($gdimage); }
function enterObject() { if (!is_string($this->getValue())) { $this->setValue(''); } // MEDIAPOOL $mediacatid = $this->getElement(8) == '' ? 0 : (int) $this->getElement(8); $mediapool_user = $this->getElement(9) == '' ? 'yform::mediafile' : $this->getElement(9); $pool = $this->params['value_pool']['email']; $mediapool_user = preg_replace_callback('/###(\\w+)###/', function ($m) use($pool) { return isset($pool[$m[1]]) ? $pool[$m[1]] : 'key not found'; }, $mediapool_user); // MIN/MAX SIZES $sizes = explode(',', $this->getElement(3)); $minsize = count($sizes) > 1 ? (int) ($sizes[0] * 1024) : 0; $maxsize = count($sizes) > 1 ? (int) ($sizes[1] * 1024) : (int) ($sizes[0] * 1024); // ERR MSGS $error = array(); $err_msgs = explode(',', $this->getElement(6)); // min_err,max_err,type_err,empty_err $err_msgs['min_err'] = $err_msgs[0]; $err_msgs['max_err'] = isset($err_msgs[1]) ? $err_msgs[1] : $err_msgs[0]; $err_msgs['type_err'] = isset($err_msgs[2]) ? $err_msgs[2] : $err_msgs[0]; $err_msgs['empty_err'] = isset($err_msgs[3]) ? $err_msgs[3] : $err_msgs[0]; $rdelete = md5($this->getFieldName('delete')); $rfile = 'file_' . md5($this->getFieldName('file')); // SIZE CHECK if ($this->params['send'] && isset($_FILES[$rfile]) && $_FILES[$rfile]['name'] != '' && ($_FILES[$rfile]['size'] > $maxsize || $_FILES[$rfile]['size'] < $minsize)) { if ($_FILES[$rfile]['size'] < $minsize) { $error[] = $err_msgs['min_err']; } if ($_FILES[$rfile]['size'] > $maxsize) { $error[] = $err_msgs['max_err']; } unset($_FILES[$rfile]); $this->setValue(''); } if ($this->params['send']) { if (isset($_REQUEST[$rdelete]) && $_REQUEST[$rdelete] == 1) { $this->setValue(''); } if (isset($_FILES[$rfile]) && $_FILES[$rfile]['name'] != '') { $FILE['size'] = $_FILES[$rfile]['size']; $FILE['name'] = $_FILES[$rfile]['name']; $FILE['type'] = $_FILES[$rfile]['type']; $FILE['tmp_name'] = $_FILES[$rfile]['tmp_name']; $FILE['error'] = $_FILES[$rfile]['error']; // EXTENSION CHECK $extensions_array = explode(',', $this->getElement(4)); $ext = '.' . pathinfo($FILE['name'], PATHINFO_EXTENSION); if (!in_array(strtolower($ext), $extensions_array) && !in_array(strtoupper($ext), $extensions_array)) { $error[] = $err_msgs['type_err']; } else { $NEWFILE = $this->saveMedia($FILE, rex_path::media(), $extensions_array, $mediacatid, $mediapool_user); if ($NEWFILE['ok']) { $this->setValue($NEWFILE['filename']); } else { $this->setValue(''); $error[] = 'unknown_save_error'; } } } } if ($this->params['send']) { $this->params['value_pool']['email'][$this->getElement(1)] = stripslashes($this->getValue()); if ($this->getElement(7) != 'no_db') { $this->params['value_pool']['sql'][$this->getElement(1)] = $this->getValue(); } } ## check for required file if ($this->params['send'] && $this->getElement(5) == 1 && $this->getValue() == '') { $error[] = $err_msgs['empty_err']; } ## setting up error Message if ($this->params['send'] && count($error) > 0) { $this->params['warning'][$this->getId()] = $this->params['error_class']; $this->params['warning_messages'][$this->getId()] = implode(', ', $error); } $this->params['form_output'][$this->getId()] = $this->parse('value.mediafile.tpl.php'); }
if ($this->allowedExtensions && in_array(strtolower($ext), $this->allowedExtensions)) { $these = implode(', ', $this->allowedExtensions); return array('error' => 'Fehler: Die Datei hat eine ungültige Endung, verboten sind: ' . $these . '.'); } if (!$replaceOldFile) { $final_name = rex_mediapool_filename($filename . '.' . $ext); } if ($this->file->save($uploadDirectory . $final_name)) { rex_mediapool_syncFile($final_name, rex_get('mediaCat', 'int'), ''); rex_set_session('media[rex_file_category]', rex_get('mediaCat', 'int')); return array('success' => true, 'filename' => '' . $final_name . '', 'mediaCatId' => rex_get('mediaCat', 'int'), 'fileId' => rex_media::get($final_name)->getId(), 'originalname' => '' . $filename . '.' . $ext . '', 'timestamp' => time()); } else { return array('error' => 'Die Datei konnte nicht gespeichert werden.' . 'Der Upload wurde abgebrochen, oder es handelt sich um einen internen Fehler'); } } } // security proof // die() if not logged in if (rex::getUser()->hasPerm('rex5_multiupload[]') or rex::getUser()->isAdmin()) { // redaxo array without dots, strip them out $blockedExt = rex_mediapool_getMediaTypeBlacklist(); $allowedExtensions = $blockedExt; // max file size in bytes //$sizeLimit = 10 * 1024 * 1024; $sizeLimit = '10737418240'; $uploader = new qqFileUploader($allowedExtensions, $sizeLimit); $result = $uploader->handleUpload(rex_path::media()); // to pass data through iframe you will need to encode all html tags echo htmlspecialchars(json_encode($result), ENT_NOQUOTES); } else { die('ACCESS DENIED'); }
public static function init() { //--- handle image request $rex_media_manager_file = self::getMediaFile(); $rex_media_manager_type = self::getMediaType(); if ($rex_media_manager_file != '' && $rex_media_manager_type != '') { $media_path = rex_path::media($rex_media_manager_file); $cache_path = rex_path::addonCache('media_manager'); $media = new rex_managed_media($media_path); $media_manager = new self($media); $media_manager->setCachePath($cache_path); $media_manager->applyEffects($rex_media_manager_type); $media_manager->sendMedia(); exit; } }
<?php /** * rex5_multiupload Addon. * @author Friends Of REDAXO * @package redaxo * @var rex_addon $this */ $addon = rex_addon::get('rex5_multiupload'); // --- DYN $properties = array('folder' => rex_path::media(), 'sync_cats' => '1', 'instant_upload_start' => '1', 'upload_simultaneously' => '5', 'clear_uploadlist_automatically' => '0', 'clear_file_after_finish' => '1', 'show_footnote' => '0', 'php_debug' => '0', 'javascript_debug' => '0'); foreach ($properties as $key => $val) { $addon->setProperty($key, $val); } // --- /DYN // --- HEADER if (rex::isBackend()) { rex_view::addCssFile($addon->getAssetsUrl('fileuploader.css')); rex_view::addJSFile($addon->getAssetsUrl('fileuploader.js')); $_REX_HACK_OPENER = ""; $_REX_HACK_OPENER = rex_request('opener_input_field', 'string'); $header = PHP_EOL . ' ' . PHP_EOL . ' <!-- rex5_multiupload -->' . PHP_EOL . ' <script type="text/javascript">var lastMediaPoolOpener = "' . $_REX_HACK_OPENER . '";</script>' . PHP_EOL . ' <!-- ###MULTIUPLOAD_EP_REPLACE### -->' . PHP_EOL . ' <!-- /rex5_multiupload -->' . PHP_EOL; rex_extension::register('OUTPUT_FILTER', function (rex_extension_point $ep) use($header) { $suchmuster = '</head>'; $ersetzen = $header . "\n</head>"; $ep->setSubject(str_replace($suchmuster, $ersetzen, $ep->getSubject())); }); } // --- /HEADER
} elseif ($syncResult['msg']) { $error[] = $syncResult['msg']; } } // diff count neu berechnen, da (hoffentlich) diff files in die db geladen wurden $diff_count = count($diff_files); } } elseif (rex_post('save', 'boolean')) { $error[] = rex_i18n::msg('pool_file_not_found'); } $content = ''; if ($diff_count > 0) { $writable = []; $not_writable = []; foreach ($diff_files as $file) { if (is_writable(rex_path::media($file))) { $e = []; $e['label'] = '<label>' . $file . '</label>'; $e['field'] = '<input type="checkbox" name="sync_files[]" value="' . $file . '" />'; $writable[] = $e; } else { $not_writable[] = $file; } } $e = []; $e['label'] = '<label>' . rex_i18n::msg('pool_select_all') . '</label>'; $e['field'] = '<input type="checkbox" name="checkie" id="rex-js-checkie" value="0" onchange="setAllCheckBoxes(\'sync_files[]\',this)" />'; $writable[] = $e; $fragment = new rex_fragment(); $fragment->setVar('elements', $writable, false); $panel = $fragment->parse('core/form/checkbox.php');
// Wrapper-Fehler-Klasse $form_subject = $subject = 'REX_VALUE[4]'; // Überschrift / Betreff der E-Mail $form_ID = "doform" . "REX_SLICE_ID"; // Formular ID generiert aus SLICE ID $form_required = ' <strong class="reqfield inactive">*</strong>'; // Markierung von Pflichtfeldern $form_bcc = "REX_VALUE[11]"; // BCC-Feld $form_deliver_org = "REX_VALUE[13]"; //Original senden an Bestätigungsmail anhängen $form_submit_title = "REX_VALUE[7]"; // Bezeichnung des Sende-Buttons $form_attachment = rex_path::media() . "REX_MEDIA[id=1 output=1]"; // Pfad zum Dateianhang bei Bestätigungs-E-Mail $form_upload_folder = rex_path::media() . "upload/"; // Pfad für Dateien, die über das Formular hochgeladen werden $form_send_path = false; // true, wenn der Pfad zum Anhang mitgesendet werden soll // FROMMODE: true entspricht der Absender der E-Mail dem Empfänger der Mail // Bei false wird der Absender aus den PHPMailer-Addon-Einstellungen übernommen $form_from_mode = true; // Standard=true umgeht Spamfilter // Welche Felder sollen nicht in der E-Mail übertragen werden? $form_ignore_fields = array('captcha', 'sicherheitscode', 'ilink', 'link', 'divstart', 'divend', 'fieldend', 'info', 'exlink'); // Captcha $captchaID = 00; // ID zum Captcha-Artikel der das Captcha-Template nutzt $captchasource = htmlspecialchars(rex_getUrl($captchaID)); // Alternative: Externe Einbindung eines Captchas // $captchasource="/redaxo/captcha/captcha.php";