1

Topic: Changing output syntax

Hi all,

I'm quite new at using htmlLawed, and I am amazed by the power of the script.

However, I am trying to find a way to change the output syntax of the corrected elements. To be more precise, I would like :

<td align="center" style="background-color: $bgcolor3;">

to become :

<td align=\"center\" style=\"background-color: $bgcolor3;\">

My guess is that the hl_tag is the function I should be looking into..

Otherwise, script works great!!

2

Re: Changing output syntax

After searching for a bit, I found what i was looking for :

Find :

 foreach($a as $k=>$v){$aA .= " {$k}=\"{$v}\"";}

Replace by :

foreach($a as $k=>$v){$aA .= " {$k}=\\\"{$v}\\\"";}

and voilà!!

3

Re: Changing output syntax

Just curious: what is the goal of using this particular syntax -- backslashed-double-quotes (\")?

4 (edited by Kommius 2009-08-16 14:07:26)

Re: Changing output syntax

The goal is to parse a PHP file containing XHTML Tags, such as this one :

<?php

/************************************************************************/
/* NUKECLAN 1.5.x : Web Portal System                                   */
/* ====================================                                 */
/* Copyright (c) 2003-2008 by Team Nuke-Clan                            */
/* http://www.nukeclan.org                                                */
/*                                                                        */
/* Based on PHP-Nuke                                                    */
/* Copyright (c) 2005 by Francisco Burzi                                */
/* http://phpnuke.org                                                   */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/

if (!defined('ADMIN_FILE')) {
    die ("Access Denied");
}

global $admindata;
if (is_admin2($admindata["admin_id"], "super")) {

$GLOBALS["pagetitle"] = "> "._NCHTTPREFERERS."";

// Do not remove the following lines, these are for copyright information!
$ncadmincopy = "Referers";
$author_name = "Francisco Burzi, Team NukeClan";
$author_homepage = "http://www.php-nuke.org";
$license = "GNU/GPL";
$download_location = "http://www.nukeclan.org";
$module_version = "2.0";
$module_description = "Affichage des référants HTTP";
// End of copyright information

#==================================================
# function HTTPReferer
# Liste des référants
#==================================================
function HTTPReferer() {
    global $bgcolor1, $bgcolor2, $bgcolor3, $db, $admin_file;
    include_once("header.php");
    NCGraphicAdmin();
        
    OpenTable();
    echo "<center><b>"._NCWHOLINKS."</b></center><br /><br />";
    echo "<table width=\"100%\" border=\"0\" cellspacing=\"1\" bgcolor=\"$bgcolor2\">";
    echo "<tr>";
    echo "<td bgcolor=\"$bgcolor3\" align=\"center\"><b>"._NCHITS."<b></td>";
    echo "<td bgcolor=\"$bgcolor3\" align=\"center\"><b>"._NCURL."</b></td>";
    echo "<td bgcolor=\"$bgcolor3\" align=\"center\"><b>"._NCUPDATED."</b></td>";
    echo "<td bgcolor=\"$bgcolor3\" align=\"center\"><b>"._NCDELETE."</b></td>";
    echo "</tr>";
    
    $req_refs = $db->sql_query("SELECT r_id, r_url, r_count, r_lasttime FROM ".TABLE_REFERER." ORDER BY r_count DESC");
    $num_refs = $db->sql_numrows($req_refs);
    
    if (!empty($num_refs)) {
        while ($row = $db->sql_fetchrow($req_refs)) {
                $r_id = intval($row['r_id']);
                $r_url = filter($row['r_url'], nohtml);
                $r_url2 = urlencode($r_url);
                $r_count = intval($row['r_count']);
                $r_lasttime = formatTimestamp($row['r_lasttime']);
                
                echo "<tr><td bgcolor=\"$bgcolor1\" align=\"center\"><font class=\"content\">$r_count</font></td>";
                echo "<td bgcolor=\"$bgcolor1\" width=\"100%\"><font class=\"content\"><a href=\"index.php?url=$r_url2\" target=\"_blank\">$r_url</a></font></td>";
                echo "<td bgcolor=\"$bgcolor1\" nowrap>&nbsp;<font class=\"content\">$r_lasttime</font>&nbsp;</td>";
                echo "<td bgcolor=\"$bgcolor1\" align=\"center\"><a href=\"".$admin_file.".php?op=DelReferer&amp;ref_id=".$r_id."\"><img src=\"images/objets/wrong.gif\" border=\"0\" alt=\""._NCDELETE."\" title=\""._NCDELETE."\"></a></td>";
                echo "</tr>";
            }
    } else {
        echo "<tr><td align=\"center\" bgcolor=\"$bgcolor1\" colspan=\"4\">"._NCNOREFERERS."</td></tr>";
    }
    echo "</table><br />";
    echo "<form action=\"".$admin_file.".php\" method=\"post\">";
    echo "<input type=\"hidden\" name=\"op\" value=\"DelReferer\">";
    echo "<input type=\"hidden\" name=\"ref_id\" value=\"all\">";
    echo "<center><input type=\"submit\" value=\""._NCDELETEALL."\"></center>";
    CloseTable();
    
    include_once("footer.php");
}

#==================================================
# function DelReferer
# Effacer les référants
#==================================================
function DelReferer($ref_id) {
    global $db, $admin_file;
        
    if ($ref_id == "all") {
        $db->sql_query("DELETE FROM ".TABLE_REFERER."");
    } elseif (!empty($ref_id)) {
        $ref_id = intval($ref_id);
        $db->sql_query("DELETE FROM ".TABLE_REFERER." WHERE r_id='$ref_id'");
    }
        redirect_nc("".$admin_file.".php?op=HTTPReferer");
}

    switch($op) {

        case "HTTPReferer":
        HTTPReferer();
        break;

        case "DelReferer":
        DelReferer($ref_id);
        break;

    }

} else {
    echo "Access Denied";
}
?>

I still have some problems though, as all encapsed strings like

value=\""._NCDELETEALL."\"

are not parsed correctly and return empty values, since the script stops at the second double quote...

I'm also trying to find a way to parse only lines containing the echo ""; tag, so the script doesn't modify the PHP code ;)

5

Re: Changing output syntax

Would use of 'stripslashes()' on the input before it is passed to htmLawed help?

6

Re: Changing output syntax

Hmm it might.. I'll look into it!