$setting = array('show_credit_log' => 0, 'close_credit_log' => 0); $settings = gpc('setting', 'P', $setting); if (!$error) { settings_cache($settings); $sysmsg[] = '积分配置管理更新成功'; redirect(urr(ADMINCP, "item={$item}&menu={$menu}&action={$action}"), $sysmsg); } else { redirect('back', $sysmsg); } } else { $log_count = @$db->result_first("select count(*) from " . get_table_credit_log() . ""); $perpage = 50; $userid = (int) gpc('userid', 'G', 0); $task_sql = in_array($task, array('download', 'ref')) ? " p.action='{$task}' and" : ''; $uid_sql = $userid ? " p.userid='{$userid}' and" : ''; $sql_do = get_table_credit_log() . " p,{$tpf}files f,{$tpf}users u where {$task_sql} {$uid_sql} p.userid=u.userid and p.file_id=f.file_id"; $rs = $db->fetch_one_array("select count(*) as total_num from {$sql_do}"); $total_num = $rs['total_num']; $start_num = ($pg - 1) * $perpage; $q = $db->query("select p.*,f.file_name,f.file_extension,u.username from {$sql_do} order by p.in_time desc limit {$start_num},{$perpage}"); $orders = array(); while ($rs = $db->fetch_array($q)) { $rs[a_view] = urr(ADMINCP, "item={$item}&menu={$menu}&action={$action}&userid={$rs[userid]}"); $rs[action] = $ca_arr[$rs[action]]; $tmp_ext = $rs[file_extension] ? '.' . $rs[file_extension] : ''; $rs[file_name] = $rs[file_name] . $tmp_ext; $rs['in_time'] = date('Y-m-d H:i:s', $rs['in_time']); $orders[] = $rs; } $db->free($q); unset($rs);
$rs['o_status'] = get_income_status($rs['o_status']); $rs['in_time'] = date('Y-m-d H:i:s', $rs['in_time']); $orders[] = $rs; } $db->free($q); unset($rs); $page_nav = multi($total_num, $perpage, $pg, urr("mydisk", "item=profile&action=income_log")); require_once template_echo('profile', $user_tpl_dir); break; case 'credit_log': if ($auth[view_credit]) { $sql_do = "(p.action='download' or p.action='view')"; } else { $sql_do = "p.action='download'"; } $sql_do = get_table_credit_log() . " p,{$tpf}files f where {$sql_do} and p.userid='{$pd_uid}' and p.file_id=f.file_id"; $rs = $db->fetch_one_array("select count(*) as total_num from {$sql_do}"); $total_num = $rs['total_num']; $start_num = ($pg - 1) * $perpage; $q = $db->query("select p.*,f.file_name,file_extension from {$sql_do} order by p.in_time desc limit {$start_num},{$perpage}"); $orders = array(); while ($rs = $db->fetch_array($q)) { $tmp_ext = $rs[file_extension] ? '.' . $rs[file_extension] : ''; $rs[file_name] = $rs[file_name] . $tmp_ext; $rs[action] = $ca_arr[$rs[action]]; $rs['in_time'] = date('Y-m-d', $rs['in_time']); $orders[] = $rs; } $db->free($q); unset($rs); $page_nav = multi($total_num, $perpage, $pg, urr("mydisk", "item=profile&action={$action}"));
$str .= '</select>' . LF; echo 'true|' . $str; } else { echo __('multi_server_not_set'); } break; case 'adm_del_log': $log_day = (int) gpc('log_day', 'P', 0); if ($pd_gid != 1) { exit(__('not_admin_error')); } if (!$log_day) { exit(__('log_day_error')); } $tmp = $log_day * 86400; $db->query_unbuffered("delete from " . get_table_credit_log() . " where in_time<{$timestamp}-{$tmp}"); exit('true|' . __('adm_del_log_success')); break; case 'dostat': $act = gpc('act', 'P', ''); $dd = gpc('dd', 'P', ''); if ($act && $dd) { if (in_array($act, array('views', 'downs', 'money'))) { //$all = (float)@$db->result_first("select sum($act) from {$tpf}stat_user where dd='$dd'"); $all = 0; $q = $db->query("select views,downs,money,userid from {$tpf}stat_user where dd='{$dd}'"); while ($rs = $db->fetch_array($q)) { $all += get_discount($rs[userid], $rs[$act]); } $db->free($q); unset($rs);
function add_credit_log($file_id, $credit, $action, $userid, $ref = '') { global $db, $tpf, $timestamp, $onlineip, $settings; if (!$settings['close_credit_log']) { switch ($action) { case 'download': $id = @$db->result_first("select id from " . get_table_credit_log() . " where file_id='{$file_id}' and userid='{$userid}' and action='{$action}' order by id desc limit 1"); if ($id) { $db->query_unbuffered("update " . get_table_credit_log() . " set credit=credit+{$credit},in_time='{$timestamp}',ip='{$onlineip}' where id='{$id}'"); } else { $ins = array('file_id' => $file_id, 'credit' => $credit, 'action' => $action, 'in_time' => $timestamp, 'ip' => $onlineip, 'userid' => $userid); $db->query_unbuffered("insert into " . get_table_credit_log() . " set " . $db->sql_array($ins) . ""); } break; case 'view': $id = @$db->result_first("select id from " . get_table_credit_log() . " where file_id='{$file_id}' and userid='{$userid}' and action='{$action}' order by id desc limit 1"); if ($id) { $db->query_unbuffered("update " . get_table_credit_log() . " set credit=credit+{$credit},in_time='{$timestamp}',ip='{$onlineip}' where id='{$id}'"); } else { $ins = array('file_id' => $file_id, 'credit' => $credit, 'action' => $action, 'in_time' => $timestamp, 'ip' => $onlineip, 'userid' => $userid); $db->query_unbuffered("insert into " . get_table_credit_log() . " set " . $db->sql_array($ins) . ""); } break; case 'ref': if ($ref) { $ins = array('file_id' => $file_id, 'action' => $action, 'in_time' => $timestamp, 'ip' => $onlineip, 'userid' => $userid, 'ref' => $ref); $db->query_unbuffered("insert into " . get_table_credit_log() . " set " . $db->sql_array($ins) . ""); } break; } } }