No changes

This commit is contained in:
Frank Harris 2025-09-11 13:29:15 -04:00
parent 8680a02b13
commit b6b398f5bf
17374 changed files with 2475441 additions and 0 deletions

View file

@ -0,0 +1,21 @@
window.getParameterByName = function(name) {
url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, ' '));
}
window.getCookie = function(name) {
match = document.cookie.match(new RegExp(name + '=([^;]+)'));
if (match) return match[1];
}
window.deleteCookie = function(name) {
document.cookie = name +'=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';
}

View file

@ -0,0 +1,26 @@
<?php
// variables which are required in both viewticket and submitticket.
if (!function_exists('get_lang')) exit;
?>
<script>
var fileInputs, limit = <?php echo $attachmentSettings['attachment_limit']; ?>;
var allowedExtensions = <?php echo json_encode(explode(', ', $attachmentSettings['attachment_extensions'])); ?>;
var maxFileSize = <?php echo $attachmentSettings['attachment_max_size']; ?>;
var maxFileSizeUnits = "<?php echo bytesTo($attachmentSettings['attachment_max_size']); ?>";
var fixBeforeSubmitting = "<?php echo get_lang('ticket_fix_before_submitting'); ?>"
var fixBeforeReplying = "<?php echo get_lang('ticket_fix_before_replying'); ?>"
var problemWithAttachments = "<?php echo get_lang('ticket_problem_with_attachments'); ?>"
var invalidExtensionLang = "<?php echo get_lang('ticket_attachment_invalid_extension'); ?>"
var invalidSizeLang = "<?php echo get_lang('ticket_attachment_invalid_size'); ?>"
var maxFileElements = "<?php echo get_lang('ticket_max_file_elements'); ?>"
var multipleFilesSelects = "<?php echo get_lang('ticket_attachment_multiple_files'); ?>"
var extensionsLang = "<?php echo get_lang('attachment_allowed_extensions_info'); ?>"
<?php
if ($attachmentSettings['attachment_limit'] == 0) {
echo 'var fileSizeInfo = "'. get_lang_f('attachment_size_info', bytesTo($attachmentSettings['attachment_max_size'])) .'"';
} else {
echo 'var fileSizeInfo = "'. get_lang_f('attachment_file_size_info', $attachmentSettings['attachment_limit'], bytesTo($attachmentSettings['attachment_max_size'])) .'"';
}
?>
</script>

View file

@ -0,0 +1,52 @@
$(function() {
$(".rateResponse").each(function(){
var tid = this.getAttribute('data-tid');
var uid = this.getAttribute('data-uid');
var reply_id = this.getAttribute('data-reply-id');
var rating = this.getAttribute('data-rating');
var inputs = "";
for (x = 5; x > 0; --x) {
inputs += "<input class='star star-" + x + "' value='" + x + "' data-tid='" + tid + "' data-uid='" + uid + "' id='reply_" + reply_id + " star-" + x + "' type='radio' name='star'" + (x == rating ? " checked" : "") + ">",
inputs += "<label class='star star-" + x + "' for='reply_" + reply_id + " star-" + x + "'></label>"
}
this.$html = $([
"<div class='stars'>",
" <form action=''>",
inputs,
" </form>",
"</div>"
].join("\n"));
$(this).html(this.$html.html());
});
$(".ticket_reply_notice").click(function() {
var state = ($("#toggleNoticeIcon").text() == "+" ? "-" : "+");
$(".ticket_ReplyBox").slideToggle(function() {
$("#toggleNoticeIcon").text(state);
});
});
$("input[name=star]").click(function() {
var data = {
reply_id: this.getAttribute('id').split(/[ ,]+/)[0].replace(/\D/g, ''),
tid: this.getAttribute('data-tid'),
uid: this.getAttribute('data-uid'),
rating: this.getAttribute('value')
};
$.ajax({
type: "POST",
url: "home.php?m=tickets&p=rate&type=cleared&data_type=json",
data: data,
success: function(data) {
console.log(data.message);
},
dataType: "json",
});
});
});

View file

@ -0,0 +1,118 @@
$(function() {
var cookie = getCookie('fileErrors');
var uid = getParameterByName('uid');
var page = getParameterByName('p');
$("#file_size_info").text(fileSizeInfo);
$("#extension_info").text(extensionsLang.replace('%s', allowedExtensions.join(', ')));
if (typeof cookie !== "undefined" && (uid !== null && uid.length !== 0)) {
var decodedCookie = decodeURIComponent(cookie.replace(/\+/g, ' '));
var json = JSON.parse(decodedCookie);
if (json.uid == uid && json.fileErrors[0].length > 0) {
$("#jsErrorBox").css("display", "block");
$("#errorHeader").text(problemWithAttachments + ':');
for (var key in json.fileErrors[0]) {
$(".ticketErrorList").append('<li class="ticketError">' + json.fileErrors[0][key] + '</li>');
}
deleteCookie('fileErrors');
}
}
$("#add_file_attachment").click(function(e) {
fileInputs = $(".attachment_inputs :file").length;
if (limit > 0 && fileInputs >= limit) {
$(this).prop('disabled', true);
} else {
$(".attachment_inputs").append(
$("<input/>").attr('type', 'file').attr('name', 'ticket_file[]')
);
}
e.preventDefault();
});
$("#submit").click(function(e) {
var errorHeader = (page == 'viewticket' ? fixBeforeReplying : fixBeforeSubmitting);
var errorCount = 0;
var multiple = false;
$("#jsErrorBox").css("display", "none");
$(".ticketErrorList").empty();
$("#errorHeader").text(errorHeader + ':');
fileInputs = $(".attachment_inputs :file").length;
if (limit > 0 && fileInputs > limit) {
$('.ticketErrorList').append('<li class="ticketError">' + maxFileElements.replace("%1", limit) + '</li>')
++errorCount;
} else {
for (var i = 0; i <= fileInputs-1; ++i) {
var fileList = $(".attachment_inputs :file").get(i).files;
var fileIndex = fileList[0];
// Prevent "multiple" from being added to the input element - check we only have one file.
if (fileList.length > 1 && !multiple) {
$(".ticketErrorList").append('<li class="ticketError">' + multipleFilesSelects + '</li>');
multiple = true;
++errorCount;
}
if (typeof fileIndex == "undefined") {
continue;
} else {
// Seems hacky due to the requirement of including translations.
// Make sure the file extension is allowed and the file size is appropriate.
if ($.inArray(fileIndex.name.split('.').pop(), allowedExtensions) == -1) {
$(".ticketErrorList").append('<li class="ticketError">' + invalidExtensionLang.replace("%1", fileIndex.name) + '</li>');
++errorCount;
}
if (fileIndex.size > maxFileSize) {
$(".ticketErrorList").append('<li class="ticketError">' + invalidSizeLang.replace("%1", fileIndex.name).replace("%2", maxFileSizeUnits) + '</li>');
++errorCount;
}
}
}
}
if (errorCount > 0) {
$("#jsErrorBox").css("display", "block");
e.preventDefault();
}
});
$(".downloadAttachmentLink").click(function(e) {
e.preventDefault();
var fileName = $(this).text();
var attachmentId = this.getAttribute('data-id');
var ticketId = this.getAttribute('data-tid');
var uniqueId = this.getAttribute('data-uid');
var url = "?m=tickets&p=download&id=" + attachmentId + "&tid=" + ticketId + "&uid=" + uniqueId + "&type=cleared";
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var downloadUrl = URL.createObjectURL(xhttp.response);
var a = document.createElement("a");
document.body.appendChild(a);
a.style = "display: none";
a.href = downloadUrl;
a.download = fileName;
a.click();
}
};
xhttp.open("GET", url, true);
xhttp.responseType = "blob";
xhttp.send();
});
});

View file

@ -0,0 +1,31 @@
$(function() {
$("#phpIniButton").click(function(e){
var units = ['k', 'm', 'g', 't', 'p'];
var maxSize = $("#attachment_max_size").val();
var limit = parseInt($("#attachment_limit").val());
var unit = maxSize.slice(-2, -1);
var sizeNoUnit = maxSize.slice(0, -2);
var post_max_size = "";
if ($.inArray(unit.toLowerCase(), units) != -1) {
post_max_size = (sizeNoUnit * (limit+1)) + unit;
}
var str = "<pre>";
str += "file_uploads = On\n";
str += "upload_max_filesize = " + sizeNoUnit + unit + "\n";
str += "max_file_uploads = " + limit + "\n";
if (post_max_size.length !== 0) {
str += "post_max_size = " + post_max_size + "\n";
}
str += "</pre>";
$("#guesstimateIniSettings").css("display", "block");
$("#guesstimateIniSettings").html(str);
});
});