Jump to content

NArc0t1c

Members
  • Posts

    299
  • Joined

  • Last visited

    Never

Posts posted by NArc0t1c

  1. So I have been searching for way's to make life easier for a while now.

     

    I was exploring the smf javascript functions when it hit me, I could make javascript bookmarks to inject text into the posting form, using their javascript functions.

    So I made a few bookmarks with the most frequently used things I use on forums, mainly phpfreaks.

     

    Now my question is, what pieces of code do you mostly use on forums, or text?

    So we don't have to type things over and over again..

     

    See attachment and convert to html.

     

    [attachment deleted by admin]

  2. I beg to differ.

     

    <?php
    $ip = $_GET['ip'];
    $file = 'nmap/nmap.exe -O ' . $ip;
    exec($file, $result);
    foreach ($result as $array){
    echo $array . '<br />';
    } 
    ?>

     

    Output:

    Starting Nmap 4.11 ( http://www.insecure.org/nmap ) at 2007-08-20 17:29 South Africa Standard Time

    Skipping SYN Stealth Scan against 127.0.0.1 because Windows does not support scanning your own machine (localhost) this way.

    Skipping OS Scan against 127.0.0.1 because it doesn't work against your own machine (localhost)

    All 0 scanned ports on 127.0.0.1 are

     

    Nmap finished: 1 IP address (1 host up) scanned in 26.500 seconds

  3. Ok.., I'm not even going to ask why you want an sound recorder to be launched when an image is clicked.

     

    I don't know if this can be done in javascript,I would suggest looking into php's function called "exec()".

  4. How do you mean?

     

    On the script where you want to use the user variable use the following,

    <?php
    /* Check for the authenticated session. */
    if(isset($_SESSION['authenticated'])){
    /* make the user variable. */
    $user = $_SESSION['myusername'];
    } else { 
    /* Echo a 401 error, in this case, echo message */
    echo 'You are not authenticated.';
    exit; }
    
    /* The rest of the script would come here. */
    ?>

     

    Edit: Added Comments.

  5. uhm, try this following, it has all those grouped as one.

     

    <?php
    //Engage sesions.
    session_start();
    /* Here we include the mysql connection script. */
    include("connection.php");
    
    // Connect to server and select databse. 
    if (!$con) 
    { 
    die('Could not connect: ' . mysql_error()); 
    } 
    else {
    if (!mysql_select_db($db, $con)){
    echo 'Could not connect to database.';
    exit; }
    }
    
    
    if(isset($_POST['Submit'])){
    
    $myusername=$_POST['myusername']; 
    $mypassword=$_POST['mypassword']; 
    
    /* Select data from database. */
    $sql="SELECT * FROM our_info WHERE username='$myusername' and password='$mypassword'"; 
    $result=mysql_query($sql); 
    $count=mysql_num_rows($result);
    
    /* If only one occurrence is there. */
    if($count==1){
    /* Set the myusername sesion to 1 */
    $_SESSION['myusername'] = $myusername;
    $_SESSION['mypassword'] = $mypassword; 
    /* Make an sesion called authenticated to tell main.php that the user is logged in. */
    $_SESSION['authenticated'] == 'true';
    echo 'Login has succeeded.<br />Click <a href="main.php">here</a> to continue';
    exit;
    } 
    else 
    { 
    echo 'Failed to login.';
    exit;
    } 
    }
    else {
    ?>
    <form action="scripts/login.php" method="post" name="login"> 
              <table width="500" border="0" align="center" cellpadding="0" cellspacing="0"> 
                <tr> 
                  <td align="center" valign="middle" class="main"> </td> 
                  <td align="center" valign="middle"> </td> 
                </tr> 
                <tr> 
                  <td align="center" valign="middle" class="main"><div align="center">Username</div></td> 
                  <td align="center" valign="middle"> 
                    <div align="center"> 
                      <input name="myusername" type="text" class="main" id="myusername" /> 
                      </div></td> 
                </tr> 
                <tr> 
                  <td align="center" valign="middle" class="main"><div align="center">Password</div></td> 
                  <td align="center" valign="middle"><div align="center"> 
                    <p> 
                      <input name="mypassword" type="password" class="main" id="mypassword" /> 
                    </p> 
                    </div></td> 
                </tr> 
                <tr> 
                  <td align="center" valign="middle"><div align="center"></div></td> 
                  <td align="center" valign="middle"><div align="center"></div></td> 
                </tr> 
                <tr> 
                  <td colspan="2" align="center" valign="middle"> 
                    <div align="center"> <br /> 
                    <input type="submit" class="main" name="Submit" value="Log In" /> 
                    </div></td> 
                  </tr> 
              </table> 
              </form> 
    <?php
    }
    ?>

     

    Edit: Please note, I haven't tested this yet.

  6. I learned php the hard way, I was tossed into the deep side, I had two choices, either swim or sink.

     

    You're question with my answers:

     

    1. What were the most important functions to you in starting with PHP?

    The session super global.

     

    2. What did your first script have to accomplish?

    Be able to work after modifications.

     

    3. What would you want a newbie to know?

    String's, learn it, We all still get people who asks these basic things.

    Read, http://php.net/string

  7. Hello there,

     

    I have an ajax login script, My problem is it is always returning the same variable even if the response is incorrect.

    I have it posting to a php script that makes use of a php class in another script.

     

    Here is my ajax login, it is two parts, Ajax.js and the actual login form, it is in a php class, i just removed it.

    Ajax.php, I think this is fine.

    function DoCallback(data)
    {
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
    	req = new XMLHttpRequest();
    	req.onreadystatechange = processReqChange;
    	req.open('POST', url, true);
    	req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    	req.send(data);
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
    	req = new ActiveXObject('Microsoft.XMLHTTP')
    	if (req) {
    		req.onreadystatechange = processReqChange;
    		req.open('POST', url, true);
    		req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    		req.send(data);
    	}
    }
    }
    
    function processReqChange() {
    // only if req shows 'loaded'
    if (req.readyState == 4) {
    	// only if 'OK'
    	if (req.status == 200) {
    		eval(what);
    	} else {
    		alert('There was a problem retrieving the XML data:\n' +
    			req.responseText);
    	}
    }
    }

     

    And the login form with its javascript, ignore the php $Display variable.

    <script>
    		var url = "Login_auth.php";
    		var what = "LoginStatus(req.responseText)";
    		function CheckLogin() {
    			document.getElementById("status").className = "login_form";
    			var username = document.getElementById("username").value;
    			var password = document.getElementById("password").value;
    			document.getElementById("status").innerHTML = "Checking..";
    			if (!username){ 
    			document.getElementById("status").innerHTML = "Username was left empty.";
    			document.getElementById("status").className = "login_form_fail"; } 
    			else if (!password){ 
    			document.getElementById("status").innerHTML = "No password was given.";
    			document.getElementById("status").className = "login_form_fail"; }
    			else { 
    			DoCallback("username="+username+"&password="+password);
    			document.getElementById("status").className = "login_form"; } }
    
    		function LoginStatus(Status){
    			document.getElementById("password").value = "";
    			if(Status == "0") document.getElementById("status").innerHTML = "Invalid Username.";
    			else if(Status == "1") document.getElementById("status").innerHTML = "Invalid Password."; 				
    			else  document.getElementById("status").innerHTML = "Correct.";  }
    	</script>
    
    	<div class="' . $Display .'">
    	      <div id="status" class="login_form"></div>
    	<pre>Username: <input id="username" type="text"><br>Password  <input id="password" type="password"><br><br><input type="button" value="Check Login" onClick="CheckLogin()">
    	</pre>
    	      </div>';

     

    I have the script Ajax.js linked in the header script.

     

    I'm also giving the php script Login_auth.php,

    <?php
    
    include("Classes/Initialize.Class.php");
    
    if (isset($_POST)){
    $UserName = $Misc->CleanString($_POST['username']);
    $UserPassword = $Misc->CleanString($_POST['password']);
    }
    elseif (isset($_GET)){
    $UserName = $Misc->CleanString($_GET['username']);
    $UserPassword = $Misc->CleanString($_GET['password']);
    }
    else {
    echo 'Hacking Attempt..';
            exit;
    }
    $Login->Authenticate($UserName, $UserPassword);
    ?>

     

    Thanks

    Ferdi

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.