Twitter Updates

Twitter Updates

    @thebandits

    Friday, August 14, 2009

    Adding ReCaptcha On PHP-Nuke (Integration)

    Once Finished you will have the option to use the site code or the ReCaptcha verifications with you PHP-Nuke Your_Account Module.

    Below are instructions on how to add ReCaptcha to the Your_Account Module In PHP-Nuke 8.0

    Files you will need:
    recaptchalib.php (from http://recaptcha.net/plugins/php/)
    config.php (from PHP-Nuke)
    index.php (from modules/Your_Account)
    recaptcha_functions.php (a file I give you)

    First Get Your Public and Private Keys from ReCaptcha.net, and put them in the recaptcha_functions.php file
    File:recaptcha_functions.php
    <?php
    /**
    * $Id: $
    * Author: Bandit-X <www.Bandit-X.Net>
    * Licence: GNU
    */
    if (!defined('MODULE_FILE')) {
    die ("You can't access this file directly...");
    }
    require_once('recaptchalib.php');
    
    $publickey = "my public key"; // you got this from the signup page
    $privatekey = "my private key";
    
    
    function recaptcha_showform()
    {
    global $publickey;
    echo "<script type=\"text/javascript\">var RecaptchaOptions = {   theme : 'white'};</script>";
    echo recaptcha_get_html($publickey);
    
    }
    function recaptcha_showtable()
    {
    global $publickey;
    echo "<tr><td colspan='2'><script type=\"text/javascript\">var RecaptchaOptions = {   theme : 'white'};</script>";
    echo recaptcha_get_html($publickey);
    echo "</td></tr>";
    }
    
    function recaptcha_check(){
    global $privatekey;
    $resp = recaptcha_check_answer ($privatekey,
    $_SERVER["REMOTE_ADDR"],
    $_POST["recaptcha_challenge_field"],
    $_POST["recaptcha_response_field"]);
    return $resp;
    }
    
    function recaptcha_error()
    {
    include_once("header.php");
    OpenTable();
    echo "<center><font class=\"title\"><b>ReCaptcha Error!</b></font><br><br>";
    echo "<font class=\"content\">The reCAPTCHA wasn't entered correctly. Go back and try it again<br>"._GOBACK."</font></center>";
    CloseTable();
    include_once("footer.php");
    
    }
    ?>
    


    Now lets Open up the index.php file from the Your_Account module, first make a backup of that file.

    > up top. search for.
    if(is_user($user)) {
    include("modules/$module_name/navbar.php");
    }
    

    > below it add.
    //Backwards Compatibility
    if((!$_POST['gfx_check']) AND ($gfx_chk == 2 OR $gfx_chk == 3 OR $gfx_chk == 4 OR $gfx_chk == 5 OR $gfx_chk == 6 OR $gfx_chk == 7)){
    if (!defined('USE_RECAPTCHA')){
    define('USE_RECAPTCHA',1);//Set 1 to use ReCaptcha, Set 0 to Disable ReCaptcha
    require_once('recaptcha_functions.php');
    }
    }
    
    if (!defined('USE_RECAPTCHA')){
    define('USE_RECAPTCHA',0);
    }
    

    ===============================================================================================
    in function confirmNewUser(

    > search for:
    if (extension_loaded("gd") 
    

    > replace with:
    if ((USE_RECAPTCHA  != 1) AND extension_loaded("gd") 
    

    > Search For:
    ."<input type=\"hidden\" name=\"random_num\" value=\"$random_num\">"
    ."<input type=\"hidden\" name=\"gfx_check\" value=\"$gfx_check\">"
    ."<input type=\"hidden\" name=\"username\" value=\"$username\">"
    

    > replace with:
    ."<input type=\"hidden\" name=\"random_num\" value=\"$random_num\">";
    if ((USE_RECAPTCHA == 1) AND ($gfx_chk == 3 OR $gfx_chk == 4 OR $gfx_chk == 6 OR $gfx_chk == 7)){
    recaptcha_showform();
    }else{
    echo "<input type=\"hidden\" name=\"gfx_check\" value=\"$gfx_check\">";
    }
    echo "<input type=\"hidden\" name=\"username\" value=\"$username\">"
    

    ===============================================================================================
    in function finishNewUser(

    > search for:
    if (extension_loaded("gd")
    

    > replace with:
    if ((USE_RECAPTCHA == 1) AND ($gfx_chk == 3 OR $gfx_chk == 4 OR $gfx_chk == 6 OR $gfx_chk == 7)){
    $resp = recaptcha_check();
    if (!$resp->is_valid){
    recaptcha_error();
    die();
    }
    }elseif ((USE_RECAPTCHA != 1) AND extension_loaded("gd") 
    

    ===============================================================================================
    function main(

    > search for:
    if (extension_loaded("gd") 
    

    > replace with:
    if ((USE_RECAPTCHA == 1)  AND ($gfx_chk == 2 OR $gfx_chk == 4 OR $gfx_chk == 5 OR $gfx_chk == 7)){
    recaptcha_showtable();
    }elseif ((USE_RECAPTCHA  != 1) AND extension_loaded("gd") 
    

    ===============================================================================================
    function new_user(

    > search for:
    if (extension_loaded("gd")
    

    > replace with:
    if ((USE_RECAPTCHA != 1) AND extension_loaded("gd")
    

    ===============================================================================================
    function login

    > search for:
    if (extension_loaded("gd") 
    

    > replace with:
    if ((USE_RECAPTCHA == 1) AND ($gfx_chk == 2 OR $gfx_chk == 4 OR $gfx_chk == 5 OR $gfx_chk == 7))
    {
    $resp = recaptcha_check();
    }
    
    if ((USE_RECAPTCHA == 1) AND (!$resp->is_valid) AND ($gfx_chk == 2 OR $gfx_chk == 4 OR $gfx_chk == 5 OR $gfx_chk == 7)){
    recaptcha_error();
    die();
    }elseif ((USE_RECAPTCHA  != 1) AND extension_loaded("gd")
    


    ===============================================================================================

    Save The File.
    Upload. recaptchalib.php and recaptcha_functions.php to the same directory as mainfile.php and config.php.
    Upload. index.php that you modified to the modules/Your_Account folder.

    Open. config.php and set the $gfx_chk variable
    # $gfx_chk: Set the graphic security code on every login screen,
    #  You need to have GD extension installed:
    #  0: No check
    #  1: Administrators login only
    #  2: Users login only
    #  3: New users registration only
    #  4: Both, users login and new users registration only
    #  5: Administrators and users login only
    #  6: Administrators and new users registration only
    #  7: Everywhere on all login options (Admins and Users)
    #  NOTE: If you aren't sure set this value to 0
    //Example:
    $gfx_chk = 3;
    


    Save And upload config.php.

    Then. Check if the ReCaptcha is working.
    PHP-Nuke/modules.php?name=Your_Account

    Thursday, July 23, 2009

    reCaptcha on the php-nuke

    Last week I kept on having issues with spam bots registering and posting their spam on this forum. I was a bit surprised that there wasn't some captcha options for php-nuke. So i went on to implementing a captcha for the registration form. So after some reading I then implemented reCaptcha on the new user registrations. It was really quite simple, the recaptcha site has examples and tons of documentation on how to use their captcha in different programming languages and also some info on how it works. Oh and for the registrations on php-nuke you only have to modify a few files to implement reCaptcha.

    How the reCAPTCHA API Works

    API diagram

    1. The user loads the web page with the reCAPTCHA challenge JavaScript embedded.
    2. The user's browser requests a challenge from reCAPTCHA. reCAPTCHA gives the user a challenge and a token that identifies the challenge.
    3. The user fills out the web page form, and submits the result to your application server, along with the challenge token.
    4. reCAPTCHA checks the user's answer, and gives you back a response.
    5. If true, generally you will allow the user access to some service or information. E.g. allow them to comment on a forum, register for a wiki, or get access to an email address. If false, you can allow the user to try again.
    http://recaptcha.net/
    resources: http://recaptcha.net/resources.html
    API: http://recaptcha.net/apidocs/captcha/

    Friday, July 17, 2009

    me updating the php-nuke

    i was currently using php-nuke 7.5 , (i personally dislike the system) . i needed to update to a newer version and it was also moving to a new server. i hoped it all goes well.

    While prepping for the update I noticed something in the update scripts. in an update script the nuke_ prefix was present and not using the correct retrieval of the system prefix it said. nuke_banner_clients.

    My Process.
    • Create A full backup. All Files + Database.
    • restore full backup on the new server
    • While the backup was restoring i downloaded nuke 8.1
    • extract the package to a folder on my desktop
    • open the config.php file from my desktop
    • compare it to the config file of the backup that was restored. (since this is one of the only files that i will delete from my desktop and not upload to the new server. i had to check for any modifications that could effect the new system)
    • i had to edit the restored version, to implements some new changes/features
    • deleted config.php from the package on my desktop
    • deleted the theme folder from my desktop
    • deleted the install folder from my desktop
    • uploaded files that were left on the desktop package
    • upload update files. (updates the database)
    • wait for upload of files to complete (since this took the longest. 40 minutes for me)
    • create new database backup from old server and restored on new server
    • run them update files
    • then view site (the new one)
    • verify everything is ok.
    • delete update files.
    • also did a update on the forum (even though it included a forum update. there was another greater than what is in the package . so i updated it)
    • change dns name servers.
    • shut down old site (site A) forum and leave a message .
    • (return hours later)
    well it turned out ok. this was done back in March.2009.

    Issues:
    • it took a few days to get login info to change the dns servers
    • finding a download link for php-nuke took longer than a few clicks. you have to do a bit of searching
    • i was worried about the forum the most. since the update included an update to the forum, plus i got an even newer forum package that was to be updated .
    • my paranoia made me read through every one of those update scripts.
    • i modified my HOSTS file on my computer and forgot to change it back so i didn't notice the dns changes.
    • i couldn't verify if all files were uploaded. so i ran the checksum script that xoops has.

    Monday, June 22, 2009

    SourceForge.net Community Choice Awards 2009 Voting. BEGIN!

    There are so many choices that I have not voted yet. There are many of my favorites in the same category. What I did notice is that portableApps (one of my favorite things i use when i am on campus) is on there for multiple categories. There are projects like TortoiseSVN, PhpMyAdmin, FreeNAS, PortableApps, WinMerge, Notepad++ on there that are some I use quite a bit. There are also some i haven't heard of before, but they too sound interesting to me.

    Voting Ends July 20th.
    http://sourceforge.net/community/cca09/

    Monday, June 15, 2009

    I Should Really Park My Car In The Garage More Oftern, No Joke.

    So about every year I've had this car, i seem to be going to the body shop and getting something fixed. Last year it was a dent on the rear quarter panel. And Now Last night on my driveway someone hit the side of my car. I included the links to some images. Photo 1 Photo 2 Photo 3 . It's difficult keeping a new car new.

    Monday, June 08, 2009

    On The 11th Day. A Miracle Happened, Well Not Really

    At The End Of May I Applied For An APT (Abandoned Project Takeover) On SF.Net . In A Day Or So, It Was Approved. The Journey Doesn't End There Though, Since It Takes 2-3 Weeks To Process. So Everyday I Would Log in and Check On Its' Status. But On The 11th Day I Couldn't Find It But Then I Noticed I Became A Project Admin Of The xoopsmy Project.
    Why Did I Request An APT?
    - SMD Had Issues With Retrieving His Password And This Was The Next Best Thing To Do.

    Should You Expect A Release Of XM-Spotlight Soon?
    - No. Cause I Have No Clue On What To Number It, But I'm Thinking Maybe 1.04 Alpha. I Also Got a Feature Request Thread On Bandit-X.Net
    - That Doesn't Solve The Issue With Current Users With No Download Of XM-Spotlight, So I Will Have To Release a 1.02 Final, But I Think I Used That Release Already. And Also Version Numbers That Extends Farther Then The Hundreths Place Do Not Show Up In The Admin.

    Oh And I Need To Make A New Changelog, The Current One Is Missing.

    Saturday, May 09, 2009

    Oh Where Did Bandit Go?


    Hi Hi, I've been away for a while and quite busy also. Final exams have been over for about a week now. They were quite difficult. So what have I been doing since then? I have been taking it easy, i went to spectate a drifting event. Speedrift 14 on May 3rd (the image on the right is from Speedrift). And the rest of the week was me doing yard work or fixing my lawn mower. i also joined a tractor forum, i don't own a tractor but there are quite a few lawn boy fans on there. Lawn-Boy 20+ years FTW!

    I'm not going to jump in and start coding stuff, right now i have to get my stuff organized. my room is a mess. my computer is a mess, there are so many random files and folders taking up space and cluttering up things.