Question

I have been fiddling around with a third-party script for some time when I noticed there was some unusual PHPBB framework code put in randomly with the rest of the PHP. What I need to understand is if there is anything particularly special about this code(can it do something regular PHP can't?) and how I can smoothly transition the code to PHP without a framework if there isn't anything special about the code.

<?
include('bar.php');
include "../includes/config.inc.php";
include "loggedin.inc.php";
include "../includes/countries.inc.php";
$auction_id = isset($_REQUEST['aid']) ? $_REQUEST['aid'] : "";
?>
<?
define("DATAGRID_DIR", "../datagrid/");
define("PEAR_DIR", "../datagrid/pear/");
require_once(DATAGRID_DIR . 'datagrid.class.php');
require_once(PEAR_DIR . 'PEAR.php');
require_once(PEAR_DIR . 'DB.php');
$DB_USER = $DbUser;
$DB_PASS = $DbPassword;
$DB_HOST = $DbHost;
$DB_NAME = $DbDatabase;
ob_start();
$db_conn     = DB::factory('mysql');
$result_conn = $db_conn->connect(DB::parseDSN('mysql://' . $DB_USER . ':' . $DB_PASS . '@' . $DB_HOST . '/' . $DB_NAME));
if (DB::isError($result_conn)) {
    die($result_conn->getDebugInfo());
}
$sql = "SELECT u.id, u.nick, COUNT(b.bidder) AS bid_count, 'View offers' AS link
            FROM BPLA_bids b
                INNER JOIN BPLA_users u ON b.bidder=u.id
            WHERE b.auction=$auction_id
            GROUP BY b.bidder";
$unique_prefix       = "au_";
$dgrid               = new DataGrid($debug_mode, $messaging, $unique_prefix, DATAGRID_DIR);
$default_order_field = "nick";
$default_order_type  = "ASC";
$dgrid->dataSource($db_conn, $sql, $default_order_field, $default_order_type);
$dg_language = "en";
$dgrid->setInterfaceLang($dg_language);
$direction = "ltr";
$dgrid->setDirection($direction);
$modes = array(
    "add" => array(
        "view" => false,
        "edit" => false,
        "type" => "link"
    ),
    "edit" => array(
        "view" => false,
        "edit" => false,
        "type" => "link",
        "byFieldValue" => ""
    ),
    "cancel" => array(
        "view" => false,
        "edit" => false,
        "type" => "link"
    ),
    "details" => array(
        "view" => false,
        "edit" => false,
        "type" => "link"
    ),
    "delete" => array(
        "view" => false,
        "edit" => false,
        "type" => "image"
    )
);
$dgrid->setModes($modes);
$http_get_vars = array(
    "aid"
);
$dgrid->setHttpGetVars($http_get_vars);
$printing_option = false;
$dgrid->allowPrinting($printing_option);
$exporting_option    = false;
$exporting_directory = "";
$dgrid->allowExporting($exporting_option, $exporting_directory);
$sorting_option = true;
$dgrid->allowSorting($sorting_option);
$paging_option   = true;
$rows_numeration = false;
$numeration_sign = "N #";
$dgrid->allowPaging($paging_option, $rows_numeration, $numeration_sign);
$bottom_paging     = array();
$top_paging        = array();
$pages_array       = array(
    "10" => "10",
    "25" => "25",
    "50" => "50",
    "100" => "100",
    "250" => "250"
);
$default_page_size = 10;
$paging_arrows     = array(
    "first" => "|&lt;&lt;",
    "previous" => "&lt;&lt;",
    "next" => "&gt;&gt;",
    "last" => "&gt;&gt;|"
);
$dgrid->setPagingSettings($bottom_paging, $top_paging, $pages_array, $default_page_size, $paging_arrows);
$dgrid->setViewModeTableProperties($vm_table_properties);
$vm_colimns = array(
    "nick" => array(
        "header" => "Nick",
        "type" => "label",
        "summarize" => "false",
        "visible" => "true"
    ),
    "bid_count" => array(
        "header" => "Bid count",
        "type" => "label",
        "summarize" => "false",
        "visible" => "true"
    ),
    "link" => array(
        "header" => "&nbsp;",
        "type" => "link",
        "field_key" => "id",
        "field_data" => "link",
        "href" => "auction_users_bids.php?aid=$auction_id&uid={0}"
    )
);
$dgrid->setColumnsInViewMode($vm_colimns);
$dgrid->bind();
ob_end_flush();   
?>

No correct solution

OTHER TIPS

PHPBB uses standard PHP code. In the code you display, a DataGrid class is used, which PHPBB defined earlier. If you can find where that class is defined, that may help in understanding what it is doing. Search for

class DataGrid

in the PHPBB code to find out more about that class.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top