/** * * @param string $where * @return array 返回数据库查询后的数组: */ function pagination($where, $conn, $tbl_name) { require_once 'class/Config_commodity.php'; require_once 'class/DBpagination.php'; require_once 'class/DBcount.php'; require_once 'class/Info_user.php'; require_once 'class/Config_user.php'; require_once 'Include_picture.php'; //2.向数据库查询符合条件数,以计算显示分页数目 $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; //4. 查询当前页的数据 $choosed_fields = array(Config_commodity::table_name . '.' . Config_commodity::description, Config_commodity::table_name . '.' . Config_commodity::id, Config_commodity::table_name . '.' . Config_commodity::publisher, Config_commodity::table_name . '.' . Config_commodity::title, Config_commodity::table_name . '.' . Config_commodity::price, Config_commodity::table_name . '.' . Config_commodity::release_date, Config_commodity::table_name . '.' . Config_commodity::praise, Config_commodity::table_name . '.' . Config_commodity::leave_message_time, Config_commodity::table_name . '.' . Config_commodity::id); $DBpagination = new DBpagination($tbl_name, $where, $page, SIZE_EACH_PAGE, $choosed_fields); $reval = $DBpagination->excute($conn); //逐个配置 array 三级关联数组 供界面使用 $array = array(); while (($temp_database_row_array = mysqli_fetch_array($reval, MYSQLI_ASSOC)) != null) { $userinfo = Info_user::get_user_info_by_id($conn, $temp_database_row_array[Config_commodity::publisher]); $array[] = array('imgs' => get_commodity_pic($conn, $temp_database_row_array[Config_commodity::id]), 'description' => $temp_database_row_array[Config_commodity::description], 'title' => $temp_database_row_array[Config_commodity::title], 'price' => $temp_database_row_array[Config_commodity::price], 'url' => 'upload/default.jpg', 'name' => $userinfo[Config_user::log_name], 'time' => get_time($temp_database_row_array[Config_commodity::release_date]), 'star_numbers' => $temp_database_row_array[Config_commodity::praise], 'message_numbers' => $temp_database_row_array[Config_commodity::leave_message_time], 'id' => $temp_database_row_array[Config_commodity::id]); } //5.释放资源 mysqli_free_result($reval); return array('page' => $page, 'array' => $array); }
function get_leave_message($commodity_id, $conn) { require_once 'class/Config_leave_message.php'; require_once 'class/DBpagination.php'; require_once 'class/Info_user.php'; require_once 'class/Config_user.php'; $page = isset($_REQUEST['page']) ? (int) $_GET['id'] : 1; $dbtraerser = new DBpagination(Config_leave_message::tbl_name, ' where ' . Config_leave_message::commodity_id . ' = ' . "'" . $commodity_id . "'", $page, MESSAGE_EACH_PAGE, array(Config_leave_message::content, Config_leave_message::time, Config_leave_message::talker)); $retval = $dbtraerser->excute($conn); $array_message = array(); while (($temp_database_row_array = mysqli_fetch_array($retval, MYSQLI_ASSOC)) != null) { $temp_user = Info_user::get_user_avatar_and_logname($conn, $temp_database_row_array[Config_leave_message::talker]); $array_message[] = array('description' => $temp_database_row_array[Config_leave_message::content], 'time' => get_time($temp_database_row_array[Config_leave_message::time]), 'nickname' => $temp_user[Config_user::log_name], 'img' => 'upload/avatar.png'); } mysqli_free_result($retval); return $array_message; }
function show_buy_html($commodity_id, $conn) { require_once 'class/Config_commodity.php'; require_once 'class/DBtraverser.php'; $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'; require_once 'class/Config_user.php'; $acceptor_info_array = Info_user::get_user_info_by_id($conn, $_SESSION['CURRENT_LOGIN_ID']); $publisher_info_array = Info_user::get_user_info_by_id($conn, $array_commofity_info[Config_commodity::publisher]); $commodity_array_for_display = array('nickname' => $acceptor_info_array[Config_user::log_name], 'acceptor_phone' => $acceptor_info_array[Config_user::phone_number], 'publisher_name' => $publisher_info_array[Config_user::log_name], 'publisher_phone' => $array_commofity_info[Config_commodity::communication_number], '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); return $commodity_array_for_display; } }
<?php session_start(); //$_SESSION['CURRENT_LOGIN_ID'] = 1; if (isset($_SESSION['CURRENT_LOGIN_ID'])) { include 'smarty_init.php'; require_once 'class/Info_user.php'; require_once 'class/Config.php'; $conn = Config::connect(); $user_array = Info_user::get_user_info_by_id($conn, $_SESSION['CURRENT_LOGIN_ID']); $my_personal = array('introduction' => $user_array[Config_user::autograph], 'good_buyer' => $user_array[Config_user::payer_credit], 'good_seller' => $user_array[Config_user::seller_credit], 'username' => $user_array[Config_user::legal_name], 'nickname' => $user_array[Config_user::log_name], 'gender' => $user_array[Config_user::sex], 'phone' => $user_array[Config_user::phone_number], 'email' => $user_array[Config_user::email], 'birth' => $user_array[Config_user::birthday], 'good_at' => $user_array[Config_user::strongpoint], 'hobby' => $user_array[Config_user::interestc], 'url_header' => 'upload/avatar.png'); $smarty->assign('my_personal', $my_personal); $smarty->display('My/my-personal.html'); } else { include 'Login.php'; }
<?php session_start(); if (isset($_SESSION['CURRENT_LOGIN_ID'])) { include 'smarty_init.php'; require_once 'class/Config.php'; require_once 'class/Config_user.php'; if (isset($_POST['reset'])) { //new_pwd new_pwd2 old require_once 'class/Config.php'; require_once 'class/Info_user.php'; $pwd = $_POST['old']; $newPwd = $_POST['new_pwd']; $conn = Config::connect(); $logname = $_SESSION['CURRENT_LOGIN_USER']; $retval = Info_user::updateInfo($logname, $pwd, $conn, $newPwd); if ($retval == Info_user::logname_not_exsit) { echo "<script language='javascript'> alert('logname_not_exsit!');\r\n window.history.go(-1);\r\n </script>"; // $smarty->display('My/my-change-pwd.html'); } else { if ($retval == Info_user::wrong_pass_word) { echo "<script language='javascript'> alert('wrong_pass_word!');\r\n window.history.go(-1);</script>"; // $smarty->display('My/my-change-pwd.html'); } else { if ($retval == Info_user::done) { echo "<script language='javascript'> alert('done!') ;\r\n window.history.go(-2);</script>"; // $smarty->display('My/my-set.html'); } } } } else {
require_once 'class/DBpagination.php'; require_once 'class/Config_transaction.php'; require_once 'class/Config_commodity.php'; require_once 'Include_picture.php'; require_once 'class/Info_user.php'; include 'smarty_init.php'; $user_id = $_SESSION['CURRENT_LOGIN_ID']; $conn = Config::connect(); $retval = found_transactions($conn); //逐个配置 array 三级关联数组 供界面使用 $array = array(); while (($temp_database_row_array = mysqli_fetch_array($retval, MYSQLI_ASSOC)) != null) { $buyer_id = $temp_database_row_array[Config_transaction::commodity_buyer_id]; $holder_id = $temp_database_row_array[Config_transaction::commodity_holder_id]; $trader = $buyer_id == $user_id ? $holder_id : $buyer_id; $trader_avatar_and_logname = Info_user::get_user_avatar_and_logname($conn, $trader); $array[] = array('url_header' => 'upload/avatar.png', 'url_pic' => get_one_commodity_pic($conn, $temp_database_row_array[Config_commodity::id]), 'acceptor' => $trader_avatar_and_logname[Config_user::log_name], 'title' => $temp_database_row_array[Config_commodity::title], 'price' => $temp_database_row_array[Config_commodity::price], 'id' => $temp_database_row_array[Config_commodity::id]); } $smarty->assign('accepts', $array); $smarty->display('My/my-accepted.html'); } else { include 'Login.php'; } function found_transactions($conn) { $page = isset($_REQUEST['page']) ? (int) $_REQUEST['page'] : 1; $where = ' where ' . Config_transaction::table_name . "." . Config_transaction::choosed_id . ' = ' . Config_commodity::table_name . "." . Config_commodity::id; if (isset($_GET['type'])) { if ($_GET['type'] == 'skill') { $where .= ' AND ' . Config_transaction::table_name . "." . Config_transaction::commodity_holder_id . ' = ' . "'" . $_SESSION['CURRENT_LOGIN_ID'] . "'"; } else {
//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'; }