function duplicateGame($game_id) { global $config; $basedir = $config['basedir']; $g = getGame($game_id); $bet_items = getBetItems($g['g_id']); $title = $g['g_title']; $description = $g['g_description']; $imgfilename = $g['g_image']; $category = $g['g_categories']; $tags = $g['g_tags']; $bet_info = $g['g_betInfo']; $bet_condition = $g['g_addInfo']; $title_jp = $g['g_title_jp']; $description_jp = $g['g_description_jp']; $category_jp = $g['g_categories_jp']; $tags_jp = $g['g_tags_jp']; $bet_info_jp = $g['g_betInfo_jp']; $bet_condition_jp = $g['g_addInfo_jp']; $reserve_time1 = time(); $reserve_time2 = time(); $timezone = $g['g_timezone']; $coin_per_bet = $g['g_coinPerBet']; $house_comm = $g['g_houseCom']; $publish_type = 'draft'; $is_recommend = $g['g_isRecommend']; $is_trial = $g['g_isTrial']; $jap_page = $g['g_japPage']; $eng_page = $g['g_engPage']; $bet_minimum = $g['g_betMinimum']; $q = "INSERT INTO games "; $q .= "(g_title, g_title_jp, g_description, g_description_jp, g_image, g_categories, g_categories_jp, g_tags, g_tags_jp, g_betInfo, g_betInfo_jp, g_addInfo, g_addInfo_jp, g_schedFrom, g_schedTo, g_timezone, g_coinPerBet, g_houseCom, g_publishType, g_isRecommend, g_isTrial, g_japPage, g_engPage, g_betMinimum, g_isCancelled, g_isClosed, g_isDeleted) "; $q .= "VALUES "; $q .= "('{$title}', '{$title_jp}', '{$description}', '{$description_jp}', '{$imgfilename}', '{$category}', '{$category_jp}', '{$tags}', '{$tags_jp}', '{$bet_info}', '{$bet_info_jp}', '{$bet_condition}', '{$bet_condition_jp}', '{$reserve_time1}', '{$reserve_time2}', '{$timezone}', '{$coin_per_bet}', '{$house_comm}', '{$publish_type}', '{$is_recommend}', '{$is_trial}', '{$jap_page}', '{$eng_page}', '{$bet_minimum}', '0', '0', '0')"; mysql_query($q); $insert_id = mysql_insert_id(); $cachefile = $basedir . '/temp/bet_items_active.php'; $cachedata = false; if (file_exists($cachefile)) { $cachedata = json_decode(file_get_contents($cachefile), true); } foreach ($bet_items as $bi) { $description = $bi['bi_description']; $description_jp = $bi['bi_description_jp']; $bet_id = addBetItem($insert_id, $description_jp, $description); if ($bet_id and $cachedata) { $cachedata[] = array('bi_id' => $bet_id, 'bi_game_id' => $insert_id, 'bi_description' => $description, 'bi_winner' => 0); } } if ($cachedata) { file_put_contents($cachefile, json_encode($cachedata)); } // erase the cache $filename = $basedir . '/temp/all_games.txt'; unlink($filename); $games = getAllGames(); file_put_contents($filename, json_encode($games)); return true; }
if (!$total_placed_coins) { $cachefile = $basedir . '/temp/bet_items_active.php'; $cachedata = false; if (file_exists($cachefile)) { $temp = json_decode(file_get_contents($cachefile), true); // remove all bet items from this game foreach ($temp as $c) { if ($c['bi_game_id'] != $game_id) { $cachedata[] = $c; } } } deleteBetItem($game_id); $count_bi = count($bet_items); for ($i = 0; $i < $count_bi; $i++) { $bet_id = addBetItem($game_id, $bet_items[$i], $bet_items_en[$i]); if ($bet_id and $cachedata) { $cachedata[] = array('bi_id' => $bet_id, 'bi_game_id' => $insert_id, 'bi_description' => $bet_items_en[$i], 'bi_description_jp' => $bet_items[$i], 'bi_winner' => 0); } } if ($cachedata) { file_put_contents($cachefile, json_encode($cachedata)); } } // !if $total_placed_coins // renew the cache $filename = $basedir . '/temp/all_games.txt'; $games = getAllGames(); if (file_exists($filename)) { unlink($filename); }
} else { $bool = true; } if (!$bool) { addTag($tag, '', 'en'); } } if ($insert_id) { $cachefile = $basedir . '/temp/bet_items_active.php'; $cachedata = false; if (file_exists($cachefile)) { $cachedata = json_decode(file_get_contents($cachefile), true); } $count_bi = count($bet_items); for ($i = 0; $i < $count_bi; $i++) { $bet_id = addBetItem($insert_id, $bet_items[$i], $bet_items_en[$i]); if ($bet_id and $cachedata) { $cachedata[] = array('bi_id' => $bet_id, 'bi_game_id' => $insert_id, 'bi_description' => $bet_items_en[$i], 'bi_description_jp' => $bet_items[$i], 'bi_winner' => 0); } } if ($cachedata) { file_put_contents($cachefile, json_encode($cachedata)); } } // erase the cache $filename = $basedir . '/temp/all_games.txt'; unlink($filename); $games = getAllGames(); file_put_contents($filename, json_encode($games)); //sleep(5); header('Location: ' . $baseurl . '/admin/games?lang=' . $LANGUAGE);