userdata['acclevel'] < 80) die ('Access denied!'); ?>      title; ?>

I have no permission to write to '$f'"; if ($ok != '') { echo 'FATAL:


Correct this before continuing'; die(); } return true; } function getTableFields($table,$auto_increment) { // get a field array of specified table global $db; $db->query("SHOW COLUMNS FROM $table;"); $res = array(); while ($r=$db->fetch_array()) { if ((!$auto_increment) && ($r['Extra']=='auto_increment')) { continue; } else { array_push($res,$r['Field']); } } return $res; } function copySettings($table,$game1,$game2) { global $db; $db->query("SELECT game FROM $table WHERE game='$game2' LIMIT 1;"); if ($db->num_rows()!=0) $ret = 'Target gametype exists, nothing done!'; else { $db->query("SELECT count(game) AS cnt FROM $table WHERE game='$game1';"); $r = $db->fetch_array(); if ($r['cnt']==0) $ret = 'No data existent for source gametype.'; else { $ret = $r['cnt'].' entries copied!'; $fields = ''; $ignoreFields = array('game','id','d_winner_id','d_winner_count','g_winner_id','g_winner_count','count','picked','kills','deaths','headshots'); foreach (getTableFields($table,0) AS $field) { if (!in_array($field, $ignoreFields)) { if ($fields!='') $fields .= ', '; $fields .= $field; } } $SQL = "INSERT INTO $table ($fields,game) SELECT $fields,'$game2' FROM $table WHERE game='$game1';"; $db->query($SQL); } } return $ret.""; } function mkdir_recursive($pathname) { is_dir(dirname($pathname)) || mkdir_recursive(dirname($pathname)); return is_dir($pathname) || @mkdir($pathname); } function copyFile($source,$dest) { if ($source != '') { $source = IMAGE_PATH."/games/$source"; $dest = IMAGE_PATH."/games/$dest"; if (!is_file($source)) $ret = "File not found $source (dest: $dest)
"; else { mkdir_recursive(dirname($dest)); if (!copy($source,$dest)) $ret = 'FAILED'; else $ret = 'OK'; } return "Copying '$source' to '$dest': $ret"; } return ''; } function scanCopyFiles($source,$dest) { global $files; $d = dir(IMAGE_PATH.'/games/'.$source); if ($d !== false) { while (($entry=$d->read()) !== false) { if (is_file(IMAGE_PATH.'/games/'.$source.'/'.$entry) && ($entry != '.') && ($entry != '..')) $files[] = array($source.'/'.$entry,$dest.'/'.$entry); if (is_dir(IMAGE_PATH.'/games/'.$source.'/'.$entry) && ($entry != '.') && ($entry != '..')) scanCopyFiles($source.'/'.$entry,$dest.'/'.$entry); } $d->close(); } } if (isset($_POST['confirm'])) { $game1 = ''; if (isset($_POST['game1'])) if ($_POST['game1']!='') $game1 = $_POST['game1']; $game2 = ''; if (isset($_POST['game2'])) if ($_POST['game2']!='') $game2 = $_POST['game2']; $game2name = ''; if (isset($_POST['game2name'])) if ($_POST['game2name']!='') $game2name = $_POST['game2name']; echo '


'; echo 'Target gametype exists, nothing done!

'; } else { $db->query("INSERT INTO hlstats_Games (code,name,hidden,realgame) SELECT '$game2', '$game2name', '0', realgame FROM hlstats_Games WHERE code='$game1'"); echo 'OK'; $dbtables = array(); array_push($dbtables, 'hlstats_Actions', 'hlstats_Awards', 'hlstats_Ribbons', 'hlstats_Ranks', 'hlstats_Roles', 'hlstats_Teams', 'hlstats_Weapons' ); foreach ($dbtables as $dbt) { echo "
  • $dbt ... "; echo copySettings($dbt,$game1,$game2); } echo '


    '; echo '


    '; echo 'Done.

    '; } } else { $result = $db->query("SELECT code, name FROM hlstats_Games ORDER BY code;"); unset($games); $games[] = ''; while ($rowdata = $db->fetch_row($result)) { $games[] = ""; } ?>
    Are you sure to copy all settings from the selected gametype to the new gametype name?
    All existing images will be copied also to the new gametype!

    Existing gametype:
    New gametype code:
    New gametype name: