| Current Path : /home2/wtmwscom/public_html/member/ |
| Current File : /home2/wtmwscom/public_html/member/cron_board_income.php |
<?php
include '../connection.php';
include '../function_lib.php';
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
$datetime = date('Y-m-d H:i:s');
$result = mysqli_query($connection, "SELECT uid, type, board_type FROM user WHERE uid != 100 ORDER BY recid ASC");
while ($row = mysqli_fetch_object($result)) {
$uid = $row->uid;
$type = $row->type;
$board_type = $row->board_type;
if($board_type==1){
$board_id_count = get_count_board_user_id_by_board_type($uid, $board_type);
if($board_id_count >= get_board_id_count_const($board_type)){
//update user board type
mysqli_query($connection, "UPDATE user SET board_type = '2' WHERE uid = '$uid'");
//add to board
add_user_to_board($uid, 2, $datetime);
}
}
elseif($board_type==2){
$board_id_count = get_count_board_user_id_by_board_type($uid, $board_type);
if($board_id_count >= get_board_id_count_const($board_type)){
//update user board type
mysqli_query($connection, "UPDATE user SET board_type = '3' WHERE uid = '$uid'");
//add to board
add_user_to_board($uid, 3, $datetime);
}
}
elseif($board_type==3){
$board_id_count = get_count_board_user_id_by_board_type($uid, $board_type);
if($board_id_count>=get_board_id_count_const($board_type)){
//update user board type
mysqli_query($connection, "UPDATE user SET board_type = '4' WHERE uid = '$uid'");
//add to board
add_user_to_board($uid, 4, $datetime);
}
}
elseif($board_type==4){
$board_id_count = get_count_board_user_id_by_board_type($uid, $board_type);
if($board_id_count>=get_board_id_count_const($board_type)){
//update user board type
mysqli_query($connection, "UPDATE user SET board_type = '5' WHERE uid = '$uid'");
//add to board
add_user_to_board($uid, 5, $datetime);
}
}
elseif($board_type==5){
$board_id_count = get_count_board_user_id_by_board_type($uid, $board_type);
if($board_id_count>=get_board_id_count_const($board_type)){
//update user board type
mysqli_query($connection, "UPDATE user SET board_type = '6' WHERE uid = '$uid'");
//add to board
add_user_to_board($uid, 6, $datetime);
}
}
}
function get_board_id_count_const($board_type){
$board_id_count = array(1=>30, 2=>30, 3=>15, 4=>15, 5=>15);
return $board_id_count[$board_type];
}
//function get_count_board_user_id_by_board_type($uid, $board_type) {
// //$level = array(array($uid));
// $level = array();
// $count=0;
// $result = mysqli_query($connection, "select uid from board_user where placement_id = '$uid' AND board_type='$board_type' ORDER BY position ASC ");
// if (mysqli_num_rows($result) != 0) {
// $i = 1;
// while ($row = mysqli_fetch_object($result)) {
// $level[$i][] = $row->uid;
// $count++;
// }
// while (TRUE) {
// foreach ($level[$i] as $value) {
// $result = mysqli_query($connection, "select uid from board_user where placement_id = '$value' AND board_type='$board_type' ORDER BY position ASC ");
// //if(mysqli_num_rows($result) != 0){
// while ($row = mysqli_fetch_object($result)) {
// $level[$i + 1][] = $row->uid;
// $count++;
// }
// //}
// }
// // if($i==4){break;}
// if (!empty($level[$i + 1])) {
// $i++;
// continue;
// }else {
// //return $level;
// break;
// }
// }
// }
// //else{
// return $count;
// //}
//}