Foros
Insertar código de seguridad en módulo
Autor Fecha: 01 de Septiembre del 2007 a las 15:17:17   Descripción: Ninguna
Sin avatar
Sexo: Masculino
Mensajes: 344
Hola, me gustaría insertar un código de seguridad en este módulo, como podría hacerlo?

Os dejo el código:

Código
<?php

// Adaptaci&#36152;n del m&#36152;duio al NukeET 3.2 y mejoras de seguridad por truzone http://www.truzone.org

if(!defined('NUKE_ET')){
    Header("Location: ../error.php?op=e403");
    die();
}

if(isset($_GET[basepath]) || isset($_GET[baseurl]) || isset($_GET[adminurl]) || isset($_GET[adminpath]) || isset($_GET[ModName]) || isset($_GET[tmppath]) || isset($_GET[languagepath]) || isset($_GET[imagepath]) || isset($_GET[gallerypath])){ die("perraco"); }

function navigationPic($name, $gid, $pid, $orderby) {
        global
                $baseurl,
                $basepath,
                $font,
                $prefix, $db
        ;

        $orderbyA = convertorderbyin($orderby);
        $sql = "SELECT pid, name FROM $prefix"._gallery_pictures." where gid=$gid ORDER BY $orderbyA";
        $res = $db->sql_query($sql);
        $max = $db->sql_numrows($res);
        $ind = getPos($res, $pid);
        if ($ind>0) {
                $prev = mysql_result($res, $ind-1, 0);
                $pname = mysql_result($res, $ind-1, 1);
        }
        if ($ind<$max-1) {
                $next = mysql_result($res, $ind+1, 0);
                $nname = mysql_result($res, $ind+1, 1);
        }

        $out = '<p align="center">';
        /*$out .= '<font class="'.$font['normal'].'">&lt;&lt; </font>';
        if ($prev)
                $out .= '<a class="'.$font['normal'].'" href="'.$baseurl.'&amp;do=showpic&amp;gid='.$gid.'&amp;pid='.$prev.'&amp;orderby='.$orderby.'">'._GALPREV.'</a><font class="'.$font['normal'].'"> | </font>';
        else
                $out .= '<font class="'.$font['normal'].'">'._GALPREV.'</font> <font class="content"> | </font>';
        if ($next)
                $out .= '<a class="'.$font['normal'].'" href="'.$baseurl.'&amp;do=showpic&amp;gid='.$gid.'&amp;pid='.$next.'&amp;orderby='.$orderby.'">'._GALNEXT.'</a>';
        else
                $out .= '<font class="'.$font['normal'].'">'._GALNEXT.' </font>';
        $out .= '<font class="'.$font['normal'].'"> &gt;&gt;</font>';
        */
        if ($prev)
                $out .= '<a class="'.$font['normal'].'" href="'.$baseurl.'&amp;do=showpic&amp;gid='.$gid.'&amp;pid='.$prev.'&amp;orderby='.$orderby.'"><img src="'.$basepath.'/images/left.gif" alt="'._GALPREV.'" border="0" align="middle "></a><font class="'.$font['normal'].'"> ';
        else
                $out .= '<img src="'.$basepath.'/images/left.gif" alt="'._GALPREV.'" border="0" align="middle "> ';

        //$out .= '<font class="content"> | </font>';
        $out .= '<font class="'.$font['title'].'"> - '.$name.' - </font>';

        if ($next)
                $out .= '<a class="'.$font['normal'].'" href="'.$baseurl.'&amp;do=showpic&amp;gid='.$gid.'&amp;pid='.$next.'&amp;orderby='.$orderby.'"><img src="'.$basepath.'/images/right.gif" alt="'._GALNEXT.'" border="0" align="middle "></a>';
        else
                $out .= '<img src="'.$basepath.'/images/right.gif" alt="'._GALNEXT.'" border="0" align="middle ">';

        $out .= '</p>';
        return $out;
}


function displayPicturePic($row, $size) {
        global
                $gallerypath
        ;
        $template = $row[displaytag];
        $template = str_replace('<:FILENAME:>', "$gallerypath/$row[galloc]/$row[imagen]", $template);
        $template = str_replace('<:WIDTH:>', $size[0], $template);
        $template = str_replace('<:HEIGHT:>', $size[1], $template);
        $template = str_replace('<:DESCRIPTION:>', $row[description], $template);
        return $template;
}

function displayDescriptionPic($row) {
        global
                $bgcolor1,
                $bgcolor2,
                $font
        ;
        /*if(!$displaydescription) {
                return;
        }*/
        if ($row[description]!="")
        return '<center><table border="0" cellpadding="2" cellspacing="2" width="80%"">'
                .'<tr>'
                .'<td align="left" bgcolor="'.$bgcolor2.'" valign="top" width="'.strlen(_GALDESCRIPTION).'"><font class="content">'._GALDESCRIPTION.'&nbsp;</font></td>'
                .'<td align="left" bgcolor="'.$bgcolor1.'" valign="top"><font class="'.$font['normal'].'">'.$row[description].'</font></td>'
                .'</tr>'
                .'</table>'
        ;
        else return "";
}

function displaySizePic($row, $size) {
        global
                $gallerypath,
                $font
        ;
        return '<font class="content'.$font['normal'].'b>'.underscoreTospace($row[name]).'</b></font><br><font class="'.$font['normal'].'">['.$size[0].' x '.$size[1].' '.substr($row[imagen],strrpos($row[imagen], '.')+1).']</font>';
}

function displayDateAddedPic($row) {
        global
                $bgcolor1,
                $bgcolor2,
                $font
        ;
        return '<table cellpadding="0" width="160">'
                .'<tr>'
                .'<td width="90" align="left" bgcolor="'.$bgcolor2.'"><font class="'.$font['tiny'].'">'._GALADDED.'</font></td>'
                .'<td width="70" align="left" bgcolor="'.$bgcolor1.'"><font class="'.$font['tiny'].'">'.strftime(_GALDATEBRIEF, $row[unix_time]).'</font></td>'
                .'</tr>'
                .'</table>'
        ;
}

function displaySubmitterPic($row) {
        global
                $bgcolor1,
                $bgcolor2,
                $font,
                $prefix, $db
        ;
        $result = $db->sql_query("SELECT * FROM $prefix"._users." where username='".$row[submitter]."'");
        if($db->sql_numrows($result)>0) {
                $row[submitter] = '<a href="modules.php?name=Your_Account&amp;op=userinfo&amp;username='.$row[submitter].'" target="_blank">'.$row[submitter].'</a>';
        }
        return '<table width="160">'
                .'<tr>'
                .'<td width="90" align="left" bgcolor="'.$bgcolor2.'"><font class="'.$font['tiny'].'">'._GALSUBMITTER.'</font></td>'
                .'<td width="70" align="left" bgcolor="'.$bgcolor1.'"><font class="'.$font['tiny'].'">'.$row[submitter].'</font></td>'
                .'</tr>'
                .'</table>'
        ;
}


function displayHitsPic($row) {
        global
                $bgcolor1,
                $bgcolor2,
                $font
        ;
        return '<table width="160">'
                .'<tr>'
                .'<td width="90" align="left" bgcolor="'.$bgcolor2.'"><font class="'.$font['tiny'].'">'._GALHITS.'</font></td>'
                .'<td width="70" align="left" bgcolor="'.$bgcolor1.'"><font class="'.$font['tiny'].'">'.$row[counter].'</font></td>'
                .'</tr>'
                .'</table>'
        ;
}


function displayRatePic($row) {
        global
                $galleryvar,
                $bgcolor1,
                $bgcolor2
        ;
        if(!$galleryvar['allowrate']) {
                return;
        }
        return '<table width="160">'
                .'<tr>'
                .'<td width="90" align="left" bgcolor="'.$bgcolor2.'"><font class="'.$font['tiny'].'">'._GALVOTES.'</font></td>'
                .'<td width="70" align="left" bgcolor="'.$bgcolor1.'" ><font class="'.$font['tiny'].'">'.$row[votes].'</font></td>'
                .'</tr>'
                .'<tr>'
                .'<td width="90" align="left" bgcolor="'.$bgcolor2.'"><font class="'.$font['tiny'].'">'._GALRATING.'</font></td>'
                .'<td width="70" align="left" bgcolor="'.$bgcolor1.'"><font class="'.$font['tiny'].'">'.$row[rate].'</font></td>'
                .'</tr>'
                .'</table>'
        ;
}

function displayRatingBarPic($row, $orderby) {
        global
                $galleryvar,
                $user,
                $baseurl,
                $imagepath,
                $font
        ;
        if(!$galleryvar['allowrate']) {
                return;
        }
        if(!$galleryvar['anonrate'] || $user) {
                return  '<form action="'.$baseurl.'&amp;do=Vote" method="post">'
                        .'<input type="hidden" name="pid" value="'.$row[pid].'">'
                        .'<input type="hidden" name="orderby" value="'.$orderby.'">'
                        .'<table width="160" border="0" cellpadding="2" cellspacing="1" align="center">'
                        .'<tr>'
                        .'<td align="right" valign="middle">'
                        .'<select name="rate">'
                        .'<option value="1">1</option>'
                        .'<option value="2">2</option>'
                        .'<option value="3">3</option>'
                        .'<option value="4">4</option>'
                        .'<option value="5">5</option>'
                        .'<option value="6">6</option>'
                        .'<option value="7">7</option>'
                        .'<option value="8">8</option>'
                        .'<option value="9">9</option>'
                        .'<option value="10" selected>10</option>'
                        .'</select>'
                        .'</td>'
                        .'<td align="left" valign="middle">'
                        .'<input src="'.$imagepath.'/rate.jpg" type="image">'
                        .'</td>'
                        .'</tr>'
                        .'</table>'
                        .'</form>'
                ;
        }
        else {
                return '<font class="'.$font['tiny'].'">'._GALMEMBERSRATE.'</font>';
        }
}

function displayCommentsPic($pid, $orderby) {
   global
           $adminpath,
           $user,
        $baseurl,
        $admin,
        $imagepath,
        $prefix, $db,
        $font
   ;

   include("$adminpath/config.php");

        $out = '<br><center><p align="center">';
        $out .= '<font class="'.$font['title'].'">'._GALCOMMPOST.'</font></p><br><br>';

        $result3 = $db->sql_query("select cid, pid, comment, date, name, member from $prefix"._gallery_comments." where pid=$pid order by date ASC");
        if ($db->sql_numrows($result3) == 0) {
                $out .= '<p align="center"><font class="content">'._GALNOCOMM.'</font></p><br>';
        }
        else {
                $out .= '<TABLE border="0" bgcolor="white" cellPadding="2" cellSpacing="2" width="80%" align="center">';

                while(list($cid, $cpid, $comment, $date, $name, $member) = $db->sql_fetchrow($result3)) {
                        if ($member)
                                $poster = '<a class="'.$font['normal'].'" href="modules.php?name=Your_Account&op=userinfo&amp;username='.$name.'">'.underscoreTospace($name).'</a>';
                        else
                                $poster =  '<font class="'.$font['normal'].'">'.underscoreTospace($name).'</font>';

                          $out .= '<TR>';

                $out .= '  <TD align="center" bgColor="'.$bgcolor2.'" vAlign="top" width="140"><font class="'.$font['normal'].'">'.$poster.'<br>('.substr($date,0,10).')</font></TD>'
                        .'  <TD align="left" bgColor="'.$bgcolor1.'" vAlign="top"><font class="'.$font['normal'].'">'.$comment.'</font></TD>';

                if (is_admin($admin))
                        $out .= '  <TD align="center" width="30"><a href="'.$baseurl.'&amp;do=deletecomment&amp;cid='.$cid.'&amp;pid='.$pid.'&amp;orderby='.$orderby.'" onClick="return confirm(''._GALSURE2DELETECOMMENT.'')">'
                             .'<img src="'.$imagepath.'/delete.gif" border="0" alt="'._DELETE.'"></a></td>';

                $out .= '</TR>';
                } //while
                $out .= '</TABLE>';
        }
        print '<br><br>';
        if (is_user($user)) {
                $userdata=cookiedecode($user);
                $out .=
                '<p align="center"><form action="'.$baseurl.'" method="POST">'
                .'<input type="hidden" name="do" value="Post">'
                .'<font class="'.$font['title'].'">'._GALNAME.'</font>&nbsp;<b>'.$userdata[1].'</b>'
                       .'<input type="hidden" name="gname" value="'.$userdata[1].'">'
                       .'<input type="hidden" name="member" value="1"><br>'
                .'<font class="'.$font['title'].'">'._GALCOMMENT.'</font><br>'
                  .'<input class="textbox" type="text" name="comment" size="70" maxlength="70"><br>'
                  .'<input class="textbox" type="hidden" name="pid" value="'.$pid.'">&nbsp;'
                  .'<input type="submit" value="Post">'
                .'</form>'
                .'<font class="option">'._GALNOTE.'</font></p>';
        }
        elseif (!$galleryvar['anoncomments']) {
                $out .=
                '<p align="center"><form action="'.$baseurl.'" method="post">'
                .'<input type="hidden" name="do" value="Post">'
                .'<font class="'.$font['title'].'">'._GALNAME.'</font><br>'
                     .'<input type="text" SIZE="20" MAXLENGTH="20" name="gname">'
                     .'<input type="hidden" name="member" value="0">'
                     .'<br><font class="'.$font['title'].'">'._GALCOMMENT.'</font><br>'
                .'<input class="textbox" type="text" name="comment" size="70" maxlength="70"><br>'
                .'<input class="textbox" type="hidden" name="pid" value="'.$pid.'">&nbsp;'
                .'<input type="submit" value="Post">'
                .'</form>';
//                .'<font class="option">'._GALNOTE.'</font></p>';
        }
        else {
                $out .= '<p align="center"><font class="'.$font['tiny'].'">'._GALREGISTER."</font></p>";
        }
  return $out;
}

function getPos($res, $pid) {
        global $db;
        $i=0;
        while ($row=$db->sql_fetchrow($res)) {
                if ($row[pid] == $pid)
                        return $i;
                $i++;
        }
}


function rateCollector($pid, $rate) {
    global
            $cookiePrefix,
            $HTTP_COOKIE_VARS,
            $adminpath,
        $prefix, $db
    ;

    include ("$adminpath/config.php");

    // Fix for lamers that like to cheat on polls
    $ip = getenv("REMOTE_ADDR");
    $past = time()-1800;
    $db->sql_query("DELETE FROM $prefix"._gallery_rate_check." WHERE time < $past");
    $result = $db->sql_query("SELECT ip, pid FROM $prefix"._gallery_rate_check." WHERE pid=$pid");
    list($ips, $pids) = $db->sql_fetch_row($result);
    $ctime = time();
    if (($ip == $ips) && ($pid == $pids)) {
        $voteValid = 0;
    } else {
        $db->sql_query("INSERT INTO $prefix"._gallery_rate_check." (ip, time, pid) VALUES ('$ip', '$ctime', '$pid')");
        $voteValid = 1;
    }
    // Fix end

    if($setRateCookies>0) {
        // we have to check for cookies, so get timestamp of this rate
        list($time) = $db->sql_fetch_row($db->sql_query("SELECT date FROM $prefix"._gallery_pictures." WHERE pid=$pid"));
        $timeStamp = formatTimestamp($time);
        $cookieName = $cookiePrefix.$timeStamp;
        // check if cookie exists
        if($HTTP_COOKIE_VARS["$cookieName"] == "1") {
            // cookie exists, invalidate this vote
            echo $warn = "You already voted today!";
            $voteValid = 0;
        } else {
            // cookie does not exist yet, set one now
            $cvalue = 1;
            setcookie("$cookieName",$cvalue,time()+86400);
        }
    }
    // update database if the vote is valid
    if($voteValid>0) {
        $db->sql_query("update $prefix"._gallery_pictures." set votes=votes+1, rate=(rate*(votes-1) + $rate)/votes where pid=$pid");
    }

    // a lot of browsers can't handle it if there's an empty page
    print '<html><head></head><body></body></html>';

}

function showpic($pid, $orderby) {
        global
                $adminpath,
                $basepath,
                $prefix, $db,
                $gallerypath,
                $user,
                $admin,
                $baseurl,
                $galleryvar,
                $font,
                $PHP_SELF
        ;

        include("$adminpath/config.php");

        if(!isset($orderby) || $orderby=="")
                $orderby = $galleryvar['defaultsortmedia'];

        $prow = $db->sql_fetchrow($db->sql_query("SELECT p.*, UNIX_TIMESTAMP(p.date) AS unix_time, c.galloc, c.visible, t.templatePictures, t.templateCSS, f.displaytag, f.filetype, f.description AS description_media FROM $prefix"._gallery_pictures." AS p LEFT JOIN $prefix"._gallery_categories." AS c ON c.gallid=p.gid LEFT JOIN $prefix"._gallery_template_types." AS t ON t.id=c.template LEFT JOIN $prefix"._gallery_media_types." AS f ON f.extension=p.extension WHERE pid=$pid"));

        $ok=0;
        switch ($prow[visible]) {
                case 0:
                        if (is_admin($admin))
                                $ok=1;
                        break;
                case 1:
                        if (is_user($user) || is_admin($admin))
                                $ok=1;
                        break;
                default:
                        $ok=1;
                        break;
        }

        if ($ok) {
                galleryHeader();
?><style type="text/css">

table td.img1 {
    width: 9px;
    height: 9px;
    background: url(http://www.zptweb.net/themes/iCGstation/images/t_01.gif) no-repeat;
}

table td.img2 {
    background: url(http://www.zptweb.net/themes/iCGstation/images/t_02.gif) repeat-x;
}

table td.img3 {
    width: 9px;
    height: 9px;
    background: url(http://www.zptweb.net/themes/iCGstation/images/t_03.gif) no-repeat;
}

table td.img4 {
    background: url(http://www.zptweb.net/themes/iCGstation/images/t_04.gif) repeat-y;
}

table td.img5 {
    background: url(http://www.zptweb.net/themes/iCGstation/images/t_05.gif) repeat-y;
}

table td.img6 {
    height: 9px;
    background: url(http://www.zptweb.net/themes/iCGstation/images/t_06.gif) no-repeat;
}

table td.img7 {
    background: url(http://www.zptweb.net/themes/iCGstation/images/t_07.gif) repeat-x;
}

table td.img8 {
    height: 9px;
    background: url(http://www.zptweb.net/themes/iCGstation/images/t_08.gif) no-repeat;
}

</style>

</head>

<body>

<br><table align="center" width="50%" cellpadding="0" cellspacing="0" border="0">
<tr><td class="img1"></td><td class="img2"></td><td class="img3"></td></tr>
<tr><td class="img4"></td><td>
<?php

                if($prow[filetype] == 1) {
                        $size = @getimagesize("$gallerypath/$prow[galloc]/$prow[imagen]");
                }
                else {
                        $size[0] = $prow[width];
                        $size[1] = $prow[height];
                        $size[2] = $prow[description_media];
                        $size[3] = "width="size[0]" height="size[1]"";
                }
                $navtree = navigationTree($prow[gid], $prow[pid]);
                $navpic = navigationPic($prow[name], $prow[gid], $prow[pid], $orderby);
                $navgall = navigationGall();

                $iname = displaySizePic($prow, $size);
                $img = displayPicturePic($prow, $size);
                $date = displayDateAddedPic($prow);
                $submitter = displaySubmitterPic($prow);
                $hits = displayHitsPic($prow);
                $rate = displayRatePic($prow);
                $ratingbar = displayRatingBarPic($prow, $orderby);
                $description = displayDescriptionPic($prow);

                if ($galleryvar['allowcomments'])
                        $comments = displayCommentsPic($prow[pid], $orderby);
                //
                if ($galleryvar['allowpostcard']) {
                       $path = substr($PHP_SELF, 0, strlen($PHP_SELF) - strlen("/modules.php"));
                        if($prow[filetype] == 1) {
                                $postcard = "<center><a class="".$font['normal']."" href="$postscardpath?image=$path/$gallerypath/$prow[galloc]/$prow[imagen]" target="_blank">
                                  <img src="$imagepath/mailcard.gif" border="0" align="middle" alt=""._GALPOSTCARD."">
                                   "._GALPOSTCARD."
                                  </a>";
                         }
                }
                if ($galleryvar['allowprint'])  {
                        // No Margin Pop Up Window Version 1.0 : Credits to Dodo : http://www.regretless.com
                              $dir="../gallery/$prow[galloc]/"; // the directory where your image's at with "/" at the end, leave it                                      // blank if you are calling the image from the same directory
                        $pic="$prow[imagen]"; // your image file name
                        $width="$prow[width]"; // image width
                        $height="$prow[height]"; // image height
                        $target++; // leave this alone
                        $nmdir="$basepath/public/"; // the directory where your nmimage.php's at with "/" at the end
                        // leave it blank if you are calling the image from the same directory

                        $print = "<A class="".$font['normal']."" HREF="#" onMouseOver="window.status='pop up';return true" onMouseOut="window.status='';return true" onClick="window.open('$nmdir";
                        $print .= "nmimage.php?z=$dir$pic&width=$width&height=$height','$target','width=$width,height=$height,directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=no,left=0,top=0,screenx=50,screeny=50');return false">";
                        $print .= "<img src="$imagepath/print.gif" border="0" align="middle" alt=""._GALPRINTMEDIA.""> "._GALPRINTMEDIA." </a>";
                }

                if ($galleryvar['allowdownload']) {
                        $thefile = substr($prow[imagen], 0, strrpos($prow[imagen],'.'));
                        $zipfile = $thefile.".zip";
                        $gzfile = $prow[imagen].".gz";
                        if ($galleryvar['downloadmode']=="zip")
                                $thefile = $zipfile;
                        elseif ($galleryvar['downloadmode']=="gz")
                                $thefile = $gzfile;
                        $download = "<a class="".$font['tiny']."" href="$baseurl&amp;do=getit&amp;url=$prow[galloc]/$thefile&amp;filename=$thefile"><img src="$imagepath/hit.gif" border="0" align="middle" alt="Download this Media" ></a> <a class="content" href="$baseurl&amp;do=getit&amp;url=$prow[galloc]/$thefile&amp;filename=$thefile"> "._GALDOWNLOADMEDIA."</a>";
                }
                //
                $template = $prow[templatePictures];
                $template = str_replace('<:IMAGE:>', $img, $template);
                $template = str_replace('<:DESCRIPTION:>', $description, $template);
                $template = str_replace('<:RATE:>', $rate, $template);
                $template = str_replace('<:RATINGBAR:>', $ratingbar, $template);
                $template = str_replace('<:SUBMITTER:>', $submitter, $template);
                $template = str_replace('<:NAMESIZE:>', $iname, $template);
                $template = str_replace('<:COMMENTS:>', $comments, $template);
                $template = str_replace('<:HITS:>', $hits, $template);
                $template = str_replace('<:DATE:>', $date, $template);
                // raw data
                $template = str_replace('<:RAWIMAGE:>', $prow[imagen], $template);
                $template = str_replace('<:RAWIMAGESIZE:>', $size[3], $template);
                $template = str_replace('<:RAWIMAGEWIDTH:>', $size[0], $template);
                $template = str_replace('<:RAWIMAGEHEIGHT:>', $size[1], $template);
                $template = str_replace('<:RAWDESCRIPTION:>', $prow[description], $template);
                $template = str_replace('<:RAWRATE:>', $prow[rate], $template);
                $template = str_replace('<:RAWVOTES:>', $prow[votes], $template);
                $template = str_replace('<:RAWSUBMITTER:>', $prow[submitter], $template);
                $template = str_replace('<:RAWNAME:>', $prow[name], $template);
                $template = str_replace('<:RAWHITS:>', $prow[hist], $template);
                $template = str_replace('<:RAWDATEBRIEF:>', strftime(_GALBRIEFDATE, $prow[unix_time]), $template);
                $template = str_replace('<:POSTCARD:>', $postcard, $template);
                $template = str_replace('<:PRINT:>', $print, $template);
                $template = str_replace('<:DOWNLOAD:>', $download, $template);

                print "$navgall $navtree";
                print "$navpic $template";
                CloseTable();
                galleryFooter();
        } // If OK
}
?>

Saludos Guiño
Individual Perfil Privado
Autor Fecha: 15 de Septiembre del 2007 a las 12:11:12   Descripción: Ninguna
Sin avatar
Sexo: Masculino
Edad: 21 años
Ubicación: Poza Rica, Veracruz
País:
Mensajes: 1278
Un código de seguridad no es dificil de hacer. Si tu consigues un script que haga la función de código de seguridad, y pones una imagen de ejemplo, ocupando el lugar del código de seguridad; entonces yo te ayudaré a integrar dicho código.

Obviamente yo no puedo hacer todo, desde el código de seguridad hasta su integración total. Tu también tienes que poner de tu parte.

Saludos Muy bien
Individual Perfil Privado Website
Autor Fecha: 15 de Septiembre del 2007 a las 15:30:04   Descripción: Ninguna
Sin avatar
Sexo: Masculino
Mensajes: 344
Se me olvidó decir que el código de seguridad, ya lo tengo, incluso se como meterlo, pero no me sale.

Este es:

Agregar el código de seguridad en cualquier zona de tu nuke es muy sencillo.

Primero lo necesario. Básicamente en una function se colocará el código de seguridad y en la function destino se comprobará que se ha introducido correctamente.

Lo habitual es que en una function exista un formulario y nosotros queremos que ese formulario tenga el código de seguridad, a esa function la llamaremos function inicio. La function que se cargará cuando enviemos el formulario es la function destino.

Cada function tiene una línea que empieza por la palabra global seguido de un listado de variables ya definidas en el nuke y que se van a utilizar en la function. A esta línea debemos agregar la variable $gfx_chk en la function inicio y las variables $gfx_chk y $sitekey en la function destino.

Procedamos a colocar el código de seguridad en sí. El código genérico a agregar en la function inicio es:

Código
$random_num = mt_rand(0, 1000000);
if (extension_loaded('gd') AND ($gfx_chk == 3 OR $gfx_chk == 4 OR $gfx_chk == 6 OR $gfx_chk == 7))
{
echo '
<br><br><b>'._SECURITYCODE.':</b>
<img src="error.php?op=gfx&random_num='.$random_num.'" border="1" alt="'._SECURITYCODE.'" title="'._SECURITYCODE.'">
<br><br>
<b>'._TYPESECCODE.':</b> <input type="text" NAME="gfx_check" SIZE="7" MAXLENGTH="6">
<input type="hidden" name="random_num" value="'.$random_num.'">';
}

Debe ponerse dónde deseamos que se muestre el código.

En la function destino debemos colocar el código que comprueba que el código se ha introducido de forma correcta, para ello es bueno que el código se coloque justo despues de la línea del global y el código sería:

Código
$datekey = date("F j");
$rcode = hexdec(md5($_SERVER[HTTP_USER_AGENT] . $sitekey . $_POST[random_num] . $datekey));
$code = substr($rcode, 2, 6);
if (extension_loaded("gd") AND $code != $gfx_check AND ($gfx_chk == 3 OR $gfx_chk == 4 OR $gfx_chk == 6 OR $gfx_chk == 7)) {
include('header.php');
OpenTable();
echo '<center><b>'._SECCODEINCOR.'</b><br><br>'._GOBACK.'</center>';
CloseTable();
include('footer.php');
die();
}

Para terminar, debemos definir en el lang del módulo _SECCONDEINCOR introduciendo la siguiente línea:

define("_SECCODEINCOR","Código de Seguridad es incorrecto, Por favor regresa atrás y escribelo exactamente como fue generado...");


Con esto ya tenemos el código de seguridad integrado. A continuación pongo un sencillo código de un módulo con el código de seguridad:

Código
<?php
/************************************************************************/
/* NUKE ET: Modificacion del PHP-Nuke */
/* ================================== */
/* */
/* Modulo creado con el conversor HTML a NukeET */
/* */
/* Copyright (c) 2004 por Truzone */
/* http://www.truzone.org */
/************************************************************************/

if(!defined('NUKE_ET')) {
Header("Location: ../../error.php?op=e403");
die();
}

require_once("mainfile.php");
$module_name = basename(dirname(__FILE__));

function principal()
{
global $module_name,$gfx_chk;
include('header.php');
OpenTable();
echo '
<form method="post" action="./modules.php?name='.$module_name.'&amp;op=destino">';

$random_num = mt_rand(0, 1000000);
if (extension_loaded('gd') AND ($gfx_chk == 3 OR $gfx_chk == 4 OR $gfx_chk == 6 OR $gfx_chk == 7))
{
echo '
<br><br><b>'._SECURITYCODE.':</b>
<img src="error.php?op=gfx&random_num='.$random_num.'" border="1" alt="'._SECURITYCODE.'" title="'._SECURITYCODE.'">
<br><br>
<b>'._TYPESECCODE.':</b> <input type="text" NAME="gfx_check" SIZE="7" MAXLENGTH="6">
<input type="hidden" name="random_num" value="'.$random_num.'">';
}

echo '
<input type="submit" value="Enviar">
</form>';
CloseTable();
include('footer.php');
}

function destino()
{
global $module_name,$gfx_chk,$sitekey;

$datekey = date("F j");
$rcode = hexdec(md5($_SERVER[HTTP_USER_AGENT] . $sitekey . $_POST[random_num] . $datekey));
$code = substr($rcode, 2, 6);
if (extension_loaded("gd") AND $code != $gfx_check AND ($gfx_chk == 3 OR $gfx_chk == 4 OR $gfx_chk == 6 OR $gfx_chk == 7))
{
include('header.php');
OpenTable();
echo '<center><b>'._SECCODEINCOR.'</b><br><br>'._GOBACK.'</center>';
CloseTable();
include('footer.php');
die();
}
include('header.php');
OpenTable();
echo '
<center>
El c&oacute;digo de seguridad es correcto
</center>';
CloseTable();
include('footer.php');
}

switch($op)
{

default:
principal();
break;

case "destino":
destino();
break;

}

?>

Pero el caso esque a mí el código se me muestra, la imagen no soy capaz de que se muestre, no se muestra nada, ni sale ningún error, es como si no hubiera realizado ningún cambio.

Saludos.
Este mensaje fue editado por última vez el 15 de Septiembre del 2007 a las 15:30:41 por Dreagnout.
Individual Perfil Privado
Autor Fecha: 25 de Septiembre del 2007 a las 08:47:12   Descripción: Ninguna
Sin avatar
Sexo: Masculino
Edad: 21 años
Ubicación: Poza Rica, Veracruz
País:
Mensajes: 1278
El manual esta algo explicado, aunque al ejemplo le falta optimización o una mejor programación.

Por ejemplo. Con respecto a la función inicio(). Si no puede generar la imagen, ¿porque el resto del formulario no se incluyo en el if?. Asi tal cual, la imagen puede no aparecer, pero el boton de enviar, solito, si.

Ahora con respecto a la funcion destino()... que es eso de tener un doble header y finalizar el proceso con un die()... Tan facil y limpio que hubiera sido usar un if y else.

Pero bueno es solo un ejemplo.

Ahora lo importante. Me diste el código del módulo sin el de seguridad (el primero que pegaste); y también me diste el código del ejemplo, con el de seguridad (el último); pero nunca me diste tu código modificado... y que se supone no funciono.

Y es que me hubiera gustado revisar dicho código y darte la solución. Ahora, si me dices que ni el ejemplo te funciono, eso ya es otra cosa.

Aparte, poner un codigo de seguridad, no es tan facil como preguntarle a alguien mas como se hace. Yo ahorita no te puedo ayudar, porque no me has dicho ni que quieres lograr, donde quieres que aparezca el codigo y demas.

Yo lo podría poner y tu me dirás... esta bién, pero yo no lo queria ahi... y yo te diré, pues si, pero tu nunca me diste detalles y yo no soy adivino.

Espero haberme dado a entender, simplemente necesito más detalles; por eso te pedi que pusieras el código, aunque no funcionara, pues yo lo haría funcionar.

O tan siquiera dime, cual es la función del código de seguridad, que recurso se supone que va a restringir.

Saludos Muy bien
Individual Perfil Privado Website
Autor Fecha: 30 de Septiembre del 2007 a las 04:48:03   Descripción: Ninguna
Sin avatar
Sexo: Masculino
Mensajes: 344
Hola Luis, no puse el código modificado porque no me funcionó, y el código qeu modifiqué no lo guardé modificado, ya que como no me funcionó, lo dejé como estaba.

Esto es lo que quiero modificar:

http://img233.imageshack.us/img233/616/imagen1dj9.png

Quiero modificar el código de enviar, comentarios, para que los bots no me maten de spam.

Y está claro que el código de mostrar los comentarios se haya en una function:

Código
function displayCommentsPic($pid, $orderby) {
   global
           $adminpath,
           $user,
        $baseurl,
        $admin,
        $imagepath,
        $prefix, $db,
        $font
   ;

   include("$adminpath/config.php");

        $out = '<br><center><p align="center">';
        $out .= '<font class="'.$font['title'].'">'._GALCOMMPOST.'</font></p><br><br>';

        $result3 = $db->sql_query("select cid, pid, comment, date, name, member from $prefix"._gallery_comments." where pid=$pid order by date ASC");
        if ($db->sql_numrows($result3) == 0) {
                $out .= '<p align="center"><font class="content">'._GALNOCOMM.'</font></p><br>';
        }
        else {
                $out .= '<TABLE border="0" bgcolor="white" cellPadding="2" cellSpacing="2" width="80%" align="center">';

                while(list($cid, $cpid, $comment, $date, $name, $member) = $db->sql_fetchrow($result3)) {
                        if ($member)
                                $poster = '<a class="'.$font['normal'].'" href="modules.php?name=Your_Account&op=userinfo&amp;username='.$name.'">'.underscoreTospace($name).'</a>';
                        else
                                $poster =  '<font class="'.$font['normal'].'">'.underscoreTospace($name).'</font>';

                          $out .= '<TR>';

                $out .= '  <TD align="center" bgColor="'.$bgcolor2.'" vAlign="top" width="140"><font class="'.$font['normal'].'">'.$poster.'<br>('.substr($date,0,10).')</font></TD>'
                        .'  <TD align="left" bgColor="'.$bgcolor1.'" vAlign="top"><font class="'.$font['normal'].'">'.$comment.'</font></TD>';

                if (is_admin($admin))
                        $out .= '  <TD align="center" width="30"><a href="'.$baseurl.'&amp;do=deletecomment&amp;cid='.$cid.'&amp;pid='.$pid.'&amp;orderby='.$orderby.'" onClick="return confirm(''._GALSURE2DELETECOMMENT.'')">'
                             .'<img src="'.$imagepath.'/delete.gif" border="0" alt="'._DELETE.'"></a></td>';

                $out .= '</TR>';
                } //while
                $out .= '</TABLE>';
        }
        print '<br><br>';
        if (is_user($user)) {
                $userdata=cookiedecode($user);
                $out .=
                '<p align="center"><form action="'.$baseurl.'" method="POST">'
                .'<input type="hidden" name="do" value="Post">'
                .'<font class="'.$font['title'].'">'._GALNAME.'</font>&nbsp;<b>'.$userdata[1].'</b>'
                       .'<input type="hidden" name="gname" value="'.$userdata[1].'">'
                       .'<input type="hidden" name="member" value="1"><br>'
                .'<font class="'.$font['title'].'">'._GALCOMMENT.'</font><br>'
                  .'<input class="textbox" type="text" name="comment" size="70" maxlength="70"><br>'
                  .'<input class="textbox" type="hidden" name="pid" value="'.$pid.'">&nbsp;'
                  .'<input type="submit" value="Post">'
                .'</form>'
                .'<font class="option">'._GALNOTE.'</font></p>';
        }
        elseif (!$galleryvar['anoncomments']) {
                $out .=
                '<p align="center"><form action="'.$baseurl.'" method="post">'
                .'<input type="hidden" name="do" value="Post">'
                .'<font class="'.$font['title'].'">'._GALNAME.'</font><br>'
                     .'<input type="text" SIZE="20" MAXLENGTH="20" name="gname">'
                     .'<input type="hidden" name="member" value="0">'
                     .'<br><font class="'.$font['title'].'">'._GALCOMMENT.'</font><br>'
                .'<input class="textbox" type="text" name="comment" size="70" maxlength="70"><br>'
                .'<input class="textbox" type="hidden" name="pid" value="'.$pid.'">&nbsp;'
                .'<input type="submit" value="Post">'
                .'</form>';
//                .'<font class="option">'._GALNOTE.'</font></p>';
        }
        else {
                $out .= '<p align="center"><font class="'.$font['tiny'].'">'._GALREGISTER."</font></p>";
        }
  return $out;
}

El caso es, que no consigo hacerlo, y lo hago tal y como viene en el ejemplo.

Saludos.

Individual Perfil Privado
Autor Fecha: 07 de Octubre del 2007 a las 09:29:06   Descripción: Ninguna
Sin avatar
Sexo: Masculino
Edad: 21 años
Ubicación: Poza Rica, Veracruz
País:
Mensajes: 1278
Esta es la función de los comentarios, con el código de seguridad:

Código PHP
<?php

function displayCommentsPic($pid, $orderby) {
   global
          
$adminpath,
          
$user,
        
$baseurl,
        
$admin,
        
$imagepath,
        
$prefix, $db,
        
$font,
        
$gfx_chk
  
;

   include(
"$adminpath/config.php");

        
$out = '<br><center><p align="center">';
        
$out .= '<font class="'.$font['title'].'">'._GALCOMMPOST.'</font></p><br><br>';

        
$result3 = $db->sql_query("select cid, pid, comment, date, name, member from $prefix"._gallery_comments." where pid=$pid order by date ASC");
        if (
$db->sql_numrows($result3) == 0) {
                
$out .= '<p align="center"><font class="content">'._GALNOCOMM.'</font></p><br>';
        }
        else {
                
$out .= '<TABLE border="0" bgcolor="white" cellPadding="2" cellSpacing="2" width="80%" align="center">';

                while(list(
$cid, $cpid, $comment, $date, $name, $member) = $db->sql_fetchrow($result3)) {
                        if (
$member)
                                
$poster = '<a class="'.$font['normal'].'" href="modules.php?name=Your_Account&op=userinfo&amp;username='.$name.'">'.underscoreTospace($name).'</a>';
                        else
                                
$poster =  '<font class="'.$font['normal'].'">'.underscoreTospace($name).'</font>';

                          
$out .= '<TR>';

                
$out .= '  <TD align="center" bgColor="'.$bgcolor2.'" vAlign="top" width="140"><font class="'.$font['normal'].'">'.$poster.'<br>('.substr($date,0,10).')</font></TD>'
                        
.'  <TD align="left" bgColor="'.$bgcolor1.'" vAlign="top"><font class="'.$font['normal'].'">'.$comment.'</font></TD>';

                if (
is_admin($admin))
                        
$out .= '  <TD align="center" width="30"><a href="'.$baseurl.'&amp;do=deletecomment&amp;cid='.$cid.'&amp;pid='.$pid.'&amp;orderby='.$orderby.'" onClick="return confirm(''._GALSURE2DELETECOMMENT.'')">'
                            
.'<img src="'.$imagepath.'/delete.gif" border="0" alt="'._DELETE.'"></a></td>';

                
$out .= '</TR>';
                }
//while
                
$out .= '</TABLE>';
        }
        print
'<br><br>';

        
$random_num = mt_rand(0, 1000000);
        if (
extension_loaded('gd') AND ($gfx_chk == 3 OR $gfx_chk == 4 OR $gfx_chk == 6 OR $gfx_chk == 7))
        {
        
$security = '
        <br><br><b>'
._SECURITYCODE.':</b>
        <img src="error.php?op=gfx&random_num='
.$random_num.'" border="1" alt="'._SECURITYCODE.'" title="'._SECURITYCODE.'">
        <br><br>
        <b>'
._TYPESECCODE.':</b> <input type="text" NAME="gfx_check" SIZE="7" MAXLENGTH="6">
        <input type="hidden" name="random_num" value="'
.$random_num.'"><br>';
        } else {
            
$security = null;
        }

        if (
is_user($user)) {
                
$userdata=cookiedecode($user);
                
$out .=
                
'<p align="center"><form action="'.$baseurl.'" method="POST">'
                
.'<input type="hidden" name="do" value="Post">'
                
.'<font class="'.$font['title'].'">'._GALNAME.'</font>&nbsp;<b>'.$userdata[1].'</b>'
                      
.'<input type="hidden" name="gname" value="'.$userdata[1].'">'
                      
.'<input type="hidden" name="member" value="1"><br>'
                
.'<font class="'.$font['title'].'">'._GALCOMMENT.'</font><br>'
                  
.'<input class="textbox" type="text" name="comment" size="70" maxlength="70"><br>'
                  
.'<input class="textbox" type="hidden" name="pid" value="'.$pid.'">&nbsp;'.$security
                  
.'<input type="submit" value="Post">'
                
.'</form>'
                
.'<font class="option">'._GALNOTE.'</font></p>';
        }
        elseif (!
$galleryvar['anoncomments']) {
                
$out .=
                
'<p align="center"><form action="'.$baseurl.'" method="post">'
                
.'<input type="hidden" name="do" value="Post">'
                
.'<font class="'.$font['title'].'">'._GALNAME.'</font><br>'
                    
.'<input type="text" SIZE="20" MAXLENGTH="20" name="gname">'
                    
.'<input type="hidden" name="member" value="0">'
                    
.'<br><font class="'.$font['title'].'">'._GALCOMMENT.'</font><br>'
                
.'<input class="textbox" type="text" name="comment" size="70" maxlength="70"><br>'
                
.'<input class="textbox" type="hidden" name="pid" value="'.$pid.'">&nbsp;'
                
.'<input type="submit" value="Post">'.$security
                
.'</form>'
                
.'<font class="option">'._GALNOTE.'</font></p>';
        }
        else {
                
$out .= '<p align="center"><font class="'.$font['tiny'].'">'._GALREGISTER."</font></p>";
        }
  return
$out;
}

?>

Pero no me diste el módulo completo, ya que no viene la función que procesará el formulario.
Individual Perfil Privado Website
Autor Fecha: 09 de Octubre del 2007 a las 12:12:03   Descripción: Ninguna
Sin avatar
Sexo: Masculino
Mensajes: 344
Hola, luis, efectivamente, no trae función de mostrar comentario, según veo en el tutorial, no hace falta que la tenga No entiendo

Pero he añadido tu código, y no aparece nada, ni imagen, ni error, ni nada, como estaba antes, porqué puede ser?

Gracias.
Individual Perfil Privado