Jump to content

Drezard

Members
  • Posts

    244
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Drezard's Achievements

Advanced Member

Advanced Member (4/5)

0

Reputation

  1. Writing an app that requires symmetric encryption. I need to be able to have a key (such as 123) and be able to use this key and encrypt a string. Then decrypt the string later using the same key. This encryption needs to be pretty robust and unbreakable. Any functions or suggestions?!? Thinking of using the mcrypt library in some way. Drez
  2. Thanks heaps for the help. I kind of get whats going on here... Need a bit more reading of basic AJAX maybe.
  3. It fails on that line. So basically. It loads AJAX. It runs the javascript code (if I put alerts in) up to that line and then does nothing past that line. It doesn't output anything to screen either. It doesn't throw the "sent null?" alert.
  4. My basic ajax example. It fails on this line here: httpObject.open("GET", "test.php?keyword=" +document.getElementById('keyword').value, true); Except I'm not sure why. Heres the whole code: <html> <head> <script type="text/javascript"> function getHTTPObject(){ if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP"); else if (window.XMLHttpRequest) return new XMLHttpRequest(); else { alert("Your browser does not support AJAX."); return null; } } function doWork(){ httpObject = getHTTPObject(); if (httpObject != null){ httpObject.open("GET", "test.php?keyword=" +document.getElementById('keyword').value, true); alert("sent null?"); httpObject.onreadystatechange = setOutput; } } function setOutput(){ if (httpObject.readyState == 4){ alert("Ready state does equal 4"); document.getElementById('output').innerHTML = httpObject.responseText; } } </script> </head> <body> <form name="keywordform"> Search: <input type='text' name='keyword' onkeyup="doWork();" id ="1" /> </form> <div id='output'>blank</div> </body> </html> Any help?
  5. I'm writing a bit of code that uses this query: "SELECT * FROM articles WHERE link='".$link."'" When I execute this in the mysql console such as : SELECT * FROM articles WHERE link='http://www.theage.com.au/travel/travel-news/nerd-bird-flies-like-a-brick-20100326-r0eh.html; It works perfectly. Displays the results I want... But when I try and do the same query with PHP I get : Ideas anyone? I'm guessing its formatting? Daniel
  6. Usually I can use code like this: <?php if (!isset($_GET['submit'])) { echo "<form method='get'> Search: <input type='text' name='keywords'> <br /> <input type='submit' name='submit'> </form>"; } else { echo $_GET['keywords']; } ?> And it will echo the keywords when you enter them... but for some reason that form, wont submit the 'submit' variable. Whats going on? Daniel
  7. When I run this script here: <?php $senderName = "System"; $senderEmail = "system@example.local"; $mailTo = "daniel@example.com"; $mailHeader = "From: " . $senderName . " <" . $senderEmail . ">\r\n"; $mailSubject = "Callback\r\n"; $mailMessage = "Test Msg\n"; if ((mail($mailTo, $mailSubject, $mailMessage, $mailHeader)) != 1) { echo "The callback failed to send.\n"; } else { echo "Mail sent successfully.\n"; } ?> It sends an email to my account and I get the email. But it has this big ugly header at the top: How do I get rid of this? Daniel
  8. Change the url to: What if I wanted to do it using Regex tho? Daniel
  9. Guys, Im trying to make a script that will create a list of our competitors with a couple of details from the local phone book website. Im using CURL to pull the data down (and as you can see, if you run it, it should work), it then dumps all of the HTML into $buffer. I then want to know (just for this example, then I'll build on it), how many of the lines contain the string "phoneNumber". It should be ATLEAST 5 - 10. So far $count only prints 1 at the end. Any ideas why? Script: #!/usr/bin/php -q <?php $url = "http://www.yellowpages.com.au/search/postSearchEntry.do?clueType=0&clue=computers&locationClue=Mordialloc%2C+VIC&x=0&y=0"; $chandle = curl_init(); curl_setopt($chandle, CURLOPT_URL, $url); curl_setopt($chandle, CURLOPT_CONNECTTIMEOUT, 2); curl_setopt($chandle, CURLOPT_RETURNTRANSFER, 1); $buffer = curl_exec($chandle); curl_close($chandle); $array = explode("\r", $buffer); $size = sizeof($array); $i = 0; $count = 0; while ($i < $size) { $regex = preg_match("/phoneNumber/", $array[$i]); if ($regex == 1) { $count++; } $i++; } print $count . "\n"; ?> Thanks, Daniel
  10. I work as a Network Engineer and we get a number of customers who forgot their modem passwords. So, Im trying to write a Curl script (and slowly learning Curl as well). Ive written a test script, which is here: <?php // curl.php $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, 'http://www.rootedbox.info/curl/http-protocol/protected/'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_USERPWD, 'admin:password'); $output = curl_exec($curl); $info = curl_getinfo($curl); if ($info['http_code'] == 401) { echo "Password is incorrect"; } else { echo "Password is: password"; } curl_close($curl); ?> How do I make it so that it doesn't display the page returned.... So currently, when I run this script, it displays the "401 - Error" and then my "The password is...." bit. I want it ONLY to display the "The password is..." bit. Daniel
  11. nope. even when I changed it, it still wouldn't work. the code for deleting the cookie is: Daniel
  12. Im writing an app that uses cookies. Now... my code to create a cookie looks like this: // my cookie creation setcookie("USER_SESSION", ($this->user_id . "+|+" . $this->password), (time() + 900)); my code to delete the cookie looks like this: // my cookie deletion setcookie("USER_SESSION", "", ((1-time())-900)); The cookie creates but it wont delete. Whats wrong? Daniel
  13. Drezard

    Spaces

    The code: $return = exec('df'); Only returns the last line. How do I get it to return EVERY line? I want all of the info from the df command. Daniel
  14. Drezard

    Spaces

    <?php $return = exec('df'); $returnarray = explode(' ', $return); ?> it has FARR too many spaces the $returnarray because df returns something along the lines of: how would i take out all of the spaces???? in the array so instead it would be like $return array[0] = 'Filesystem'; and $returnarray[6] = '/dev/sda'; and $returnarray[7] = '36622412'; How would i do this???
  15. Is there a function in PHP thats like Sleep() in C? Daniel
×
×
  • 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.