Clan Adverts

Add gfx_chk to Submit News

Description: Adds gfx_chk to submit news
Version: 1.0
Added on: 29 April 2007
Author: Floppy
Difficulty Level: Intermediate
Views: 1416
Detailed Profile

edit the file modules/Submit_News/index.php, go to the line 24 of this file and add to the globals the following variable gfx_chk to the function defaultDisplay like that

Find

Code:
  global $AllowableHTML, $prefix, $user, $cookie, $anonymous, $currentlang, $multilingual, $db, $module_name, $nuke_editor;


Change To

Code:
global $AllowableHTML, $prefix, $user, $cookie, $anonymous, $currentlang, $multilingual, $db, $module_name, $nuke_editor, $gfx_chk;


now we must change the form by adding this security code in it, go to the line 96-105

Find

Code:
if ($nuke_editor == 0) {
        echo "<font class=\"content\">"._ALLOWEDHTML."<br>";
        while (list($key,) = each($AllowableHTML)) echo " <".$key.">";
        echo "</font>";
    } else {
        echo ""._HTMLNOTALLOWED."</font>";
    }
    echo "</td></tr>";
    echo "<tr><td colspan=\"2\"> </td></tr>";
    echo "<tr><td> </td><td><hr noshade size=\"1\"></td></tr>";


Change To

Code:
if ($nuke_editor == 0) {
        echo "<font class=\"content\">"._ALLOWEDHTML."<br>";
        while (list($key,) = each($AllowableHTML)) echo " <".$key.">";
        echo "</font>";
    } else {
        echo ""._HTMLNOTALLOWED."</font>";
    }
    echo "</td></tr>";
    echo "<tr><td colspan=\"2\"> </td></tr>";
    mt_srand ((double)microtime()*1000000);
    $maxran = 1000000;
    $random_num = mt_rand(0, $maxran);
    if (extension_loaded("gd") AND $gfx_chk != 0 ) {
        echo "<tr><td><b>"._SECURITYCODE.":</b></td><td><img src='?gfx=gfx_little&random_num=$random_num' border='1' alt='"._SECURITYCODE."' title='"._SECURITYCODE."'></td></tr>\n";
        echo "<tr><td><b>"._TYPESECCODE.":</b></td><td><input type=\"text\" NAME=\"gfx_check\" SIZE=\"3\" MAXLENGTH=\"3\"></td></tr>\n";
        echo "<input type=\"hidden\" name=\"random_num\" value=\"$random_num\">\n";
    } else {
        echo "<input type=\"hidden\" name=\"random_num\" value=\"$random_num\">\n";
    }
    echo "</td></tr>";
    echo "<tr><td colspan=\"2\"> </td></tr>";
    echo "<tr><td> </td><td><hr noshade size=\"1\"></td></tr>";


now we must ensure that this addition is made in the form process part to, the function PreviewStory line 126 to add 2 variables to the globals gfx_chk and sitekey

Find

Code:
global $user, $cookie, $bgcolor1, $bgcolor2, $anonymous, $prefix, $multilingual, $AllowableHTML, $db, $module_name, $nuke_editor;


Change To

Code:
global $user, $cookie, $bgcolor1, $bgcolor2, $anonymous, $prefix, $multilingual, $AllowableHTML, $db, $module_name, $nuke_editor, $gfx_chk, $sitekey;


Now go to the line 131-135

Find

Code:
    $story2 = "$f_story<br><br>$f_storyext";
    OpenTable();
    echo "<center><font class=\"title\"><b>"._NEWSUBPREVIEW."</b></font>";
    CloseTable();
    echo "<br>";


Change To

Code:
$story2 = "$f_story<br><br>$f_storyext";
    $datekey = date("F j");
    $rcode = hexdec(md5($_SERVER['HTTP_USER_AGENT'] . $sitekey . filter($_POST['random_num'], "nohtml") . $datekey));
    $code = substr($rcode, 2, 3);
    if (extension_loaded("gd") AND $code != filter($_POST['gfx_check'], "nohtml") AND $gfx_chk != 0) {
    OpenTable();
    echo "<center><font class=\"title\"><b>"._SECURITYCODEERROR."</b></font></center>";
    CloseTable();
    include ("footer.php");
    die();
    }
    OpenTable();
    echo "<center><font class=\"title\"><b>"._NEWSUBPREVIEW."</b></font>";
    CloseTable();
    echo "<br>";


the modification of this module form is now completed, you can ofcourse apply those changes to any form you want, but my advice remain do make it only for forms accessible to A.nonymous

Submitted by floppy