assign("last_news", $DBC->getArray("select id, name, ndate from ucms_news where visible=1 order by ndate desc limit 0,2")); $cats = $DBC->getArray("select id, name from ucms_cat_categories where visible=1 order by sorter"); $tpl->assign("categories", $cats); $tpl->assign("top_product", $DBC->getRow("select id, name, imgformat, short from ucms_cat_production where visible=1 and is_main=1 order by rand() desc limit 0,1")); if($AuthUserData['id']) { $tpl->assign("matrixs_count", $DBC->dbSmall("select count(distinct c.matrix_id) from ucms_matrix_cells c inner join ucms_matrixs m on (m.id=c.matrix_id and m.active=1) where c.user_id='".$AuthUserData['id']."'")); $tpl->assign("matrixs_bytype", $DBC->getArray("select mt.name, m.matrix_type_id, count(distinct c.matrix_id) as cc from ucms_matrix_cells c inner join ucms_matrixs m on (m.id=c.matrix_id and m.active=1) inner join ucms_matrix_types mt on (m.matrix_type_id = mt.id) where c.user_id='".$AuthUserData['id']."' group by mt.name, m.matrix_type_id")); $tpl->assign("c_p_matix_cells_count", $DBC->dbSmall("select count(distinct c.id) from ucms_clients_matrix_cells c where c.user_id='".$AuthUserData['id']."'")); $tpl->assign("c_p_matix_bonus_cells_count", $DBC->dbSmall("select count(distinct c.id) from ucms_bonus_matrix_cells c where c.user_id='".$AuthUserData['id']."'")); $bonusmatrix_cells = $DBC->dbSmall("select count(distinct c.id) from ucms_bonus_cells c where c.user_id='".$AuthUserData['id']."'") ; $tpl->assign("bonusmatrix_cells_count", $bonusmatrix_cells); if(!$bonusmatrix_cells) $tpl->assign("bonus_levels", $DBC->getArray("select * from ucms_bonus_levels where visible=1 and price order by price")); } // kill this later // recalc_money($_SESSION['usr_id']); $tpl->assign("mtypes", $DBC->getArray("select id, name, input_points from ucms_matrix_types")); $tpl->assign("c_p_matrix_cell_price", $ini->getVal("matrix", "cell_price")); $tpl->assign("c_p_matrix_bonus_cell_price", $ini->getVal("matrix", "bonus_cell_price")); if(checkInt($_SESSION['usr_id'])) { $row = $DBC->getRow("select * from ucms_accounts where id='".$_SESSION['usr_id']."'"); $acivity = ( ($row['active_perm'] > 0) || (strtotime($row['active_to']) > time()) ) ? TRUE : FALSE; $tpl->assign("user_activity", $acivity); $tpl->assign("AuthUserData", $row); } $tpl->display($LOCALPATH."modules/index/tpl/".$base_template); function recalc_money($user_id) { global $DBC; $DBC->sqlQry("update ucms_users_transact set locked = 0 where locked_until < now() and user_id='$user_id'"); $DBC->sqlQry("update ucms_accounts set money_uah = round((select sum(amount) from ucms_users_transact where user_id='$user_id' and currency_id='0' and (locked=0 || locked is null)), 2) where id='$user_id'"); $DBC->sqlQry("update ucms_accounts set money_usd = round((select sum(amount) from ucms_users_transact where user_id='$user_id' and currency_id='1' and (locked=0 || locked is null)), 2) where id='$user_id'"); $DBC->sqlQry("update ucms_accounts set locked_money_uah = round((select sum(amount) from ucms_users_transact where user_id='$user_id' and currency_id='0' and locked = '1'), 2) where id='$user_id'"); $DBC->sqlQry("update ucms_accounts set locked_money_usd = round((select sum(amount) from ucms_users_transact where user_id='$user_id' and currency_id='1' and locked = '1'), 2) where id='$user_id'"); $DBC->sqlQry("update ucms_accounts set points = (select sum(amount) from ucms_users_transact where user_id='$user_id' and currency_id='2' and from_days(to_days(ndate)+60)>=now() and (used=0 or used is null) and (locked=0 || locked is null)) where id='$user_id'"); //$DBC->sqlQry("update ucms_accounts set points = (select sum(points) from ucms_cat_orders where client_id='$user_id') where id='$user_id'"); } ?>