Esempio n. 1
0
require_once 'class/Config_commodity.php';
include_once 'smarty_init.php';
require_once 'class/Config.php';
$conn = Config::connect();
$commodity_id = (int) $_REQUEST['id'];
$where = ' where ' . Config_commodity::id . ' = ' . "'" . $commodity_id . "'";
$DBtraverser = new DBtraverser(Config_commodity::table_name, $where);
$result = $DBtraverser->excute($conn);
$array_commofity_info = mysqli_fetch_array($result, MYSQLI_ASSOC);
if ($array_commofity_info) {
    require_once 'Include_picture.php';
    require_once 'class/Info_user.php';
    $array_pictures = get_commodity_pic($conn, $commodity_id);
    $array_message = get_leave_message($commodity_id, $conn);
    $userInfo = new Info_user();
    $username = $userInfo->get_user_logname($conn, $array_commofity_info[Config_commodity::publisher]);
    $commodity_array_for_display = array('nickname' => $username, 'title' => $array_commofity_info[Config_commodity::title], 'time' => get_time($array_commofity_info[Config_commodity::release_date]), 'price' => $array_commofity_info[Config_commodity::price], 'description' => $array_commofity_info[Config_commodity::description], 'description-img' => get_one_commodity_pic($conn, $array_commofity_info[Config_commodity::id]), 'img' => 'upload/avatar.png', 'id' => $commodity_id, 'star_numbers' => $array_commofity_info[Config_commodity::praise], 'message_numbers' => $array_commofity_info[Config_commodity::leave_message_time]);
    $smarty->assign('messages', $array_message);
    $smarty->assign('skill', $commodity_array_for_display);
    $smarty->assign('msg-total', $array_commofity_info[Config_commodity::leave_message_time]);
    $smarty->display('Reward&Market/market-skill.html');
} else {
}
mysqli_free_result($result);
function get_time($release_date)
{
    $now_time = time();
    $release_time = strtotime($release_date);
    return (int) (($now_time - $release_time) / 3600 / 24);
}
function get_leave_message($commodity_id, $conn)
Esempio n. 2
0
    //choose from
    $tbl_name = Config_budget::table_name . ',' . Config_commodity::table_name;
    $choose_fields = array(Config_budget::table_name . '.' . Config_budget::holder_id, Config_budget::table_name . '.' . Config_budget::payer_id, Config_budget::table_name . '.' . Config_budget::pay_date, Config_commodity::table_name . '.' . Config_commodity::price, Config_commodity::table_name . '.' . Config_commodity::title, Config_commodity::table_name . '.' . Config_commodity::id, Config_commodity::table_name . '.' . Config_commodity::publisher, Config_commodity::table_name . '.' . Config_commodity::course_or_reward);
    $where = ' where ' . Config_budget::table_name . '.' . Config_budget::commodity_id . ' = ' . Config_commodity::table_name . '.' . Config_commodity::id . ' AND (' . Config_budget::table_name . '.' . Config_budget::holder_id . ' = ' . "'{$id}'" . ' OR ' . Config_budget::table_name . '.' . Config_budget::payer_id . ' = ' . "'{$id}'" . ')';
    //向数据库查询符合条件数,以计算显示分页数目
    $dbcount = new DBcount($tbl_name, $where);
    $retval = $dbcount->excute($conn);
    $row = mysqli_fetch_array($retval, MYSQLI_NUM);
    $count = 1 + (int) (($row ? $row[0] : 0) / SIZE_EACH_PAGE);
    //3.计算当前页码;
    $page = isset($_GET['page']) ? (int) $_GET['page'] : 1;
    $page = $page > $count ? $count : $page;
    $DBpagination = new DBpagination($tbl_name, $where, $page, SIZE_EACH_PAGE, $choose_fields);
    $retval = $DBpagination->excute($conn);
    $account_ary = array();
    while (($temp_account_ary = mysqli_fetch_array($retval, MYSQLI_ASSOC)) != null) {
        $is_loginer_income = $temp_account_ary[Config_budget::holder_id] == $id;
        if ($is_loginer_income) {
            $trader = $temp_account_ary[Config_budget::payer_id];
        } else {
            $trader = $temp_account_ary[Config_budget::holder_id];
        }
        $type = $temp_account_ary[Config_commodity::course_or_reward] == Commodity_type_Config::reward ? '悬赏' : '技能';
        $account_ary[] = array('time' => $temp_account_ary[Config_budget::pay_date], 'type' => $type, 'title' => $temp_account_ary[Config_commodity::title], 'trader' => Info_user::get_user_logname($conn, $trader), 'price' => $temp_account_ary[Config_commodity::price], 'price_type' => $is_loginer_income ? '收入' : '支出');
    }
    $smarty->assign('account', $income_and_outcome);
    $smarty->assign('accounts', $account_ary);
    $smarty->display('My/my-account.html');
} else {
    include 'Login.php';
}