Jump to content
xisto Community

SystemWisdom

Members
  • Content Count

    118
  • Joined

  • Last visited

Posts posted by SystemWisdom


  1. I wrote a script like this not too long ago...

    The theory is: You make a random string, save that random string to your sessions (for later comparison), and then generate and output the image..

    First, the class file:

    <?phpclass TuringImage{    // Font Settings    var $m_szFontFace;    var $m_iFontSize;        // Image Object    var $m_oImage;    // Image Bounds    var $m_aImageSize;    // Image Text    var $m_szImageText;    function TuringImage()    {        // Font Settings        $this->m_szFontFace = 'fonts/mtcorsva.ttf';        $this->m_iFontSize  = 20;        $this->m_oImage = 0;        $this->m_aImageSize = array( 110, 40 ); // Image Width & Height        $this->m_szImageText = '';    }    function GenerateKey( $iLen )    {        $szRandStr = md5( uniqid( rand(), true ) );        $iRandIdx = rand( 0, (strlen($szRandStr) - $iLen - 1) );        $szRandStr = substr( $szRandStr, $iRandIdx, $iLen );                // Replace O's and 0's to reduce confusion        $szRandStr = str_replace( "O", "X", $szRandStr );        $szRandStr = str_replace( "0", "4", $szRandStr );                $this->m_szImageText = strtoupper( $szRandStr );        return;    }    function GetKey()    {   return $this->m_szImageText;    }    function Create()    {        $iTextLen = 5;                // Create Image        $this->m_oImage = imagecreate( $this->m_aImageSize[0], $this->m_aImageSize[1] );        // Get Colors        $oColorFG = imagecolorallocate( $this->m_oImage, 143, 168, 183 );        $oColorBG = imagecolorallocate( $this->m_oImage, 30, 42, 49 );        // Set Background Color of Image        imagefilledrectangle( $this->m_oImage, 0, 0, $this->m_aImageSize[0], $this->m_aImageSize[1], $oColorFG );        imagefilledrectangle( $this->m_oImage, 1, 1, $this->m_aImageSize[0]-2, $this->m_aImageSize[1]-2, $oColorBG );        // Obfuscate Image        $this->ObfuscateImage();                // Write Verification String to Image        for( $i = 0; $i < $iTextLen; $i++ )            $this->WriteTTF( (10 + ($i * 18)), (24 + rand(0, 5)), rand(-15, 15), $this->m_szImageText[$i] );                // Output Image to Browser        imagegif( $this->m_oImage );        // Free Image Resources        imagedestroy( $this->m_oImage );        return;    }    function ObfuscateImage()    {        $oColor = imagecolorallocate( $this->m_oImage, 143, 168, 183 );                // Random Pixels        for( $x = 0; $x < $this->m_aImageSize[0]; $x += rand( 3, 7 ) )            for( $y = 0; $y < $this->m_aImageSize[1]; $y += rand( 3, 7 ) )                imagesetpixel( $this->m_oImage, $x, $y, $oColor );                // Random Diagonal Lines        for( $x = 0; $x < $this->m_aImageSize[0]; $x += rand( 15, 25 ) )            imageline( $this->m_oImage, $x, 0, $x + rand( -50, 50 ), $this->m_aImageSize[1], $oColor );        for( $y = 0; $y < $this->m_aImageSize[1]; $y += rand( 15, 25 ) )            imageline( $this->m_oImage, 0, $y, $this->m_aImageSize[0], $y + rand( -50, 50 ), $oColor );        return;    }    function WriteTTF( $iLocX, $iLocY, $iAngle, $szText )    {        $oColor = imagecolorallocate( $this->m_oImage, 255, 255, 255 );        imagettftext( $this->m_oImage, $this->m_iFontSize, $iAngle, $iLocX, $iLocY, $oColor, $this->m_szFontFace, $szText );    }}?>

    Now, that class uses a True-Type font, which you can find in your c:\windows\fonts\ directory, but it should be placed in your web server where the script can access it..

    Next, you will want to output that image.. something like:

    // Create Turing Test Object$oTuringTest = new TuringImage();$oTuringTest->GenerateKey( 5 );  // Length of Key (5)// Store key in sessions for later comparison$_SESSION['SECURITY_KEY'] = $oTuringTest->GetKey();// Set Content Type to GIF with NoCacheheader( 'Content-type: image/gif' );header( 'Expires: ' . gmdate('D, d M Y H:i:s') . 'GMT' );header( 'Cache-control: no-cache' );// Output Image$oTuringTest->Create();

    Now, all you need to do, is create a form that will allow the user to enter the text they see, and then submit that form back to one of your PHP pages, where you can then get the Posted Form variable, and compare it with the session value.. If it is correct, well, you know what to do!!

    I hope that helps!

  2. Well, it sounds like you have not made a connection to the database yet... Have you called the mysql_connect() function? And have you passed it valid parameters??

    You should do something like:

    $connection = mysql_connect( "server", "username", "password" );$db = mysql_select_db( "shadow_member", $connection )    or die ("couldn't select databse.");

    I hope that helps!!

    Oh, and if you have used the connect statement already, then make sure it is correct..

  3. Counter-Strike (whether it is Steam or HL2)

    Tekken Tag Tournament

    Fable

    Might & Magic VIII

    Halo 1 & 2

    GTA (All of them, even the 2D ones were addictive when they came out)

    Final Fantasy Series (Except the originals in 2D, I hated them :ph34r:)

    Counter-Strike

    Counter-Strike

    Counter-Strike

    Yes I like CS.. my fav game of all time! I couldn't think of any more I would call favorite *that I've played*, and CS PWNS sooo much that I thought I would use it to fill in the gaps! :D

  4. I think first, it would help to know the data type of the values in your array, but in any case, I don't think it matters as long as your hardware can support such extreme sizes (in other words, do you have enough RAM?)..On an off-note, why are you using such large arrays? Wouldn't it be possible to seperate your data logically into several smaller chunks first, so as to work with smaller arrays?


  5. You could create custom DTDs and host them on your server, then point your pages to use that DTD.. But then most validators wont validate for you cuz you're not using an approved DTD...Besides the fact that creating a new DTD just to validate new tags in an XHTML document is rather pointless, as the extensibility of it is good enough as it is..Anyway, try google searching for "Custom DTDs" and stuff..


  6. Try something like this:

    <?php  switch ($_GET['page']) {  case "members":  	include 'members.php';  	break;  case "diplomacy":  	include 'diplomacy.php';  	break;  case "scrims":  	include 'scrims.php';  	break;  case "forums":  	include 'forums.php';  	break;  default:  	include 'home.php';  	break;  }?>

    I hope that helps!

  7. Yes, what you want is possible, and can be done with only XHTML & CSS using DIVs and SPANs, but can be somewhat tricky to master..

    I suggest reading anything you can from this site: CSS Zen Garden

    Remember, the complete style & layout can be modified with CSS alone!
    When you view the site, there are links on the left and each of them point to the exact same XHTML file, but with a different CSS file to apply style & layout.. you will see just how much is possible with CSS in controlling layout..

    Good luck in your studies!!


  8. I see no trick to the question other than the fact that it never actually states that any of them own a fish (it is merely implied), and thus none of them own a fish.. BUT, assuming one of them does own a fish, then it is a very well-thought-out application of pratical logic, and following the hints that are given, one can deduce that the German owns the Fish as a pet. However, don't be fooled by the thrill of having solved it, for it still takes us all very long, and can not be compared to any of the questions found within the same category on modern IQ tests. Being restricted to a time limit with dozens of questions (this being only one of them) I suspect that 98% of the people would skip this question, and move on to other questions, planning to come back to it later, but when they do, and spend 30+/- mins on that question alone, they eventually run out of time and haven't finished solving it.. Not to mention, that Einstein lived during times lacking modern education for the masses, and it is quite possible that his suggested 98% could be lower now with current standards of education.Even still, this is a brilliantly thought-out question, and deserves great appreciation, in my humble opinion.Just think, if it is that hard to solve it, how hard would it have been to have written it in the first place?


  9. Well, I pretty much agree with most of the posts above, but when it comes down to actually "making" the website, I always start in my favorite image editting software (Photoshop) and build the template in there.. It is easy because you can add mock tables and borders to see how it looks, and then erase them (because they can be done with CSS or something).. even adding text to see how it looks is simple,and helps the design of your page go smoother.. From there, you chop up the large image template into smaller workable pieces and construct your HTML code to put it all back together with the contained content (ImageReady works well for slicing images, but it is not hard, and sometimes more precise, to do it manually in photoshop)..Anyway, that's how I do it..


  10. My main purpose for me with this little bit of code (sorry if my last post mislead any of you, hope not) in my opinion, is to display that info on my site for my visitors, with an explanation of what it is, and how to prevent it.. I am personally not too concerned about the exploit for many reasons, many of which have already been discussed, but the main reason it doesn't bother me, is because I don't use CCs on my computer and passwords are only half of the key into any site.. Anyway, my interest is in displaying this info to users, similar to how many sites display the users IP address.. I may even add this handy little code bit to my Dynamic Signature!! :PAgain, thx for posting it! Ima have fun with it!! lol


  11. Try this:

    while ($checking = mysql_fetch_array($check)){            $usr = $checking['loguser'];            $mail = $checking['logemail'];                                $error = 0;                                            if ($mail == $email){                        $errormsg = "the email address you have chose is already taken";                        $error = 1;                        }                                if ($usr == $user) {                        $errormsg= 'the username you have chosen is already taken';                        $error = 1;                        }        }                        if (strlen($user) < '5') {                        $errormsg= 'the username is too short';                        $error = 1;                        }                                                if (eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $email)) {                        $errormsg= 'the email address isnt a valid email address';                        $error = 1;                            }                                                if (strlen($password) < '9') {                        $errormsg= 'the password is too short it must be at least 8 characters';                        $error = 1;                        }                                                if ($error) {                        echo $errormsg;                    }                    else {                                                    $pass = md5($password);        mysql_query("INSERT INTO login (loguser, logpass, logname, logsurname, logaddress, logarea, logcounty, logpostcode, logtelephone, logni, logemail, logcompanyid, logaccess)        VALUES ('$user', '$pass', '$name', '$surname', '$address', '$area', '$county', '$postcode', '$telephone', '$ni' '$email', '$companyid', '".$_POST['access']."')") or die (mysql_error());                                        header("Location: ../index.php");                    }

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.