Recent Posts

Pages: 1 2 [3] 4 5 ... 10
21
HTML & templates / Re: Simple contact template
« Last post by LeoNeeson on August 10, 2018, 07:20:32 PM »
Thank you bmartino1 for the validation code, it comes very handy and works well. :) I will make the necessary adjustments and optimizations on the next days (and will be doing some more testings before releasing a new stable version). Thanks again for all your time and effort on testing this...

Code: [Select]
[code]
Name:  <input type="text" required
E-mail: <input type="email"
Code: [Select]
<input type="email" required aria-required="true" />Thank you dj, this is also very useful. :)

Cheers,
Leo.-

> Status update: Currently on standby (these weeks I'm having very little time to spend on this, sorry) :-[
22
HTML & templates / Re: Simple contact template
« Last post by bmartino1 on August 10, 2018, 02:03:58 PM »
jsut to get a working eml verion i did some editing and used a macro version to write the data to a file.

Code: [Select]
<!DOCTYPE html>
<html>

<head>
<meta charset=UTF-8 />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Message to the server</title>
</head>

<!-- Fix Permission to folder upload access (hfs macro)? May not need this-->
<!-- {. set item|%folder%|add upload=@anonymous .} -->

<!-- included css here -->
<style type="text/css">
/* below line is write to use google font online  */
@import url(http://fonts.googleapis.com/css?family=Ubuntu);


* {
margin: 0;
padding: 0;
}

body {
font-size: 62.5%;
font-family: 'Ubuntu', sans-serif;
}

p {
font-size: 1.3em;
margin-bottom: 15px;
}

#page-wrap {
width: 660px;
background: white;
padding: 20px 50px 20px 50px;
margin: 20px auto;
min-height: 300px;
height: auto !important;
height: 300px;
}

#contact-area {
width: 600px;
margin-top: 25px;
}

#contact-area input, #contact-area textarea {
padding: 5px;
width: 471px;
font-family: 'Ubuntu', sans-serif;
font-size: 1.4em;
margin: 0px 0px 10px 0px;
border: 2px solid #CCC;
}

#contact-area textarea {
height: 90px;
}

#contact-area textarea:focus, #contact-area input:focus {
border: 2px solid #FC0;
}

#contact-area button.submit-button {
width: 100px;
height: 30px;
float: right;
cursor: default;
color: buttontext;
text-align: center;
padding: 2px 6px 3px;
box-sizing: border-box;
align-items: flex-start;
border: 0px outset buttonface;
-webkit-appearance: push-button;
font-family: 'Ubuntu', sans-serif;
font-size: 1.4em;
white-space: pre;
}

label {
float: left;
text-align: right;
margin-right: 15px;
width: 100px;
padding-top: 5px;
font-size: 1.4em;
}

/* -------------------------------------
    CSS for sidebar (optional)
---------------------------------------- */
div#fugo{
float:right;
}
</style>




<body>

<div id="page-wrap">
<p><h1>&laquo; Contacting the Server Administrator &raquo;</h1></p>

<div id="contact-area">

<form method="GET">
<label for="contact-name">Full Name:</label>
<input type="text" tabindex="1" class="form-control" id="contact-name" name="name" placeholder="Please Enter Your Full Name.." onkeyup='validateName()'>
            <span class='error-message' id='name-error'></span>

<label for="contact-email">Email Address:</label>
            <input type="email" tabindex="2" class="form-control" id="contact-email" name="email" placeholder="Please Enter a valid Email (your@email.com) " onkeyup='validateEmail()'>
            <span class='error-message' id='email-error'></span>

<label for="contact-subject">Subject:</label><br />
            <input type="subject" tabindex="3" class="form-control" id="contact-subject" name="subject" placeholder="Ex: I Have Experienced an Error" onkeyup='validateSubject()'>
            <span class='error-message' id='subject-error'></span>

<label for='contactMessage'>Your Message:</label><br />
            <textarea class="form-control" rows="20" cols="20" id='contact-message' tabindex="4" name='message'  placeholder="Please Detail your needs - Enter a brief message" onkeyup='validateMessage()'></textarea>
            <span class='error-message' id='message-error'></span>
            <br />

<button id="SendMe" name="SubmitMessage" onclick='return validateForm()' class="submit-button" tabindex="5" >Submit</button>
<br />       
<span class='error-message' id='submit-error'></span>
</button>
</form>
</div>
</div>


<!-- include form validate JavaScript code here -->
<script>
//Creates box and validate textbox content for a name
function validateName() {

  var name = document.getElementById('contact-name').value;

  if(name.length == 0) {

    producePrompt('Name is required', 'name-error' , 'red')
    return false;

  }

  if (!name.match(/^[A-Za-z]*\s{1}[A-Za-z]*$/)) {

    producePrompt('First and last name, please.','name-error', 'red');
    return false;

  }

  producePrompt('Valid', 'name-error', 'green');
  return true;

}

//Creates box and validate textbox content for a Email Subject
function validateSubject() {

  var submessage = document.getElementById('contact-subject').value;
  var required = 2;
  var left = required - submessage.length;

  if (left > 0) {
    producePrompt(left + ' At least 2 characters are required for the Subject','subject-error','red');
    return false;
  }

  producePrompt('Valid', 'subject-error', 'green');
  return true;

}

//Creates box and validate textbox content for a valid Email

function validateEmail () {

  var email = document.getElementById('contact-email').value;

  if(email.length == 0) {

    producePrompt('Email Invalid','email-error', 'red');
    return false;

  }

  if(!email.match(/^[A-Za-z\._\-[0-9]*[@][A-Za-z]*[\.][a-z]{2,4}$/)) {

    producePrompt('Email Invalid', 'email-error', 'red');
    return false;

  }

  producePrompt('Message Valid', 'email-error', 'green');
  return true;

}

//Creates box and validate textbox content for Email Message - Text to save to file later?
function validateMessage() {
  var message = document.getElementById('contact-message').value;
  var required = 10;
  var left = required - message.length;

  if (left > 0) {
    producePrompt(left + ' more characters are required, Please Provide More deails for the server admin','message-error','red');
    return false;
  }

  producePrompt('Valid', 'message-error', 'green');
  return true;

}

//ON button click action:
//Checks form and contents pass validation (NOT working - atleast not displaying) - use later for alert measge sent
function validateForm() {
    if (!validateName() || !validateSubject() || !validateEmail() || !validateMessage())
{
        jsShow('submit-error');
        producePrompt('Please fix errors to submit.', 'submit-error', 'red');
        setTimeout(function(){jsHide('submit-error');}, 2000);
        return false;
    }
else
{
//producePrompt('Sent Sucessfuly', 'Submit-error', 'green');
        return true;
    }
}

//??? Secondary Code for JS validation:
function jsShow(id) {
  document.getElementById(id).style.display = 'block';
}

function jsHide(id) {
  document.getElementById(id).style.display = 'none';
}



//Populate HTML Page
function producePrompt(message, promptLocation, color) {

  document.getElementById(promptLocation).innerHTML = message;
  document.getElementById(promptLocation).style.color = color;


}

</script>

<!-- Rejeto HFS Macro code and Commands via LEO sends to hfs via eml-->
<!-- JS that should just run... eml email thing to populate data later -->
<script type="text/javascript">
var LoggedInUser = '[%user%]';
var LoggedUserIP = '%ip%';

var Today = new Date(); 
var OwnTZ = -(Today.getTimezoneOffset()/60);
var Offset = new Date().getTimezoneOffset();
var MyDate = new Date((new Date).getTime()+3600*OwnTZ*1e3).toUTCString().replace(/ GMT$/,"");
Offset = (Offset<0?"+":"-")+Pad(parseInt(Math.abs(Offset/60)),2)+""+Pad(Math.abs(Offset%60),2);
function Pad(number,length){for(var tz=""+number;tz.length<length;)tz="0"+tz;return tz};
MyFullLocalTime = MyDate+' '+Offset;

</script>



<script type="text/javascript">
//Should just be there to call from - no longer ned buton click to get data
//document.getElementById("SendMe").onclick = function () {

//can view below data vial html web console
var GetName = '\nName: '+document.getElementById("contact-name").value+'\n';
var GetMail = 'Email: '+document.getElementById("contact-email").value+'\n';
var GetSubject = 'Subject: '+document.getElementById("contact-subject").value+'\n';
var GetMessage = 'Message:\n\n'+document.getElementById("contact-message").value+'\n';
var TextCurrentLength = document.getElementById("MessageB").value.length;

var Header0 = 'Received: from '+LoggedInUser+' ('+LoggedUserIP+')'+'\n';
var Header1 = 'From: "'+GetName+'" <'+GetMail+'>'+'\n';
var Header2 = 'To: "HFS Server Administrator"'+'\n';
var Header3 = 'Subject: '+GetSubject+'\n';
var Header4 = 'Date: '+MyFullLocalTime+'\n';
var Header5 = 'MIME-Version: 1.0'+'\n';
var Header6 = 'Content-Type: text/plain; charset=UTF-8'+'\n';
var Header7 = 'Content-Length: '+TextCurrentLength+'\n';
var Header8 = 'Content-Transfer-Encoding: 8bit'+'\n';
var Header9 = 'X-Originating-IP: '+LoggedUserIP+'\n';
var Header10 = 'X-Mailer: HFS Custom template'+'\n';
var FullHeaders = Header0+'\n'+Header1+'\n'+Header2+'\n'+Header3+'\n'+Header4+'\n'+Header5+'\n'+Header6+'\n'+Header7+'\n'+Header8+'\n'+Header9+'\n'+Header10+'\n';
var FullDataString = FullHeaders+GetMessage; // Message content...

//alert("Message sent!");
//alert disabled for testing

//Disabled below code
//var formData = new FormData();

// JavaScript file-like object
//var content = FullDataString // Message content...
//var blob = new Blob([content], { type: "text/plain"});

//formData.append("webmasterfile", blob, "New-Message-{.time|yyyy.mm.dd'-at-'hh.nn.ss.}.txt");

//var request = new XMLHttpRequest();
//request.open("POST", "./contact");  //enable (access/delete/upload to anyone... Folder path is correct spelling
// is not uploading- writing correctly...
//request.send(formData);
}
</script>

<!-- macro send data code for eml -->
{.if |{.?Message.}|{:
{.set|nombre|{.?name.}.}
{.set|correo|{.?email.}.}
{.set|asunto|{.?subject.}.}
{.set|mensaje|{.?message.}.}
{.set|menLENGHT|{.?TextCurrentLength.}.}

{.save|/%folder%/Private-Message-{.time|yyyy.mm.dd'-at-'hh.nn.ss.}.eml|

Received: From (User: %user%) %ip%
From: "{.^nombre.}" < {.^correo.} >
To: "HFS Server Administrator"
Subject: {.^asunto.}
Date: {.time|yyyy/mm/dd '@' hh:nn:ss.}
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Length: {.^menLENGHT.} //
Content-Transfer-Encoding: 8bit
X-Originating-IP: %ip%
X-Mailer: HFS Custom template

Message:

{.force ansi|{.^mensaje.}.}
.}

{.add to log|You've received a new message!.}

:}
.}

</body>
</html>

this web code uses macro to generate and upload teh content via a eml file (which Microsoft office outlook was able to open and read.

log:
8:59:43 AM 127.0.0.1:57818 Requested GET /
8:59:43 AM 127.0.0.1:57819 Requested GET /?mode=jquery
8:59:46 AM 127.0.0.1:57819 Requested GET /Contact/
9:00:10 AM 127.0.0.1:57819 You've received a new message!
9:00:10 AM 127.0.0.1:57819 Requested GET /Contact/?name=Brandon+Martino&email=myemail@gmail.com&subject=aa&message=test+test+test&SubmitMessage=

Best i can do
(also was able to fix java validation of form (all fields require to pass validaiton or submit button doen't work.

i leae the rest to more advance users / leo to tweak the code and fix  issues taht arise.

eml that uplaoded:

Private-Message-2018.08.10-at-09.00.10

Received: From (User: ) 127.0.0.1
From: "Brandon Martino" < myemail@gmail.com >
To: "HFS Server Administrator"
Subject: aa
Date: 2018/08/10 @ 09:00:10
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Length:  //
Content-Transfer-Encoding: 8bit
X-Originating-IP: 127.0.0.1
X-Mailer: HFS Custom template

Message:

test test test
23
HTML & templates / Re: Simple contact template
« Last post by bmartino1 on August 10, 2018, 04:33:23 AM »
*issues with post and hitting max characters (even when its not maxed... --ther is an issues witht eh XML veriosn on hos javascript apends the data to text and finds/saves fiel to folder acess.

isues is with this line:
var request = new XMLHttpRequest();
request.open("POST", "/contact");  //enable (access/delete/upload to anyone... Folder path is correct spelling
request.send(formData);

in which
request.open("POST", "/contact");  //enable (access/delete/upload to anyone... Folder path is correct spelling

shoudl become:
request.open("POST", "/%folder%");  //enable (access/delete/upload to anyone... Folder path is correct spelling

But breaks teh save funston of the code.
in the above post i ahve actaced the working end xml verison

it has file permison corect to aynomus to uplad (with out user intervention to HFS.. It has validation via javascript, and can save the file to the folder like the macro verion.

ONLY User Intervetion that is required si the coret folder path is set to the line
request.open("POST", "/contact");  //enable (access/delete/upload to anyone... Folder path is correct spelling
****************************

Probaly the same issue with the eml version
eml verison:

same issues with xml verions i assume:

no folder permsion were set. but the file seem to have completed, but was not in the expected folder path... (the form created the file, but didn't save to the location

eml with validaiton code:
Code: [Select]
<!DOCTYPE html>
<html>

<head>
<meta charset=UTF-8 />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Message to the server</title>
</head>

<!-- Rejeto HFS Macro Commands via LEO sends to hfs via text (XML) -->
<!-- Fix Permission to folder upload access (hfs macro)? -->
<!-- not working hfs macro: set item|%folder%|upload=@anonymous -->


<!-- included css here -->
<style type="text/css">
/* below line is write to use google font online  */
@import url(http://fonts.googleapis.com/css?family=Ubuntu);


* {
margin: 0;
padding: 0;
}

body {
font-size: 62.5%;
font-family: 'Ubuntu', sans-serif;
}

p {
font-size: 1.3em;
margin-bottom: 15px;
}

#page-wrap {
width: 660px;
background: white;
padding: 20px 50px 20px 50px;
margin: 20px auto;
min-height: 300px;
height: auto !important;
height: 300px;
}

#contact-area {
width: 600px;
margin-top: 25px;
}

#contact-area input, #contact-area textarea {
padding: 5px;
width: 471px;
font-family: 'Ubuntu', sans-serif;
font-size: 1.4em;
margin: 0px 0px 10px 0px;
border: 2px solid #CCC;
}

#contact-area textarea {
height: 90px;
}

#contact-area textarea:focus, #contact-area input:focus {
border: 2px solid #FC0;
}

#contact-area button.submit-button {
width: 100px;
height: 30px;
float: right;
cursor: default;
color: buttontext;
text-align: center;
padding: 2px 6px 3px;
box-sizing: border-box;
align-items: flex-start;
border: 0px outset buttonface;
-webkit-appearance: push-button;
font-family: 'Ubuntu', sans-serif;
font-size: 1.4em;
white-space: pre;
}

label {
float: left;
text-align: right;
margin-right: 15px;
width: 100px;
padding-top: 5px;
font-size: 1.4em;
}

/* -------------------------------------
    CSS for sidebar (optional)
---------------------------------------- */
div#fugo{
float:right;
}
</style>


<!-- JS of some kind??? - eml email thing? -->
<script type="text/javascript">
var LoggedInUser = '[%user%]';
var LoggedUserIP = '%ip%';
</script>

<body>

<div id="page-wrap">
<p><h1>&laquo; Contacting the Server Administrator &raquo;</h1></p>

<div id="contact-area">

<form method="GET">
<label for="contact-name">Full Name:</label>
<input type="text" tabindex="1" class="form-control" id="contact-name" name="name" placeholder="Please Enter Your Full Name.." onkeyup='validateName()'>
            <span class='error-message' id='name-error'></span>

<label for="contact-email">Email Address:</label>
            <input type="email" tabindex="2" class="form-control" id="contact-email" name="email" placeholder="Please Enter a valid Email (your@email.com) " onkeyup='validateEmail()'>
            <span class='error-message' id='email-error'></span>

<label for="contact-subject">Subject:</label><br />
            <input type="subject" tabindex="3" class="form-control" id="contact-subject" name="subject" placeholder="Ex: I Have Experienced an Error" onkeyup='validateSubject()'>
            <span class='error-message' id='subject-error'></span>

<label for='contactMessage'>Your Message:</label><br />
            <textarea class="form-control" rows="20" cols="20" id='contact-message' tabindex="4" name='message'  placeholder="Please Detail your needs - Enter a brief message" onkeyup='validateMessage()'></textarea>
            <span class='error-message' id='message-error'></span>
            <br />

<button id="SendMe" name="SubmitMessage" onclick='return validateForm()' class="submit-button" tabindex="5" >Submit</button>
        <span class='error-message' id='submit-error'></span>
</button>
</form>

</div>
</div>



<!-- include form validate JavaScript code here -->
<!-- <script src="/Contact/form.js"> </script> -->

<script>

function validateName() {

//Creates box and validate textbox content for a name
  var name = document.getElementById('contact-name').value;

  if(name.length == 0) {

    producePrompt('Name is required', 'name-error' , 'red')
    return false;

  }

  if (!name.match(/^[A-Za-z]*\s{1}[A-Za-z]*$/)) {

    producePrompt('First and last name, please.','name-error', 'red');
    return false;

  }

  producePrompt('Valid', 'name-error', 'green');
  return true;

}

//Creates box and validate textbox content for a Email Subject
function validateSubject() {

  var submessage = document.getElementById('contact-subject').value;
  var required = 2;
  var left = required - submessage.length;

  if (left > 0) {
    producePrompt(left + ' At least 2 characters are required for the Subject','subject-error','red');
    return false;
  }

  producePrompt('Valid', 'subject-error', 'green');
  return true;

}

//Creates box and validate textbox content for a valid Email

function validateEmail () {

  var email = document.getElementById('contact-email').value;

  if(email.length == 0) {

    producePrompt('Email Invalid','email-error', 'red');
    return false;

  }

  if(!email.match(/^[A-Za-z\._\-[0-9]*[@][A-Za-z]*[\.][a-z]{2,4}$/)) {

    producePrompt('Email Invalid', 'email-error', 'red');
    return false;

  }

  producePrompt('Message Valid', 'email-error', 'green');
  return true;

}

//Creates box and validate textbox content for Email Message - Text to save to file later?
function validateMessage() {
  var message = document.getElementById('contact-message').value;
  var required = 10;
  var left = required - message.length;

  if (left > 0) {
    producePrompt(left + ' more characters are required, Please Provide More deails for the server admin','message-error','red');
    return false;
  }

  producePrompt('Valid', 'message-error', 'green');
  return true;

}

//ON button click action:
//Later acess to save to file https://stackoverflow.com/questions/21012580/is-it-possible-to-write-data-to-file-using-only-javascript
//Checks form and contents pass validation
function validateForm() {
    if (!validateName() || !validateSubject() || !validateEmail() || !validateMessage())
{
        jsShow('submit-error');
        producePrompt('Please fix errors to submit.', 'submit-error', 'red');
        setTimeout(function(){jsHide('submit-error');}, 2000);
        return false;
    }
else
{
        return true;
    }
}

//??? Secondary Code for JS:
//https://stackoverflow.com/questions/24128659/contact-form-validation-javascript
//https://www.formget.com/javascript-contact-form/
//https://www.w3schools.com/js/js_validation.asp
function jsShow(id) {
  document.getElementById(id).style.display = 'block';
}

function jsHide(id) {
  document.getElementById(id).style.display = 'none';
}



//Populate HTML Page
function producePrompt(message, promptLocation, color) {

  document.getElementById(promptLocation).innerHTML = message;
  document.getElementById(promptLocation).style.color = color;


}

</script>

<!-- Rejeto HFS Macro Commands via LEO sends to hfs via eml-->

<script>
document.getElementById("SendMe").onclick = function () {

var Today = new Date(); 
var OwnTZ = -(Today.getTimezoneOffset()/60);
var Offset = new Date().getTimezoneOffset();
var MyDate = new Date((new Date).getTime()+3600*OwnTZ*1e3).toUTCString().replace(/ GMT$/,"");
Offset = (Offset<0?"+":"-")+Pad(parseInt(Math.abs(Offset/60)),2)+""+Pad(Math.abs(Offset%60),2);
function Pad(number,length){for(var tz=""+number;tz.length<length;)tz="0"+tz;return tz};
MyFullLocalTime = MyDate+' '+Offset;

var GetName = '\nName: '+document.getElementById("contact-name").value+'\n';
var GetMail = 'Email: '+document.getElementById("contact-email").value+'\n';
var GetSubject = 'Subject: '+document.getElementById("contact-subject").value+'\n';
var GetMessage = 'Message:\n\n'+document.getElementById("contact-message").value+'\n';
var TextCurrentLength = document.getElementById("MessageB").value.length;

var Header0 = 'Received: from '+LoggedInUser+' ('+LoggedUserIP+')'+'\n';
var Header1 = 'From: "'+GetName+'" <'+GetMail+'>'+'\n';
var Header2 = 'To: "HFS Server Administrator"'+'\n';
var Header3 = 'Subject: '+GetSubject+'\n';
var Header4 = 'Date: '+MyFullLocalTime+'\n';
var Header5 = 'MIME-Version: 1.0'+'\n';
var Header6 = 'Content-Type: text/plain; charset=UTF-8'+'\n';
var Header7 = 'Content-Length: '+TextCurrentLength+'\n';
var Header8 = 'Content-Transfer-Encoding: 8bit'+'\n';
var Header9 = 'X-Originating-IP: '+LoggedUserIP+'\n';
var Header10 = 'X-Mailer: HFS Custom template'+'\n';
var FullHeaders = Header0+Header1+Header2+Header3+Header4+Header5+Header6+Header7+Header8+Header9+Header10;

alert("Message sent!");

var formData = new FormData();

// JavaScript file-like object
var content = FullHeaders+GetMessage; // Message content...
var blob = new Blob([content], { type: "text/plain"});

formData.append("webmasterfile", blob, "New-Message-{.time|yyyy.mm.dd'-at-'hh.nn.ss.}.eml");

var request = new XMLHttpRequest();
request.open("POST", "/contact");  //enable (access/delete/uplaod to anyone... FOlder path is corect spelling
request.send(formData);

}
</script>

</body>
</html>

will be doing some more testing with both versions.

log:
11:31:09 PM 127.0.0.1:55915 Requested GET /
11:31:09 PM 127.0.0.1:55915 Requested GET /?mode=jquery
11:31:11 PM 127.0.0.1:55916 Requested GET /Contact/
11:31:23 PM 127.0.0.1:55916 Requested GET /Contact/?name=Brandon+Martino&email=myemail@gmail.com&subject=testing&message=hello+world&SubmitMessage=

https://www.wikihow.com/Open-EML-Files
was wondering why it wsa being save to .txt file when it should apend the finlname and extention..
-i assume testing and data string content


===========

and there is definetly somethign goin on witht he EML code in whcih it doent save/apend the data and uplad it to hfs.

8:21:48 AM 127.0.0.1:57574 Requested GET /
8:21:48 AM 127.0.0.1:57575 Requested GET /?mode=jquery
8:21:50 AM 127.0.0.1:57581 Requested GET /Contact/
8:21:58 AM 127.0.0.1:57581 Requested GET /Contact/?name=Brandon+Martino&email=myemail@gmail.com&subject=aa&message=test&SubmitMessage=
8:25:04 AM 127.0.0.1:57631 Requested GET /Contact/?name=Brandon+Martino&email=myemail@gmail.com&subject=aa&message=test&SubmitMessage=
8:25:13 AM 127.0.0.1:57631 Requested GET /Contact/?name=Brandon+Martino&email=myemail@gmail.com&subject=aa&message=test+test+test&SubmitMessage=

might use teh Macro verion to apend that data.
*couldn't get eml veriosn to work.
24
HTML & templates / Re: Simple contact template
« Last post by bmartino1 on August 10, 2018, 03:50:58 AM »
here is the xml version of the code with validation

Eml will be about the same after xml is done...

to fix file permison issue i tried hfs macor comand

Code: [Select]
<!-- Rejeto HFS Macro Commands via LEO sends to hfs via text (XML) -->
<!-- Fix Permission to folder upload access (hfs macro)? -->
set item|%folder%|upload=@anonymous

(still had to set anyone with acess/delete/uplaod to make work / test...)

had to fix code wirte path of file name:
Code: [Select]
formData.append("webmasterfile", blob, "New-Message-{.time|yyyy.mm.dd'-at-'hh.nn.ss.}.txt");
and fodler acess path:
Code: [Select]
request.open("POST", "/contact");  //enable (access/delete/uplaod to anyone... FOlder path is corect spelling
xml code with javascript validation:
**this one worked to save a file to the folder after etc...
Code: [Select]
<!DOCTYPE html>
<html>

<head>
<meta charset=UTF-8 />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Message to the server</title>
</head>

<!-- Rejeto HFS Macro Commands via LEO sends to hfs via text (XML) -->
<!-- Fix Permission to folder upload access (hfs macro)? -->
<!-- not working hfs macro: set item|%folder%|upload=@anonymous -->

<!-- included css here -->
<style type="text/css">
/* below line is write to use google font online  */
@import url(http://fonts.googleapis.com/css?family=Ubuntu);


* {
margin: 0;
padding: 0;
}

body {
font-size: 62.5%;
font-family: 'Ubuntu', sans-serif;
}

p {
font-size: 1.3em;
margin-bottom: 15px;
}

#page-wrap {
width: 660px;
background: white;
padding: 20px 50px 20px 50px;
margin: 20px auto;
min-height: 300px;
height: auto !important;
height: 300px;
}

#contact-area {
width: 600px;
margin-top: 25px;
}

#contact-area input, #contact-area textarea {
padding: 5px;
width: 471px;
font-family: 'Ubuntu', sans-serif;
font-size: 1.4em;
margin: 0px 0px 10px 0px;
border: 2px solid #CCC;
}

#contact-area textarea {
height: 90px;
}

#contact-area textarea:focus, #contact-area input:focus {
border: 2px solid #FC0;
}

#contact-area button.submit-button {
width: 100px;
height: 30px;
float: right;
cursor: default;
color: buttontext;
text-align: center;
padding: 2px 6px 3px;
box-sizing: border-box;
align-items: flex-start;
border: 0px outset buttonface;
-webkit-appearance: push-button;
font-family: 'Ubuntu', sans-serif;
font-size: 1.4em;
white-space: pre;
}

label {
float: left;
text-align: right;
margin-right: 15px;
width: 100px;
padding-top: 5px;
font-size: 1.4em;
}

/* -------------------------------------
    CSS for sidebar (optional)
---------------------------------------- */
div#fugo{
float:right;
}
</style>
<body>

<div id="page-wrap">
<p><h1>&laquo; Contacting the Server Administrator &raquo;</h1></p>

<div id="contact-area">

<form method="GET">
<label for="contact-name">Full Name:</label>
<input type="text" tabindex="1" class="form-control" id="contact-name" name="name" placeholder="Please Enter Your Full Name.." onkeyup='validateName()'>
            <span class='error-message' id='name-error'></span>

<label for="contact-email">Email Address:</label>
            <input type="email" tabindex="2" class="form-control" id="contact-email" name="email" placeholder="Please Enter a valid Email (your@email.com) " onkeyup='validateEmail()'>
            <span class='error-message' id='email-error'></span>

<label for="contact-subject">Subject:</label><br />
            <input type="subject" tabindex="3" class="form-control" id="contact-subject" name="subject" placeholder="Ex: I Have Experienced an Error" onkeyup='validateSubject()'>
            <span class='error-message' id='subject-error'></span>

<label for='contactMessage'>Your Message:</label><br />
            <textarea class="form-control" rows="20" cols="20" id='contact-message' tabindex="4" name='message'  placeholder="Please Detail your needs - Enter a brief message" onkeyup='validateMessage()'></textarea>
            <span class='error-message' id='message-error'></span>
            <br />

<button id="SendMe" name="SubmitMessage" onclick='return validateForm()' class="submit-button" tabindex="5" >Submit</button>
        <span class='error-message' id='submit-error'></span>
</button>
</form>

</div>
</div>

<!-- include form validate JavaScript code here -->
<!-- <script src="/Contact/form.js"> </script> -->

<script>

function validateName() {

//Creates box and validate textbox content for a name
  var name = document.getElementById('contact-name').value;

  if(name.length == 0) {

    producePrompt('Name is required', 'name-error' , 'red')
    return false;

  }

  if (!name.match(/^[A-Za-z]*\s{1}[A-Za-z]*$/)) {

    producePrompt('First and last name, please.','name-error', 'red');
    return false;

  }

  producePrompt('Valid', 'name-error', 'green');
  return true;

}

//Creates box and validate textbox content for a Email Subject
function validateSubject() {

  var submessage = document.getElementById('contact-subject').value;
  var required = 2;
  var left = required - submessage.length;

  if (left > 0) {
    producePrompt(left + ' At least 2 characters are required for the Subject','subject-error','red');
    return false;
  }

  producePrompt('Valid', 'subject-error', 'green');
  return true;

}

//Creates box and validate textbox content for a valid Email

function validateEmail () {

  var email = document.getElementById('contact-email').value;

  if(email.length == 0) {

    producePrompt('Email Invalid','email-error', 'red');
    return false;

  }

  if(!email.match(/^[A-Za-z\._\-[0-9]*[@][A-Za-z]*[\.][a-z]{2,4}$/)) {

    producePrompt('Email Invalid', 'email-error', 'red');
    return false;

  }

  producePrompt('Message Valid', 'email-error', 'green');
  return true;

}

//Creates box and validate textbox content for Email Message - Text to save to file later?
function validateMessage() {
  var message = document.getElementById('contact-message').value;
  var required = 10;
  var left = required - message.length;

  if (left > 0) {
    producePrompt(left + ' more characters are required, Please Provide More deails for the server admin','message-error','red');
    return false;
  }

  producePrompt('Valid', 'message-error', 'green');
  return true;

}

//ON button click action:
//Later acess to save to file https://stackoverflow.com/questions/21012580/is-it-possible-to-write-data-to-file-using-only-javascript
//Checks form and contents pass validation
function validateForm() {
    if (!validateName() || !validateSubject() || !validateEmail() || !validateMessage())
{
        jsShow('submit-error');
        producePrompt('Please fix errors to submit.', 'submit-error', 'red');
        setTimeout(function(){jsHide('submit-error');}, 2000);
        return false;
    }
else
{
        return true;
    }
}

//??? Secondary Code for JS:
//https://stackoverflow.com/questions/24128659/contact-form-validation-javascript
//https://www.formget.com/javascript-contact-form/
//https://www.w3schools.com/js/js_validation.asp
function jsShow(id) {
  document.getElementById(id).style.display = 'block';
}

function jsHide(id) {
  document.getElementById(id).style.display = 'none';
}



//Populate HTML Page
function producePrompt(message, promptLocation, color) {

  document.getElementById(promptLocation).innerHTML = message;
  document.getElementById(promptLocation).style.color = color;


}

</script>


<!-- Script that uplads conten to hfs -->
<script>
document.getElementById("SendMe").onclick = function () {

var Headers = '\n---------------------------\n';
var GetName = '\nName: '+document.getElementById("contact-name").value+'\n';
var GetMail = 'Email: '+document.getElementById("contact-email").value+'\n';
var GetSubject = 'Subject: '+document.getElementById("contact-subject").value+'\n';
var GetMessage = 'Message:\n\n'+document.getElementById("contact-message").value+'\n';

alert("Message sent!");

var formData = new FormData();

// JavaScript file-like object
var content = Headers+GetName+GetMail+GetSubject+GetMessage+Headers; // Message content...
var blob = new Blob([content], { type: "text/plain"});

formData.append("webmasterfile", blob, "New-Message-{.time|yyyy.mm.dd'-at-'hh.nn.ss.}.txt");

var request = new XMLHttpRequest();
request.open("POST", "/contact");  //enable (access/delete/uplaod to anyone... FOlder path is corect spelling
request.send(formData);

}
</script>

</body>
</html>

hfs log:

11:14:49 PM 127.0.0.1:55736 Requested GET /Contact/
11:15:00 PM 127.0.0.1:55736 Requested GET /Contact/?name=Brandon+Martino&email=myemail@gmail.com&subject=testing&message=hello+world&SubmitMessage=
11:18:59 PM 127.0.0.1:55792 Requested GET /Contact/
11:19:14 PM 127.0.0.1:55792 Uploading New-Message-2018.08.09-at-23.18.59.txt
11:19:14 PM 127.0.0.1:55792 Fully uploaded New-Message-2018.08.09-at-23.18.59.txt - 150 @ 11.3 KB/s
11:19:14 PM 127.0.0.1:55798 Requested GET /Contact/
11:19:14 PM 127.0.0.1:55795 Requested GET /Contact/?name=Brandon+Martino&email=myemail@gmail.com&subject=testing&message=test+hello+world&SubmitMessage=

...XML not taking the /n (new line

so everyoting is writen to the text document as a single line string


---------------------------

Name: Brandon Martino
Email: myemail@gmail.com
Subject: testing
Message:

test hello world

---------------------------

otehr wise is working...

XML requires folder user acount with acess/delete/upload
and requires  a define path set to the folder with that users acess...

-- poteanil fixabel vai hfs macro....
http://www.rejetto.com/wiki/index.php?title=HFS:_scripting_commands

Example: {.set item|private files|hide=0|comment=you should never see this!.}
access / delete / upload
you can set permissions on the item, by specifying a list of usernames.
Example: set item|videos|upload=robert will give account robert the ability to upload files in /videos.
Moreover, you can prefix permission by add or remove. In the previous example you set the upload permission. If mike already had upload permission, it is now lost. To add robert instead of just overwriting, you should {.set item|videos|add upload=robert.}. Now mike is happy too. As well, if you change your mind, and want to revoke your grant, just set item|videos|remove upload=robert.
You can specify more than one username this way: robert;mike;rupert.
Special usernames are @anonymous @any account @anyone.

===================
FOr some reason, hfs wasn't seeig the macro and it became displayed as a < p > tage aand text on the webpage...

:p lolz aparently i dind't have the brackets set right for hfs macro parsing, i was able to get the uplad macro permsion working..
fix upload permision

*this one is what i curetnl;y have, but still haveing full data apend to file issues...
Code: [Select]
<!-- Rejeto HFS Macro Commands via LEO sends to hfs via text (XML) -->
<!-- Fix Permission to folder upload access (hfs macro)? -->
{. set item|videos|add upload=@anonymous .}

but (with chages back for testing, it didnt save the file to the pc like the eml verion did
Code: [Select]
<!DOCTYPE html>
<html>

<head>
<meta charset=UTF-8 />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Message to the server</title>
</head>

<!-- Rejeto HFS Macro Commands via LEO sends to hfs via text (XML) -->
<!-- Fix Permission to folder upload access (hfs macro)? -->
{. set item|videos|add upload=@anonymous .}

<!-- included css here -->
<style type="text/css">
/* below line is write to use google font online  */
@import url(http://fonts.googleapis.com/css?family=Ubuntu);


* {
margin: 0;
padding: 0;
}

body {
font-size: 62.5%;
font-family: 'Ubuntu', sans-serif;
}

p {
font-size: 1.3em;
margin-bottom: 15px;
}

#page-wrap {
width: 660px;
background: white;
padding: 20px 50px 20px 50px;
margin: 20px auto;
min-height: 300px;
height: auto !important;
height: 300px;
}

#contact-area {
width: 600px;
margin-top: 25px;
}

#contact-area input, #contact-area textarea {
padding: 5px;
width: 471px;
font-family: 'Ubuntu', sans-serif;
font-size: 1.4em;
margin: 0px 0px 10px 0px;
border: 2px solid #CCC;
}

#contact-area textarea {
height: 90px;
}

#contact-area textarea:focus, #contact-area input:focus {
border: 2px solid #FC0;
}

#contact-area button.submit-button {
width: 100px;
height: 30px;
float: right;
cursor: default;
color: buttontext;
text-align: center;
padding: 2px 6px 3px;
box-sizing: border-box;
align-items: flex-start;
border: 0px outset buttonface;
-webkit-appearance: push-button;
font-family: 'Ubuntu', sans-serif;
font-size: 1.4em;
white-space: pre;
}

label {
float: left;
text-align: right;
margin-right: 15px;
width: 100px;
padding-top: 5px;
font-size: 1.4em;
}

/* -------------------------------------
    CSS for sidebar (optional)
---------------------------------------- */
div#fugo{
float:right;
}
</style>
<body>

<div id="page-wrap">
<p><h1>&laquo; Contacting the Server Administrator &raquo;</h1></p>

<div id="contact-area">

<form method="GET">
<label for="contact-name">Full Name:</label>
<input type="text" tabindex="1" class="form-control" id="contact-name" name="name" placeholder="Please Enter Your Full Name.." onkeyup='validateName()'>
            <span class='error-message' id='name-error'></span>

<label for="contact-email">Email Address:</label>
            <input type="email" tabindex="2" class="form-control" id="contact-email" name="email" placeholder="Please Enter a valid Email (your@email.com) " onkeyup='validateEmail()'>
            <span class='error-message' id='email-error'></span>

<label for="contact-subject">Subject:</label><br />
            <input type="subject" tabindex="3" class="form-control" id="contact-subject" name="subject" placeholder="Ex: I Have Experienced an Error" onkeyup='validateSubject()'>
            <span class='error-message' id='subject-error'></span>

<label for='contactMessage'>Your Message:</label><br />
            <textarea class="form-control" rows="20" cols="20" id='contact-message' tabindex="4" name='message'  placeholder="Please Detail your needs - Enter a brief message" onkeyup='validateMessage()'></textarea>
            <span class='error-message' id='message-error'></span>
            <br />

<button id="SendMe" name="SubmitMessage" onclick='return validateForm()' class="submit-button" tabindex="5" >Submit</button>
        <span class='error-message' id='submit-error'></span>
</button>
</form>

</div>
</div>

<!-- include form validate JavaScript code here -->
<!-- <script src="/Contact/form.js"> </script> -->

<script>

function validateName() {

//Creates box and validate textbox content for a name
  var name = document.getElementById('contact-name').value;

  if(name.length == 0) {

    producePrompt('Name is required', 'name-error' , 'red')
    return false;

  }

  if (!name.match(/^[A-Za-z]*\s{1}[A-Za-z]*$/)) {

    producePrompt('First and last name, please.','name-error', 'red');
    return false;

  }

  producePrompt('Valid', 'name-error', 'green');
  return true;

}

//Creates box and validate textbox content for a Email Subject
function validateSubject() {

  var submessage = document.getElementById('contact-subject').value;
  var required = 2;
  var left = required - submessage.length;

  if (left > 0) {
    producePrompt(left + ' At least 2 characters are required for the Subject','subject-error','red');
    return false;
  }

  producePrompt('Valid', 'subject-error', 'green');
  return true;

}

//Creates box and validate textbox content for a valid Email

function validateEmail () {

  var email = document.getElementById('contact-email').value;

  if(email.length == 0) {

    producePrompt('Email Invalid','email-error', 'red');
    return false;

  }

  if(!email.match(/^[A-Za-z\._\-[0-9]*[@][A-Za-z]*[\.][a-z]{2,4}$/)) {

    producePrompt('Email Invalid', 'email-error', 'red');
    return false;

  }

  producePrompt('Message Valid', 'email-error', 'green');
  return true;

}

//Creates box and validate textbox content for Email Message - Text to save to file later?
function validateMessage() {
  var message = document.getElementById('contact-message').value;
  var required = 10;
  var left = required - message.length;

  if (left > 0) {
    producePrompt(left + ' more characters are required, Please Provide More deails for the server admin','message-error','red');
    return false;
  }

  producePrompt('Valid', 'message-error', 'green');
  return true;

}

//ON button click action:
//Later acess to save to file https://stackoverflow.com/questions/21012580/is-it-possible-to-write-data-to-file-using-only-javascript
//Checks form and contents pass validation
function validateForm() {
    if (!validateName() || !validateSubject() || !validateEmail() || !validateMessage())
{
        jsShow('submit-error');
        producePrompt('Please fix errors to submit.', 'submit-error', 'red');
        setTimeout(function(){jsHide('submit-error');}, 2000);
        return false;
    }
else
{
        return true;
    }
}

//??? Secondary Code for JS:
//https://stackoverflow.com/questions/24128659/contact-form-validation-javascript
//https://www.formget.com/javascript-contact-form/
//https://www.w3schools.com/js/js_validation.asp
function jsShow(id) {
  document.getElementById(id).style.display = 'block';
}

function jsHide(id) {
  document.getElementById(id).style.display = 'none';
}



//Populate HTML Page
function producePrompt(message, promptLocation, color) {

  document.getElementById(promptLocation).innerHTML = message;
  document.getElementById(promptLocation).style.color = color;


}

</script>


<!-- Script that uplads conten to hfs -->
<script>
document.getElementById("SendMe").onclick = function () {

var Headers = '\n---------------------------\n';
var GetName = '\nName: '+document.getElementById("contact-name").value+'\n';
var GetMail = 'Email: '+document.getElementById("contact-email").value+'\n';
var GetSubject = 'Subject: '+document.getElementById("contact-subject").value+'\n';
var GetMessage = 'Message:\n\n'+document.getElementById("contact-message").value+'\n';
var FullDataString = Headers+'\n'+GetName+'\n'+GetMail+'\n'+GetSubject+'\n'+GetMessage+'\n'+Headers;


alert("Message sent!");

var formData = new FormData();

// JavaScript file-like object
var content = Headers+GetName+GetMail+GetSubject+GetMessage+Headers; // Message content...
var blob = new Blob([content], { type: "text/plain"});

formData.append("webmasterfile", blob, "New-Message-{.time|yyyy.mm.dd'-at-'hh.nn.ss.}.txt");

var request = new XMLHttpRequest();
request.open("POST", "/%folder%");  //enable (access/delete/uplaod to anyone... Folder path is correct spelling
request.send(formData);

}
</script>

</body>
</html>

log to test:
7:31:14 AM 127.0.0.1:56911 Requested GET /
7:31:14 AM 127.0.0.1:56912 Requested GET /?mode=jquery
7:31:14 AM 127.0.0.1:56915 Requested GET /
7:31:24 AM 127.0.0.1:56914 Requested GET /Contact/
7:32:20 AM 127.0.0.1:56914 Requested GET /Contact/
7:32:34 AM 127.0.0.1:56914 Requested GET /Contact/?name=Brandon+Martino&email=myemail@gmail.com&subject=testing&message=helo+world&SubmitMessage=
25
HFS ~ HTTP File Server / Re: Route HFS through VPN
« Last post by starscue on August 08, 2018, 01:28:49 PM »
bmartino1 is right, the VPN you should choose, needs to let you "open ports" on their service, something called "Port forwarding" (like you would need when you use eMule, torrent, or any other P2P protocol). You could find a comprehensive list here and here (you could also have a tutorial on how to build a private VPN here).

Please report back with the results of your experiments, to leave a future guide for the rest of the users (thanks!). Keep in touch if you need further help. :)

It's working Fine with TorGuard. You can Also Test It By Yourself.
26
HFS ~ HTTP File Server / Re: VFS settings to another PC ?
« Last post by bmartino1 on August 07, 2018, 11:54:26 PM »
http://rejetto.com/forum/index.php?topic=4393.0

when moving the vfs and folder/file directoirs do appear, you have to fix there file locaiotn.

FORM THE FAQ!

Quote:

What does the "hand" icon represent in the file system tree? 
If you see an icon that looks like a hand, it means that HFS could not find/access the original source file. HFS hides the file from the web interface until it can successfully access this file.
27
HFS ~ HTTP File Server / Re: A macro-level https redirect ?
« Last post by LeoNeeson on August 07, 2018, 04:15:15 PM »
This could be your start point.
28
HFS ~ HTTP File Server / Re: Running the latest version as a service
« Last post by LeoNeeson on August 07, 2018, 02:30:35 PM »
The manual asks me to extract the zip and run the HFS2SERVICE.EXE but this does not exist in the download.
Hi! :) As described here, you can download HFS2SERVICE.EXE from here (more info here). You will find also more alternatives, here (SRVANY-NG and NSSM, both great alternatives to run HFS as a service).

@bmartino1 and anyone interested: I'm sorry, I still didn't have enough time to work on any of those templates (I'll try to make time to do it as soon as I get some free time off, but don't hold your breath).
29
HFS ~ HTTP File Server / Re: VFS settings to another PC ?
« Last post by LeoNeeson on August 07, 2018, 02:18:36 PM »
Let me see if i understand you correctly: you want to copy your ".vfs" file from one PC to another, and when you launch HFS on a new PC, you want that HFS recreate the whole folder structure? To some point this could be feasible to add, but it only could recreate 'empty' folders without content... is that what your are looking for?... ???

If you have a lot of empty folders, it's much easier to make a ZIP of RAR file and unZIP/unRAR the folders on the new PC (just before you start HFS on the new PC). Like bmartino1 said, before you move anything, you need to save all the HFS settings in .ini file (to do this, in Expert mode, go to Menu > Save options > to file). If the whole HFS folder is small in size, it even more easier to compress everything as ZIP/RAR and uncompress everything on the new PC.

Interested option for all folders - "Not Browsable"?
I didn't understand that part... :-\
30
HFS ~ HTTP File Server / Re: Running the latest version as a service
« Last post by bmartino1 on August 06, 2018, 05:28:40 PM »
http://rejetto.com/forum/index.php?topic=4713.msg1059193#msg1059193

I detaulted the best I could. It's not natively support...

You have to use other apps/tools to make it a service.

And have hfs pre setup(no changes) to run from it's vfs/ini

.... Not familiar with that exe. Look I. The post above...
Pages: 1 2 [3] 4 5 ... 10