Jump to content

47.46.45

Members
  • Posts

    14
  • Joined

  • Last visited

    Never

About 47.46.45

  • Birthday 08/14/1989

Contact Methods

  • MSN
    47.46.45@gmail.com

Profile Information

  • Gender
    Not Telling
  • Location
    Australia

47.46.45's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi To make the operator precedence a bit more obvious I would suggest adding a couple of extra brackets if ((($win == "XP") || ($win == "Vista") || ($win == "2000") || ($win == "98") || ($win == "ME")) && ($walktype == "email")) { All the best Keith You should definitely do this, the one I posted will work for now but is going to give you headaches in the long run.
  2. Ah I see. You don't want an OR (||) then, you want an AND (&&). if (($win == "XP") || ($win == "Vista") || ($win == "2000") || ($win == "98") || ($win == "ME") && ($walktype == "email")) { Give that a try.
  3. Haha, I remember learning PHP and ActionScript at the same time... kept putting trace commands in PHP and echo commands in AS. Hurrr durrrr. Only switched to PHP when I started to move into really complicated stuff that AS was letting me down on. You should be fine with Flash for most tinkering hobby fun, and it's a nice easy language to get your head around the basics of programming. Enjoy
  4. Not a worry at all, glad to have helped. Shoot me an email or a PM if you're interested in knowing how any of it works. They're all really handy functions to know
  5. Could you paste your if statement up? Are you using double equals or singles in your conditions? If you are using the exact code I put in my last post, that will only ever eval to true if one of those conditions is met. Unless I'm missing something in my 3am stupor
  6. Try this out: // Build our function function check_email($email) { $emailArray = explode("@", $email); $ukArray = explode('.', $emailArray[1], 2); if (($emailArray[1] == "police.nsw.gov.au")||($ukArray[1] == "pnn.police.uk")) { return (1); } } // Let's test it out... $email = "doctorwho@tardis.pnn.police.uk"; if (check_email($email)) { echo "email is valid"; } Not the most elegant solution ever
  7. I'm assuming that in your actual document you closed your else and PHP tags As far as I know the proper syntax for if statements in PHP is more like if ((condition1) || (condition2) || condition3)) { echo "condition met"; } So I'd have mine like this: if (($win == "XP")||($win == "Vista")||($walktype == "email")) { You could probably debug it a little easier if you got rid of the frame stuff in the echo commands and just had an echo "conditions met"; or something similar. At the moment you aren't closing that frame tag properly, take a look at your HTML when it loads in the browser.
  8. Zhadus is spot on... should look something like this. I think. <?php $referred = $_SERVER['HTTP_REFERER']; $referred = wordwrap($referred, 20, "<br />\n", true); print "<strong>You Got Here From: (if you clicked on a link to get here)</strong>:<br />\n"; if ($referred == "") { print "Page was directly requested"; } else { print "$referred"; } ?> Tweak that 20 to adjust how soon it wraps. For bonus points: else { echo "<a href=\"".$referred."\">".$referred."</a>"; }
  9. Assuming for a second that I had the $iv stored in base 64, could I do: $plaintext = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $crypttext, MCRYPT_MODE_CBC, base64_decode($iv)); Or is that not how it's meant to work? Quick edit: sorry for the double post, I can't work out how to edit posts that are more than a few minutes old?
  10. I'd do this: <?php function check_email($email) { $emailArray = explode("@", $email); if (($emailArray[1] == "pnn.police.uk")||($emailArray[1] == "police.nsw.gov.au")) { return (1); } } ?> So you can then throw something like this into your code: $email = "sam@police.nsw.gov.au"; if (check_email($email)) { echo "email is valid"; } There's probably a more elegant way to do the dual-condition if (I'm a newbie too) but exploding around the @ is a lot tidier than splitting based on string length, especially since it's going to vary depending on the extension.
  11. There's another way you could do it... one minute while I type
  12. Out of curiosity... what's a sample email address that would pass this validation? Shouldn't they be ending with '@police.nsw.gov.au' rather than '.police.nsw.gov.au'?
  13. Thanks for the fast reply! Bit of a possible issue there - the remote device is completely beyond my control and doesn't run PHP (or any language understandable by human beings) so I have to work around it's spiteful methods of data transmission. Is this an issue? Where do you think I should implement the base64 encode / decode steps?
  14. Hi gents. New to the forum (well... sort of, I haven't actually been online since my high school days). Apologies if any of the following uses the wrong terminology, I'm a bit of a rookie. Conversely, if encryption isn't your thing, don't get scared off by all the talk of IVs and CBC - the actual issue is a lot more basic. So, on to the issue that I'm encountering. The system I'm working with operates something like this: 1. A remote device receives data from a variety of radio-linked nodes 2. Remote device generates a random IV and encrypts the data from step 1 using AES encryption, a predetermined key and the random IV. 3. Packet is prepared for sending; takes the form of [16 character IV][2 character data length][encrypted data] 4. Data is sent via a UDP socket to my server 5. Server receives packet 6. Server splits packet into IV, length, crypttext 7. Server decrypts packet Sounds simple, no? I've got the system working (more on that later) so I'll run you through an example of what goes on at the server end. We receive a packet: Which is broken down by some boring substr bits that don't need to be reproduced. For the ease of the reader I've coloured the above - red is the IV, green is the length, the rest is the encrypted data. So here's our decryption routine: $key = "DDDDDDDDDDDDDDDD"; $iv = "&:¥‹$Ý£."€¡Ñ #Ÿt"; $crypttext = "ÉêÍO¡ZígâBE…ìNñR°Ipø…0r¸Ô¶¼ &ò "ƒ5€Îvw¡BU»Ë;žzž­‰;ùÍ™Ž wƒ;EVÊ7uL´|¡¿ˆä-iÛXλüƒ4~3–zª²Ús¦6·P Gæ.æx"Ú¸bÆ%7�5y¸•X5Ø%´~?¦ñUÚþ«ˆ~Ëöêûq*Íä ± toñ²"; $plaintext = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $crypttext, MCRYPT_MODE_CBC, $iv); The output for which is: Bingo, that's exactly what we want. But, as always, something had to go disastrously wrong. Take, for example, this encrypted packet: The script splits it up into the constituent variables fine, but once we go to decrypt it... What's going on here? As you all (probably) know, data travels in a series of binary on/off pulses. This can be displayed to a terminal in raw bin, hex, dec or ascii. When PHP receives this troublesome packet, it records those binary pulses as ASCII values. Fine, that's all well and good, except that there aren't ASCII values for every hex pair. You can see why this is an issue in the above - midway through the crypttext, something that should be a "" or something is actually being recorded as an unprintable ASCII character. The decrypter hits it, which sends the whole algorithm hurtling down a different path - meaning that the rest of the packet gets junked. If these "corrupted" characters don't appear, then the script works fine. If they appear in the crypttext, everything afterwards will be ruined. If they appear in the IV, the whole packet is trashed. If they appear in the length... there is a distinct possibility the world will end. What can I do to solve this issue? I could (potentially) set my socket listener up to record the variables as binary or hex instead of ascii, thus avoiding any unprintable characters, but I don't know how to change the variable type or whatever so that mcrypt will recognise them as being binary signifiers rather than an ASCII stream of 1's and 0's. I can imagine this might be a bit overwhelming, especially considering my terrible attempts at explanation. Please ask any questions about the above... I've tried everything I can think of and am at my wit's end! Cheers, -Sam
×
×
  • 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.