Jump to content

Code is so dirty...


Monkuar

Recommended Posts

I just want to get rid of all the functions it uses.. and make it echo a output and i can put variables in the output that's all..

 

somone help clean this baby up?

 

require_once "sources/shop/core_lib.php";

//--------------------------------------------------------------
// Pull up the logs
//--------------------------------------------------------------

$templateform = loadtemplate("logs");
$id		=	$ibforums->member["id"];
$name	=	$ibforums->member["name"];
$month	=	( isset($_POST[month])	?	$_POST[month]		:	date(F)	);
$year	=	( isset($_POST[year])	?	"20" . $_POST[year]	:	date(Y)	);

    $DB->query("SELECT * FROM ibf_logs WHERE receiver_id = {$ibforums->member["id"]} && month = '$month' && year = '$year' or sender_id = {$ibforums->member["id"]} && month = '$month' && year = '$year' order by id desc");
    if ($DB->get_num_rows()==0)
    {
        eval(empty_table);
    } else
    {
        eval(start_table);
        while ($item = $DB->fetch_row())
        {
		if ($item['sender_id'] == $ibforums->member["id"]){
			$grabTwo = ($item[receiver_id] == Store ? "" : mysql_query("SELECT * FROM ibf_members WHERE id = {$item[receiver_id]}"));
			$getReceiver = ($item[receiver_id] == Store ? "" : mysql_fetch_array($grabTwo));
			$nameFrom	=	"<a href='?showuser={$ibforums->member["id"]}'>" . $ibforums->member["name"] . (isset($ibforums->member["desktop"]) ? "<img src='{$ibforums->member["desktop"]}' </a>" : "</a>");
			$nameTo		=	($item[receiver_id] == Store ? "Store" : "<a href='?showuser={$getReceiver["id"]}'>" . $getReceiver[name] . (isset($getReceiver[desktop]) ? "<img src='{$getReceiver["desktop"]}'</a>" : "</a>"));
		} else {
			$grabThree	=	mysql_query("SELECT * FROM ibf_members WHERE id = {$item[sender_id]}");
			$getSender	=	mysql_fetch_array($grabThree);
			$nameFrom	=	"<a href='?showuser={$getSender["id"]}'>" . $getSender[name] . (isset($getSender[desktop]) ? "<img src='{$getSender["desktop"]}'</a>" : "</a>");
			$nameTo		=	"<a href='?showuser={$ibforums->member["id"]}'>" . $ibforums->member["name"] . (isset($ibforums->member["desktop"]) ? "<img src='{$ibforums->member["desktop"]}'</a>" : "</a>");
		}
            $to = $nameTo;
		$from = $nameFrom;
		$amount = $item["amount"];
		$time_date = $item["date_time"];
		$message = $item["message"];
            eval(do_row);
        }
        eval(end_table);
    }
$output = $templateform;
print_and_exit();

 

thanks.. like the print_and_exit(); like i dont even want that i just want to beable to echo my stuff out w/o all these weird functions..

Link to comment
https://forums.phpfreaks.com/topic/164312-code-is-so-dirty/
Share on other sites

Sure, I'll get right on that.

thank u sir

 

monkuar my friend,

  I realize that sarcasm does not always translate, especially when it is being practiced by a master of the art like CV.  Let me state this another way:

 

  "Don't hold your breath."

 

  You have been participating here for 100+ posts, so I would think you would have picked up on what constitutes a good question vs a bad one, and yours is not very good. 

 

  In essence you dropped a block of code in here and asked people to "Make it better."  Anything is possible, but I won't be taking my time, nor apparently is CV. 

 

  One piece of advise I can provide you, is to find a way to do whatever that code is doing, without resorting to the use of eval().  It's quite simply one of the most dangerous functions, from a security standpoint, that php offers.  Not unlike the use of recursion, there is almost always a way to do without it.

 

 

Link to comment
https://forums.phpfreaks.com/topic/164312-code-is-so-dirty/#findComment-866779
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

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.