Jump to content

Shinori

Members
  • Posts

    29
  • Joined

  • Last visited

Posts posted by Shinori

  1. 13 minutes ago, justsomeguy said:

    Try this instead:

     

    
    document.cookie = name+'=; Max-Age=-99999999;';

     

    Didn't change anything. The cookie still hasn't been deleted.

    13 minutes ago, dsonesuk said:

    Just one question, where's getcookie() function?

    Here it is: 

    function getCookie(cname) 
    {
    	var name = cname + "=";
    	var decodedCookie = decodeURIComponent(document.cookie);
    	var ca = decodedCookie.split(';');
    	for(var i = 0; i < ca.length; i++) 
    	{
    		var c = ca[i];
    		while (c.charAt(0) == ' ') 
    		{
    		  c = c.substring(1);
    		}
    		if (c.indexOf(name) == 0) 
    		{
    		  return c.substring(name.length, c.length);
    		}
    	}
      return "";
    }

     

  2. Dear forumusers,

     

    I'm currently having trouble with deleting my browsercookies. Specifically speaking im trying to delete the cookies of the website the user is currently on.

    Here are my JS functions + the proof for existing cookies.

    function setCookie(cname, cvalue, days) 
    {
    	var dt, expires;
    	dt = new Date();
    	dt.setTime(dt.getTime()+(days*24*60*60*1000));
    	expires = "; expires="+dt.toGMTString();
    	document.cookie = cname+"="+cvalue+expires+';';
    }
    function delCookie(name)
    {
    	document.cookie = name + '= ; expires = Thu, 01 Jan 1970 00:00:00 GMT';
    }
    function logout()
    {
    	var cookie = getCookie("member");
    	if(typeof cookie != "undefined" || typeof cookie != null || cookie.length > 0)
    	{
    		delCookie("member");
    		window.location.reload();
    	}
    	else
    	{
    		alert("Beim Logout ist etwas schief gelaufen!");
    		window.location.reload();
    	}
    }

     

    Apparently my browsers language isn't english. Sorry for that. Basically it says that the cookies name is "member", that is has content and expires in 1 day.

     

    image.png.32f2c102b063d3aaf5c43fd7008e910b.png

     

    I call the "logout"-function via onclick event in visible DOM. The functions gets called successfully. The cookie existence of "member" is then successfully validated and delcookie() is called. 
    The windows gets reloaded as logout() is suppose to do.

    Eventually the cookie is NOT being deleted. Any ideas whats going wrong her?

     

    Thanks in advance! Sorry for my bad english :S

  3. Hey,

    having trouble with creating cookies in firefox. I've tested it in chrome and edge and it seems to be working fine. But on firefox (Quantum 66.0 (64-Bit)) the cookies is not being created and i don't know why.

    Do you habe any ideas why it's not working? I've read sth about "secure cookies in firefox".
    Thanks in advance :)

    Im actually using W3s setCookie piece of code:

     

    function setCookie(name,value,days) 
    {
        var expires = "";
        if (days) 
    	{
            var date = new Date();
            date.setTime(date.getTime() + (days*24*60*60*1000));
            expires = "; expires=" + date.toUTCString();
        }
        document.cookie = name + "=" + escape(decodeURI(value)) + ";" + expires + "; path=/";
    }

    Creating the cookie with:

    function login()
    {
    	var email = document.getElementById("email").value;
    	var psw = document.getElementById("psw").value;
    	var xmlhttp = new XMLHttpRequest();
    	xmlhttp.onreadystatechange = function()
    	{
    		if (this.readyState == 4 && this.status == 200)
    		{
    			if(this.responseText == "false")
    			{
    				popup("login_error.php");
    			}
    			else
    			{
    				setCookie("nydoo_minecraft_member",this.responseText,1);
    				window.location.reload();
    				
    			}
    		}
    	};
    	xmlhttp.open('POST',"/resources/login.php?email=" + email + "&psw=" + psw, true);
    	xmlhttp.send();
    	
    }

     

  4. Could I establish a SSH connection via PHP and create a new user on my Debian 9 system which only has access and permission to specific directories? 

    I'd probably have to establish a new ssh connection each time i try to reach any data, would I ?

     

  5. Wouldn't it be possible to "try'n'catch" a piece of code to temporarely use chmod and the file / directory just to show the content of the file?
    I tried it but it didnt seem to work. Not sure if its my code or a generel problem. 🤔

    Greetings

  6. 49 minutes ago, justsomeguy said:

    One option is to route all requests for those files to a PHP script that authorizes people before sending the file content, and having the actual files stored outside of the web server root.  You could also use a custom web server module to do authorization.

    What exactly is a custom webserver module?

    Sorry im not teh best in terms of configuring optional software for webservers 😕

     

  7. Hello,

    I'm trying to develop my own cloud storage system. 

    Currently having trouble with permissions of certain files.
    I need a specific client to have access to file located in user specific directory such as "/cloud/files/members/N10000/".
    But I dont want the file to be accessable via url or by any other client.

    The file could be an png, txt, mp4, etc.

    No I dont want to use an opne source cloud software. I want to create my own one.

    Is this possible with PHP. Do I need further software?

    Using Debian 9 and PLESK 17.8

    Thanks in advance.

  8. Hello potential helpers,

    im currently having issues with firing an ajax request inside of another ajax request.

    Heres my code: 

    Im not getting "alert(content)" :(

    Condition if(shop[1] == "gserver") and if(name.includes(shopname) == true) are definetly true.

    The function is correctly called as well.

    No Im not using jquery for reasons.

    Anyone has an idea why the 2nd requests isnt fired? Is it not waiting for the first one to finish?

    function initiate_shop_game(shopname)
    {
        var xmlhttp = new XMLHttpRequest();
        xmlhttp.onreadystatechange = function()
        {
          if(this.readyState == 4 && this.status == 200)
          {
            var obj = this.responseText;
            var array = eval("[" + obj + "]");
            var r = 1;
            for(var i = 0; i < array.length; i++)
            {
              for(var x = 0; x < array[i].length; x++)
              {
                var shop = array[i][x] + '';
                shop = shop.split(",");
                if(shop[1] == "gserver")
                {
                  var name = shop[2];
                  var imgname = shop[7]
                  var shopvalues = shop[3].split("{%TEND%}");
                  var minslots = parseInt(shopvalues[1]);
                  var maxslots = parseInt(shopvalues[2]);
                  var minram= parseInt(shopvalues[3]);
                  var maxram = parseInt(shopvalues[4]);
                  var pricea = (parseFloat(shop[5]) / 30);
                  var priceb = (parseFloat(shop[6] / 30));
                  var content = [name,imgname,minslots,maxslots,minram,maxram,pricea,priceb];
                  if(name.includes(shopname) == true)
                  {
                    var div = document.createElement('div');
                    div.id = name;
                    var xmlhttp = new XMLHttpRequest();
                    xmlhttp.onreadystatechange = function()
                    {
                      if(xmlhttp.readyState == 4 && xmlhttp.status == 200)
                      {
                        alert(content);
                      };
                      xmlhttp.open('POST',"/template_shop.php", true);
                      xmlhttp.send();
                    }
                  }
                }
              }
            }
          }
    
        };
        xmlhttp.open('POST',"/get_shop_data.php", true);
        xmlhttp.send();
    }

     

  9. Dear potential helpers,

    I try to darken the foreground of my website using a background-color.

    I created a div which wraps all my other HTML stuff, applied position: relative; to it and a very great z-Index of 999.
    All my other elements have a z-index of 100 or lower. Why isn't my div not shown in front of the other stuff?

    In case the background-color of my div foreground is only shown behind all the other elements inside it.

    Here is my HTML: 

    <html>
      <body>
          <div id="foreground">
              <!-- All my other HTML stuff having relative positioning and z-index 100 or less -->
          </div>
      </body>
    </html>

    Here is my CSS:

    #foreground
    {
    	position: relative;
    	z-index: 999;
    	display: block;
    	background-color: red;
    }

    Maybe u guys have any idea what the matter with this one. Thank you!

  10. Harrow fellow campaigners,

    no idea what is going wrong here.
    Maybe anybody has a solution:

    Assume $logged_in being true.
    check_account_status() not firing.
    Also tried to change the attribute to onclick, onmousedown etc.

    The HTML (.php):
     

    <div id="wrapper-secondnav" class="">
    	<ul id="secondnav">
    		<li><a target="_blank" href="">Stuff</a></li>
    		<li><a href="">Things</a></li>
    		<li><a target="_blank" href="">Somestuff</a></li>
    		<li><a href="">Anything</a></li>
    		<?php
    			if ($logged_in != true)
    			{
    				echo('<li><a id="register">Nooo</a></li>');
    			}
    			else
    			{
    				echo('<li><a id="register" onload="check_account_status();">Yay</a></li>');	
    			}
    		?>
    	</ul>
    </div>

    And then there is the function in JS:

    function check_account_status()
    {
        alert("I like cookies");
    }

    Thank you very much!

  11. function createCookie(name,value,days) {
        var expires = "";
        if (days) {
            var date = new Date();
            date.setTime(date.getTime() + (days*24*60*60*1000));
            expires = "; expires=" + date.toUTCString();
        }
        document.cookie = name + "=" + escape(value) + expires + "; path=/";
    }
    function user_login()
    {
    	var uname = document.getElementById('input-loginname-homepage').value;
    	var psw = document.getElementById('input-loginpassword-homepage').value;
    	var xmlhttp = new XMLHttpRequest();
    	xmlhttp.onreadystatechange = function()
    	{
    		if (this.readyState == 4 && this.status == 200)
    		{
    			if(this.responseText != "ERR")
    			{
    				var array = this.responseText.split("|");
    				createCookie("cookie_user_uname",array[0],365);
    				createCookie("cookie_user_psw",array[1],365);
    			}
    		}
    	}
    	xmlhttp.open('POST', 'ajax/login.php?uname=' + uname + '&psw=' + psw, true);
    	xmlhttp.send();
    }

    Other browser working fine. Chrome just seems to not create the cookies.
    Chrome Version 61.0.3163.100

    And no I am not trying to access the page locally (file://...)
    It`s an up an running website on the web. (https://...)

    Returned stuff via AJAX from login.php ist like "randomusername|$2y$12$bH/yQet2GxEae00PUUKmIedtkxaHZCiR5csyAzz3/3J..."

    Thank you!

     

  12. 12 minutes ago, dsonesuk said:

    Which is correct? isn't it?

    I can't see anything wrong, apart from required attribute should just be required or required="required".

    Also if the user types something, and hits enter on keyboard, it will submit form and you won't see any message at all, the function should be triggered by onsubmit on the form element, and then the JavaScript should capture that event and use preventDefault() https://www.w3schools.com/jsref/event_preventdefault.asp.

    If the form is going to be submitted and processed, a name attribute must be used on input elements to identify index name, that the value is saved to.

    I'm sorry. Meant to say the following: "If input (id="vname) is empty i only get a green 'foo'"

    I want to check if the string in input is empty if so print success else print errormsg.

    Checking for empty string isnt't working.

    vname.isEmpty()

    vname === ''

    vname.length === 0

    vname === null

     

    and reversed operators do not work.

     

    This is the entire code. I'm trying to use it with AJAX (without jquery): 

     

    nname, email, bday and msg could also be empty. But its not even working with vname.

    	<script>
    		function send_mail()
    		{
    			var vname = document.getElementById('vname').value;
    			var nname = document.getElementById('nname').value;
    			var email = document.getElementById('email').value;
    			var bday = document.getElementById('bday').value;
    			var msg = document.getElementById('textkontakt').value;
    			var xmlhttp = new XMLHttpRequest();
    			xmlhttp.onreadystatechange = function()
    			{
    				if (this.readyState == 4 && this.status == 200)
    				{
    						document.getElementById('wrapper-contact').innerHTML = this.responseText;
    				}
    			};
    			if (vname.length === 0 || vname === '' || vname == null)
    			{
    				document.getElementById('contact-response').style.color = 'red';
    				document.getElementById('contact-response').innerHTML = "Eine oder mehrere Felder sind nicht ausgefüllt<br> Anfrage konnte nicht gesendet werden!";
    			}
    			else
    			{
    				xmlhttp.open('POST', "sendmail.php?vname=" + vname + "&nname="  + nname + "&email=" + email + "&bday=" + bday + "&msg=" + msg, true);
    				xmlhttp.send();
    			}
    		}
    	</script>

    HTML: 

    <body>
    <div id="wrapper-contact">
    	<img src="\ressource\images\nydoo-title-trans.png" class="logo-small" title="Nydoo Logo (trans)" alt="Usually there should be an image here. It may be an error but could<br>also be down to a slow internet connection or a plugin installed on your browser!" id="image-title">
    	<form action="">
    		<p class="nydoo-regular font-size-12 color-white text-align-left">Es kann bis zu 2 Werktage dauern,<br> bis wir Ihre Nachricht bearbeiten<br>Sollten Sie schneller eine Antwort benötigen,<br> kontaktieren Sie uns unter +49 1573 2695219</p>
    		<input class="transform-x-50 margin-left-50percent margin-top-30 textinsert-large" type="text" id="vname" placeholder="*Vorname" required>
    		<input class="transform-x-50 margin-left-50percent margin-top-5 textinsert-large" type="text" id="nname" placeholder="*Nachname" required>
    		<input class="transform-x-50 margin-left-50percent margin-top-5 textinsert-large" type="email" id="email" placeholder="*Email" required>
    		<input class="transform-x-50 margin-left-50percent margin-top-5 textinsert-large" type="date" id="bday">
    		<textarea id="textkontakt" class="transform-x-50 margin-left-50percent margin-top-5 textinsert-large" placeholder="*Nachricht" style="height:150px" required></textarea>
    		<input class="transform-x-50 margin-left-50percent margin-top-10 button-submit-medium" onclick="send_mail()" type="button" value="Senden">
    		<p class="nydoo-regular font-size-12 color-white text-align-left">*Erforderliches Feld</p>
    		<p id="contact-response" class="nydoo-regular font-size-12 color-white text-align-left"></p>
    	</form>
    </div>
    </body>

     

  13. Dear W3schools community,

     

    I want to check if a required input is empty (has more then 0 characters). You guys have any idea what I'm doing wrong?
    Thanks in advance!

     

    If there is no character in input (id="vname") I still get a red "bar"

    Here's my code:

     

    function foobar()
    {
    	var vname = document.getElementById('vname').value;			
    	if (vname.length > 0 && vname != '' && vname != null)
    	{
    		document.getElementById('contact-response').style.color = 'green';
    		document.getElementById('contact-response').innerHTML = "foo";
    	}
    	else
    	{
    		document.getElementById('contact-response').style.color = 'red';
    		document.getElementById('contact-response').innerHTML = "bar";
    	}
    }

    I also tried length, null and '' separately. I also tried doing it with isEmpty(). Also I tried using || instead of &&. Nothing worked yet.

    Heres my HTML:

     

    <div id="wrapper-contact">
      	<form>
    		<input type="text" id="vname" placeholder="*Vname" required="yes">
        	<input type="button" onclick="foobar()" value="Senden">  
    		<p id="contact-response"></p>
    	</form>
    </div>

     

×
×
  • Create New...