Remove LCG from file uploading
This commit is contained in:
parent
e8848d898e
commit
a756ac7210
|
@ -112,7 +112,7 @@ class AdminPanelSystemPreferences extends React.Component {
|
|||
<FormField className="admin-panel-system-preferences__file-attachments-field" name="allow-attachments" decorator={ToggleButton}/>
|
||||
</div>
|
||||
<div className="admin-panel-system-preferences__max-size">
|
||||
<span>{i18n('MAX_SIZE_KB')}</span>
|
||||
<span>{i18n('MAX_SIZE_MB')}</span>
|
||||
<FormField className="admin-panel-system-preferences__max-size-field" fieldProps={{size: 'small'}} name="max-size"/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -145,7 +145,7 @@ export default {
|
|||
'RECAPTCHA_PUBLIC_KEY': 'Chave Pública do Recaptcha',
|
||||
'RECAPTCHA_PRIVATE_KEY': 'Private Key do Recaptcha',
|
||||
'ALLOW_FILE_ATTACHMENTS': 'Permitir anexar arquivos',
|
||||
'MAX_SIZE_KB': 'Tamanho máximo (KB)',
|
||||
'MAX_SIZE_MB': 'Tamanho máximo (MB)',
|
||||
'UPDATE_SETTINGS': 'Atualizar configurações',
|
||||
'DEFAULT_LANGUAGE': 'Idioma padrão',
|
||||
'SUPPORTED_LANGUAGES': 'Idiomas suportados',
|
||||
|
|
|
@ -145,7 +145,7 @@ export default {
|
|||
'RECAPTCHA_PUBLIC_KEY': 'Recaptcha公鑰',
|
||||
'RECAPTCHA_PRIVATE_KEY': 'Recaptcha私人鑰匙',
|
||||
'ALLOW_FILE_ATTACHMENTS': '允許文件附件',
|
||||
'MAX_SIZE_KB': '最大尺寸(KB)',
|
||||
'MAX_SIZE_MB': '最大尺寸(KB)',
|
||||
'UPDATE_SETTINGS': '更新設置',
|
||||
'DEFAULT_LANGUAGE': '默認語言',
|
||||
'SUPPORTED_LANGUAGES': '支持的語言',
|
||||
|
|
|
@ -145,7 +145,7 @@ export default {
|
|||
'RECAPTCHA_PUBLIC_KEY': 'Recaptcha - Öffentlicher Schlüssel',
|
||||
'RECAPTCHA_PRIVATE_KEY': 'Recaptcha - Privater Schlüssel',
|
||||
'ALLOW_FILE_ATTACHMENTS': 'Dateianlagen zulassen',
|
||||
'MAX_SIZE_KB': 'Max. Größe (KB)',
|
||||
'MAX_SIZE_MB': 'Max. Größe (MB)',
|
||||
'UPDATE_SETTINGS': 'Einstellungen aktualisieren',
|
||||
'DEFAULT_LANGUAGE': 'Standardsprache',
|
||||
'SUPPORTED_LANGUAGES': 'Unterstützte Sprachen',
|
||||
|
|
|
@ -145,7 +145,7 @@ export default {
|
|||
'RECAPTCHA_PUBLIC_KEY': 'Recaptcha Public Key',
|
||||
'RECAPTCHA_PRIVATE_KEY': 'Recaptcha Private Key',
|
||||
'ALLOW_FILE_ATTACHMENTS': 'Allow file attachments',
|
||||
'MAX_SIZE_KB': 'Max Size (KB)',
|
||||
'MAX_SIZE_MB': 'Max Size (MB)',
|
||||
'UPDATE_SETTINGS': 'Update settings',
|
||||
'DEFAULT_LANGUAGE': 'Default Language',
|
||||
'SUPPORTED_LANGUAGES': 'Supported Languages',
|
||||
|
|
|
@ -145,7 +145,7 @@ export default {
|
|||
'RECAPTCHA_PUBLIC_KEY': 'Recaptcha clave pública',
|
||||
'RECAPTCHA_PRIVATE_KEY': 'Recaptcha clave privada',
|
||||
'ALLOW_FILE_ATTACHMENTS': 'Permitir archivos adjuntos',
|
||||
'MAX_SIZE_KB': 'Tamaño máximo (KB)',
|
||||
'MAX_SIZE_MB': 'Tamaño máximo (MB)',
|
||||
'UPDATE_SETTINGS': 'Actualizar Configuraciones',
|
||||
'DEFAULT_LANGUAGE': 'Idioma predeterminado',
|
||||
'SUPPORTED_LANGUAGES': 'Idiomas Soportados',
|
||||
|
|
|
@ -145,7 +145,7 @@ export default {
|
|||
'RECAPTCHA_PUBLIC_KEY': 'Clé publique Recaptcha',
|
||||
'RECAPTCHA_PRIVATE_KEY': 'Clé privée Recaptcha',
|
||||
'ALLOW_FILE_ATTACHMENTS': 'Autoriser les pièces jointes',
|
||||
'MAX_SIZE_KB': 'Taille Maximale (Ko)',
|
||||
'MAX_SIZE_MB': 'Taille Maximale (Ko)',
|
||||
'UPDATE_SETTINGS': 'Mettre à jour les paramètres',
|
||||
'DEFAULT_LANGUAGE': 'Langue par défaut',
|
||||
'SUPPORTED_LANGUAGES': 'Langues prises en charges',
|
||||
|
|
|
@ -145,7 +145,7 @@
|
|||
'RECAPTCHA_PUBLIC_KEY': 'Recaptcha Δημοσίου Κλειδιού',
|
||||
'RECAPTCHA_PRIVATE_KEY': 'Recaptcha Ιδιωτικού Κλειδιού',
|
||||
'ALLOW_FILE_ATTACHMENTS': 'Επιτρέπονται Συνημμένα Αρχεία',
|
||||
'MAX_SIZE_KB': 'Μέγιστο Μέγεθος (KB)',
|
||||
'MAX_SIZE_MB': 'Μέγιστο Μέγεθος (MB)',
|
||||
'UPDATE_SETTINGS': 'Ενημέρωση Ρυθμίσεων',
|
||||
'DEFAULT_LANGUAGE': 'Προεπιλεγμένες Γλώσσες',
|
||||
'SUPPORTED_LANGUAGES': 'Υποστηριζόμενες Γλώσσες',
|
||||
|
|
|
@ -145,7 +145,7 @@ export default {
|
|||
'RECAPTCHA_PUBLIC_KEY': 'Recaptcha सार्वजनिक कुंजी',
|
||||
'RECAPTCHA_PRIVATE_KEY': 'Recaptcha निजी कुंजी',
|
||||
'ALLOW_FILE_ATTACHMENTS': 'फ़ाइल अनुलग्नकों की अनुमति दें',
|
||||
'MAX_SIZE_KB': 'अधिकतम आकार (KB)',
|
||||
'MAX_SIZE_MB': 'अधिकतम आकार (MB)',
|
||||
'UPDATE_SETTINGS': 'सेटिंग अपडेट करें',
|
||||
'DEFAULT_LANGUAGE': 'डिफ़ॉल्ट भाषा',
|
||||
'SUPPORTED_LANGUAGES': 'समर्थित भाषाएँ',
|
||||
|
|
|
@ -145,7 +145,7 @@ export default {
|
|||
'RECAPTCHA_PUBLIC_KEY': 'Recaptcha Public Key',
|
||||
'RECAPTCHA_PRIVATE_KEY': 'Recaptcha Private Key',
|
||||
'ALLOW_FILE_ATTACHMENTS': 'Consenti di allegare file',
|
||||
'MAX_SIZE_KB': 'Dimensione massima (KB)',
|
||||
'MAX_SIZE_MB': 'Dimensione massima (MB)',
|
||||
'UPDATE_SETTINGS': 'Aggiorna modifiche',
|
||||
'DEFAULT_LANGUAGE': 'Lingua predefinita',
|
||||
'SUPPORTED_LANGUAGES': 'Lingue supportate',
|
||||
|
|
|
@ -145,7 +145,7 @@ export default {
|
|||
'RECAPTCHA_PUBLIC_KEY': 'Recaptcha公開鍵',
|
||||
'RECAPTCHA_PRIVATE_KEY': 'Recaptcha秘密鍵',
|
||||
'ALLOW_FILE_ATTACHMENTS': '添付ファイルを許可する',
|
||||
'MAX_SIZE_KB': '最大サイズ(KB)',
|
||||
'MAX_SIZE_MB': '最大サイズ(KB)',
|
||||
'UPDATE_SETTINGS': '設定を更新する',
|
||||
'DEFAULT_LANGUAGE': '既定の言語',
|
||||
'SUPPORTED_LANGUAGES': 'サポートされている言語',
|
||||
|
|
|
@ -145,7 +145,7 @@ export default {
|
|||
'RECAPTCHA_PUBLIC_KEY': 'Recaptcha Publieke Sleutel',
|
||||
'RECAPTCHA_PRIVATE_KEY': 'Recaptcha Prive Sleutel',
|
||||
'ALLOW_FILE_ATTACHMENTS': 'Sta bijlage(s) toe',
|
||||
'MAX_SIZE_KB': 'Max grootte (KB)',
|
||||
'MAX_SIZE_MB': 'Max grootte (MB)',
|
||||
'UPDATE_SETTINGS': 'Update instellingen',
|
||||
'DEFAULT_LANGUAGE': 'Standaard Taal',
|
||||
'SUPPORTED_LANGUAGES': 'Talen die zijn ondersteund',
|
||||
|
|
|
@ -145,7 +145,7 @@ export default {
|
|||
'RECAPTCHA_PUBLIC_KEY': 'Recaptcha Chave Pública',
|
||||
'RECAPTCHA_PRIVATE_KEY': 'Recaptcha Private Key',
|
||||
'ALLOW_FILE_ATTACHMENTS': 'Permitir anexos de arquivo',
|
||||
'MAX_SIZE_KB': 'Tamanho máximo (KB)',
|
||||
'MAX_SIZE_MB': 'Tamanho máximo (MB)',
|
||||
'UPDATE_SETTINGS': 'Atualizar configurações',
|
||||
'DEFAULT_LANGUAGE': 'Idioma padrão',
|
||||
'SUPPORTED_LANGUAGES': 'Idiomas suportados',
|
||||
|
|
|
@ -145,7 +145,7 @@ export default {
|
|||
'RECAPTCHA_PUBLIC_KEY': 'Recaptcha Открытый ключ',
|
||||
'RECAPTCHA_PRIVATE_KEY': 'Recaptcha Секретный ключ',
|
||||
'ALLOW_FILE_ATTACHMENTS': 'Разрешить файловые вложения',
|
||||
'MAX_SIZE_KB': 'Максимальный размер (КБ)',
|
||||
'MAX_SIZE_MB': 'Максимальный размер (КБ)',
|
||||
'UPDATE_SETTINGS': 'Обновить настройки',
|
||||
'DEFAULT_LANGUAGE': 'Язык по умолчанию',
|
||||
'SUPPORTED_LANGUAGES': 'Поддерживаемые Языки',
|
||||
|
|
|
@ -145,7 +145,7 @@ export default {
|
|||
'RECAPTCHA_PUBLIC_KEY': 'Hızlı Erişim Anahtarı',
|
||||
'RECAPTCHA_PRIVATE_KEY': 'Recaptcha Özel Anahtar',
|
||||
'ALLOW_FILE_ATTACHMENTS': 'Dosya eklerine izin ver',
|
||||
'MAX_SIZE_KB': 'Maksimum Boyut (KB)',
|
||||
'MAX_SIZE_MB': 'Maksimum Boyut (MB)',
|
||||
'UPDATE_SETTINGS': 'Ayarları güncelle',
|
||||
'DEFAULT_LANGUAGE': 'Varsayılan dil',
|
||||
'SUPPORTED_LANGUAGES': 'Desteklenen Diller',
|
||||
|
|
|
@ -31,7 +31,7 @@ class GetAllTicketsStaffController extends Controller {
|
|||
const METHOD = 'POST';
|
||||
|
||||
public function validations() {
|
||||
return[
|
||||
return [
|
||||
'permission' => 'staff_1',
|
||||
'requestData' => [
|
||||
'page' => [
|
||||
|
|
|
@ -85,9 +85,6 @@ class InitSettingsController extends Controller {
|
|||
'last-stat-day' => date('YmdHi', strtotime(' -12 day ')),
|
||||
'ticket-gap' => Hashing::generateRandomPrime(100000, 999999),
|
||||
'ticket-first-number' => Hashing::generateRandomNumber(100000, 999999),
|
||||
'file-gap' => Hashing::generateRandomPrime(100000, 999999),
|
||||
'file-first-number' => Hashing::generateRandomNumber(100000, 999999),
|
||||
'file-quantity' => 0,
|
||||
'session-prefix' => 'opensupports-'.Hashing::generateRandomToken().'_',
|
||||
'mail-template-header-image' => 'http://opensupports.com/logo.png'
|
||||
]);
|
||||
|
|
|
@ -103,9 +103,6 @@ abstract class Controller {
|
|||
if(!$totalImages) return [];
|
||||
|
||||
$maxSize = Setting::getSetting('max-size')->getValue();
|
||||
$fileGap = Setting::getSetting('file-gap')->getValue();
|
||||
$fileFirst = Setting::getSetting('file-first-number')->getValue();
|
||||
$fileQuantity = Setting::getSetting('file-quantity');
|
||||
|
||||
$fileUploader = FileUploader::getInstance();
|
||||
$fileUploader->setMaxSize($maxSize);
|
||||
|
@ -121,13 +118,10 @@ abstract class Controller {
|
|||
$imagePaths = [];
|
||||
$url = Setting::getSetting('url')->getValue();
|
||||
for($i=0;$i<$totalImages;$i++) {
|
||||
$fileUploader->setGeneratorValues($fileGap, $fileFirst, $fileQuantity->getValue());
|
||||
$fileUploader->upload("image_$i");
|
||||
$imagePaths[] = $url . '/api/system/download?file=' . $fileUploader->getFileName();
|
||||
$fileQuantity->value++;
|
||||
}
|
||||
|
||||
$fileQuantity->store();
|
||||
return $imagePaths;
|
||||
}
|
||||
|
||||
|
@ -138,17 +132,11 @@ abstract class Controller {
|
|||
if(!isset($_FILES['file'])) return '';
|
||||
|
||||
$maxSize = Setting::getSetting('max-size')->getValue();
|
||||
$fileGap = Setting::getSetting('file-gap')->getValue();
|
||||
$fileFirst = Setting::getSetting('file-first-number')->getValue();
|
||||
$fileQuantity = Setting::getSetting('file-quantity');
|
||||
|
||||
$fileUploader = FileUploader::getInstance();
|
||||
$fileUploader->setMaxSize($maxSize);
|
||||
$fileUploader->setGeneratorValues($fileGap, $fileFirst, $fileQuantity->getValue());
|
||||
|
||||
if($fileUploader->upload('file')) {
|
||||
$fileQuantity->value++;
|
||||
$fileQuantity->store();
|
||||
|
||||
return $fileUploader;
|
||||
} else {
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
class FileUploader extends FileManager {
|
||||
private $maxSize = 1;
|
||||
private $linearCongruentialGenerator;
|
||||
private $linearCongruentialGeneratorOffset;
|
||||
private $fileName;
|
||||
private $permission;
|
||||
private $storage;
|
||||
|
@ -71,12 +69,10 @@ class FileUploader extends FileManager {
|
|||
$newName = preg_replace('/[^a-zA-Z0-9\d\.\-]/', '_', $newName);
|
||||
$result = "";
|
||||
|
||||
if ($this->linearCongruentialGenerator instanceof LinearCongruentialGenerator) {
|
||||
if($this->permission) $result = $this->permission . '_';
|
||||
else $result = '';
|
||||
if($this->permission) $result = $this->permission . '_';
|
||||
else $result = '';
|
||||
|
||||
$result .= $this->linearCongruentialGenerator->generate($this->linearCongruentialGeneratorOffset) . '_' . $newName;
|
||||
}
|
||||
$result .= substr(Hashing::generateRandomToken(), 0, 6) . '_' . $newName;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
@ -92,14 +88,6 @@ class FileUploader extends FileManager {
|
|||
else $this->permission = '';
|
||||
}
|
||||
|
||||
public function setGeneratorValues($gap, $first, $offset) {
|
||||
$this->linearCongruentialGenerator = new LinearCongruentialGenerator();
|
||||
$this->linearCongruentialGeneratorOffset = $offset;
|
||||
|
||||
$this->linearCongruentialGenerator->setGap($gap);
|
||||
$this->linearCongruentialGenerator->setFirst($first);
|
||||
}
|
||||
|
||||
public function setMaxSize($maxSize) {
|
||||
$this->maxSize = $maxSize;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue