-
2005-04-24 21:54
KissVenus
[quote]
#**************************************************************************#
# MolyX Board 2
# ---------------------------
# copyright ?2004 - 2005 Molyx Studios. All Rights Reserved. http://www.molyx.com
# MolyX Board is licensed software. This file may not be redistributed in whole or in
# part. By installing and/or using this software you hereby agree to all of the terms,
# conditions, and restrictions set by MolyX. If you do not accept these Terms and
# Conditions, please do not use this software.
# MolyX Studios may revise these Terms and Conditions at any time without notice.
# Please visit www.molyx.com periodically to review the Terms and Conditions,
# or contact the author for clarification.
#**************************************************************************#
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'bank');
require_once('./global.php');
class bank
{
var $banksettings = array();
function show()
{
global $forums, $DB, $_INPUT, $bbuserinfo, $bboptions;
if ( !$bbuserinfo || !$bbuserinfo['id'] || $bbuserinfo['id'] < 1 ) {
$forums->func->standard_error("notlogin");
}
$forums->lang = $forums->func->load_lang($forums->lang, 'bank' );
$this->banksettings = $forums->cache['banksettings'];
if (!$this->banksettings['openbank']) {
$forums->func->standard_error("bankclosed");
}
require_once('./includes/xfunctions_bank.php');
$this->bankfunc = new bankfunc();
switch ($_INPUT['do'])
{
case 'purge' : $this->purge(); break;
case 'dopurge' : $this->dopurge(); break;
case 'mkaccount' : $this->mkaccount(); break;
case 'clearlog' : $this->clearlog(); break;
case 'takeloan' : $this->takeloan(); break;
case 'pbclean' : $this->pbclean(); break;
case 'returnloan' : $this->returnloan(); break;
case 'transfer' : $this->transfer(); break;
case 'depositorwithdraw' : $this->depositorwithdraw(); break;
case 'borsreputation' : $this->borsreputation(); break;
default : $this->showmain(); break;
}
}
function calculate_credit()
{
global $forums, $bbuserinfo, $DB;
$banksettings = $this->banksettings;
// ======================================
// 评估值和信誉额计算方法
// ======================================
// 基础信誉额
// 积分 = 基础*(100+积分)/250
// 发贴数量 = 发贴数量*3/4
// 精华 = 基础*精华*5/发贴数 => 计算比例
// 注册时间(小时)
// 固定资产 = 固定资产*130/100
// 总和 = 所有相加*(发贴数+精华*3)/发贴数
// 按照每 +-1 积分 +-2% 信誉额总和
// ======================================
$creditinfo = array();
$basic = !$banksettings['bankloanusegroup']?$banksettings['bankloanamount']:$bbuserinfo['bankloanlimit'];
$creditinfo['basic'] = array ( "name" => $forums->lang['basiccredit'],
"desc" => $forums->lang['basiccreditdesc'],
"factor" => $basic,
"value" => $basic );
$reputation = $basic*(100+$bbuserinfo['reputation'])/250;
$creditinfo['reputation'] = array ( "name" => $forums->lang['reputation'],
"desc" => $forums->lang['reputationdesc'],
"factor" => $bbuserinfo['reputation'],
"value" => $reputation );
$posts = $bbuserinfo['posts']*3/4;
$creditinfo['posts'] = array ( "name" => $forums->lang['posts'],
"desc" => $forums->lang['postsdesc'],
"factor" => $bbuserinfo['posts'],
"value" => $posts );
if ( !$bbuserinfo['posts'] )
$quint = 0;
else
$quint = $basic*$bbuserinfo['quintessence']*5/$bbuserinfo['posts'];
$creditinfo['quint'] = array ( "name" => $forums->lang['quintessence'],
"desc" => $forums->lang['quintessencedesc'],
"factor" => $bbuserinfo['quintessence'],
"value" => $quint );
$jointime = intval((TIMENOW-$bbuserinfo['joindate']) / 3600);
$creditinfo['jointime'] = array ( "name" => $forums->lang['jointime'],
"desc" => $forums->lang['jointimedesc'],
"factor" => $jointime,
"value" => $jointime );
//$tmpdata = $DB->query_first("SELECT SUM(itemvalue) as totalvalue FROM ".TABLE_PREFIX."userinventory WHERE itemvalue > 0 AND ownerid = ".$bbuserinfo['id']);
//$realestate = $tmpdata['totalvalue']!=NULL?$tmpdata['totalvalue']:0;
$realestate = 0;
$reval = $realestate*13/10;
$realestate = round($realestate, 2);
$realestate = number_format($realestate, 2, '.', '');
$creditinfo['realestate'] = array ( "name" => $forums->lang['realestate'],
"desc" => $forums->lang['realestatedesc'],
"factor" => $realestate,
"value" => $reval );
$creditscore = $basic + $jointime + $posts + $reputation + $quint + $reval;
// 计算精华帖比例
if ( $bbuserinfo['posts'] > 1 && $bbuserinfo['quintessence'] > 1 )
$creditscore = $creditscore*($bbuserinfo['posts']+$bbuserinfo['quintessence']*3)/$bbuserinfo['posts'];
// 按照每 +-1 积分 +-2% 信誉额
$creditscore = $creditscore*(50+$bbuserinfo['reputation'])/50;
$creditinfo['creditamount'] = $creditscore;
$creditinfo['creditscore'] = $forums->func->fetch_number_format($creditscore);
while ( list($key, $val) = each($creditinfo) )
{
if ( $key != "creditscore" && $key != "creditamount" )
{
$val['value'] = round($val['value'], 2);
$val['value'] = number_format($val['value'], 2, '.', '');
}
$creditinfo[$key] = $val;
}
if ( $banksettings['bankloanreglimit'] && $creditinfo['jointime']['factor'] < $banksettings['bankloanreglimit'] )
$creditinfo['jointime']['factor'] = "".$creditinfo['jointime']['factor']."";
if ( $banksettings['bankloanpostlimit'] && $creditinfo['posts']['factor'] < $banksettings['bankloanpostlimit'] )
$creditinfo['posts']['factor'] = "".$creditinfo['posts']['factor']."";
if ( $banksettings['bankloanreplimit'] && $creditinfo['reputation']['factor'] < $banksettings['bankloanreplimit'] )
$creditinfo['reputation']['factor'] = "".$creditinfo['reputation']['factor']."";
return $creditinfo;
}
function mkloantypelist()
{
$banksettings = $this->banksettings;
$listcode = array();
$types = $banksettings['bankloantimelimit'];
$ints = $banksettings['bankloaninterest'];
if ( !strstr($types, ",") && !strstr($ints, ",") && intval($stypes) && intval($ints) )
{
$listcode[] = array( "type" => $types,
"interest" => $ints );
return $listcode;
}
if ( strstr($types, ",") )
$types = explode(",", $types);
if ( strstr($ints, ",") )
$ints = explode(",", $ints);
if ( is_array($types) && is_array($ints) && sizeof($types) == sizeof($ints) )
{
for ( $i=0; $i < sizeof($types); $i++ )
{
$types[$i] = trim($types[$i]);
$itns[$i] = trim($ints[$i]);
if ( !intval($types[$i]) || !intval($ints[$i]) )
continue;
$listcode[] = array( "type" => $types[$i],
"interest" => $ints[$i] );
}
}
else if ( is_array($types) && is_array($ints) && sizeof($types) != sizeof($ints) )
$listcode[] = array( "type" => $types[0],
"interest" => $ints[0] );
else if ( is_array($types) && !is_array($ints) && intval($ints) )
$listcode[] = array( "type" => $types[0],
"interest" => $ints );
else if ( !is_array($types) && is_array($ints) && intval($types) )
$listcode[] = array( "type" => $types,
"interest" => $ints[0] );
return $listcode;
}
function fetch_userinfo($crediton=FALSE)
{
global $forums, $bbuserinfo;
$banksettings = $this->banksettings;
$thisuserinfo = array();
if ( $banksettings['bankloanonoff'] && $crediton )
$thisuserinfo['credit'] = $this->calculate_credit();
if ( $bbuserinfo['avatarlocation'] )
$thisuserinfo['avatarurl'] = $forums->func->get_avatar($bbuserinfo['avatarlocation'], 1, $bbuserinfo['avatarsize'], $bbuserinfo['avatartype']);
if ( $bbuserinfo['mkaccount'] > 0 )
{
$thisuserinfo['mkaccount'] = $forums->func->get_date($bbuserinfo['mkaccount'], 3);
$thisuserinfo['bank'] = $bbuserinfo['bank'];
}
else
$thisuserinfo['bank'] = $thisuserinfo['mkaccount'] = $forums->lang['notcreateaccount'];
if ( !empty($bbuserinfo['customtitle']) )
$thisuserinfo['title'] = $bbuserinfo['customtitle'];
else
$thisuserinfo['title'] = $bbuserinfo['grouptitle'];
$thisuserinfo['joindate'] = $forums->func->get_date($bbuserinfo['joindate'], 3);
// Log Analyse
// ==========================
$logtotal = 0;
$thisuserinfo['exlog'] = array();
if ( $bbuserinfo['exlog'] && strlen($bbuserinfo['exlog']) > 0 )
{
$thisuserinfo['exlog'] = stripslashes($bbuserinfo['exlog']);
$thisuserinfo['exlog'] = unserialize($thisuserinfo['exlog']);
for ( $i=0; $i < sizeof($thisuserinfo['exlog']); $i++ )
{
$thisuserinfo['exlog'][$i]['time'] = $forums->func->get_date($thisuserinfo['exlog'][$i]['time'], 2);
if ( $thisuserinfo['exlog'][$i]['num'] > 0 )
{
$thisuserinfo['exlog'][$i]['type'] = 1;
}
else
{
$thisuserinfo['exlog'][$i]['type'] = -1;
$thisuserinfo['exlog'][$i]['num'] = $thisuserinfo['exlog'][$i]['num']*-1;
}
$logtotal++;
}
}
if ( $logtotal < 5 )
{
$logleft = 5-$logtotal;
for ( $i=0; $i < $logleft; $i++ )
{
$thisuserinfo['exlog'][] = array("none"=>0);
}
}
// ==========================
return $thisuserinfo;
}
function generate_toprich()
{
global $forums, $DB;
$toprichdata = $DB->query("SELECT id, name, bank+cash as money FROM ".TABLE_PREFIX."user WHERE mkaccount > 0 ORDER BY money DESC LIMIT 10");
$toprich = array();
$topnum = 0;
while ( $a = $DB->fetch_array($toprichdata) )
{
$topnum++;
$a['topnum'] = $topnum;
$a['money'] = $forums->func->fetch_number_format($a['money']);
$toprich[] = $a;
}
return $toprich;
}
function can_loan()
{
global $bbuserinfo;
$banksettings = $this->banksettings;
if ( !$banksettings['bankloanonoff'] )
return FALSE;
if ( $banksettings['bankloanusegroup'] && !$bbuserinfo['bankloanlimit'] )
return FALSE;
else if ( !$banksettings['bankloanamount'] )
return FALSE;
if ( !$bbuserinfo['id']
|| $bbuserinfo['usergroupid'] == 1
|| $bbuserinfo['usergroupid'] == 5 )
return FALSE;
if ( !$bbuserinfo['mkaccount'] || $bbuserinfo['mkaccount'] == -1 )
return FALSE;
if ( $banksettings['bankloanreglimit']
&& ((TIMENOW-$bbuserinfo['joindate'])/60/60) < $banksettings['bankloanreglimit'] )
return FALSE;
if ( $banksettings['bankloanpostlimit'] && $bbuserinfo['posts'] < $banksettings['bankloanpostlimit'] )
return FALSE;
if ( $banksettings['bankloanreplimit'] && $bbuserinfo['reputation'] < $banksettings['bankloanreplimit'] )
return FALSE;
return TRUE;
}
function showmain()
{
global $forums, $DB, $bbuserinfo, $bboptions;
-
2005-04-24 21:55
KissVenus
好像有长度限制
-
老哥还没有睡啊
我闪了
-
哎呀,懒的看,php一般般,不精通的说