Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP] Edycja skryptu psychostats
Forum PHP.pl > Forum > Gotowe rozwiązania
botnaizi
Witam.
Chciałbym przerobić a właściwie wyciągnąć pewne informacje ze skryptu psychostats
chodzi dokładnie o te : http://tower.org.pl/rank/weapons.php
"27 broni zabilo 10,073,226 gracz i zadalo 1,451,043,360 Obrazen" czyli te wszystkie liczby np. na stronę główną.
Jeśli jest ktoś zainteresowany zrobieniem tego tutaj jest skrypt : http://www.psychostats.com/downloads/ .

W pliku weapons.php jest $totaldamage, $totalkills ale nie mam pojęcia jak przenieść to do innego pliku.
  1. <?php
  2. /**
  3.  * This file is part of PsychoStats.
  4.  *
  5.  * Written by Jason Morriss <stormtrooper@psychostats.com>
  6.  * Copyright 2008 Jason Morriss
  7.  *
  8.  * PsychoStats is free software: you can redistribute it and/or modify
  9.  * it under the terms of the GNU General Public License as published by
  10.  * the Free Software Foundation, either version 3 of the License, or
  11.  * (at your option) any later version.
  12.  *
  13.  * PsychoStats is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16.  * GNU General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU General Public License
  19.  * along with PsychoStats. If not, see <http://www.gnu.org/licenses/>.
  20.  *
  21.  * Version: $Id: weapons.php 385 2008-04-14 00:57:23Z lifo $
  22.  */
  23. define("PSYCHOSTATS_PAGE", true);
  24. include(dirname(__FILE__) . "/includes/common.php");
  25. $cms->init_theme($ps->conf['main']['theme'], $ps->conf['theme']);
  26. $ps->theme_setup($cms->theme);
  27. $cms->theme->page_title('PsychoStats - Weapon Usage');
  28.  
  29. // change this if you want the default sort of the player listing to be something else like 'kills'
  30. $DEFAULT_SORT = 'kills';
  31.  
  32. $validfields = array('sort','order','xml','v');
  33. $cms->theme->assign_request_vars($validfields, true);
  34.  
  35. $v = strtolower($v);
  36. $sort = trim(strtolower($sort));
  37. $order = trim(strtolower($order));
  38. $start = 0;
  39. $limit = 100;
  40. if (!preg_match('/^\w+$/', $sort)) $sort = $DEFAULT_SORT;
  41. if (!in_array($order, array('asc','desc'))) $order = 'desc';
  42.  
  43. $stats = $ps->get_sum(array('kills','damage'), $ps->c_plr_data);
  44.  
  45. $weapons = $ps->get_weapon_list(array(
  46. 'sort' => $sort,
  47. 'order' => $order,
  48. 'start' => $start,
  49. 'limit' => $limit,
  50. ));
  51. $totalweapons = count($weapons);
  52.  
  53. // calculate some extra percentages for each weapon and determine max values
  54. $max = array();
  55. $keys = array('kills', 'damage', 'headshotkills');
  56. for ($i=0; $i < count($weapons); $i++) {
  57. foreach ($keys as $k) {
  58. if ($stats[$k]) {
  59. $weapons[$i][$k.'pct'] = ($stats[$k]) ? ceil($weapons[$i][$k] / $stats[$k] * 100) : 0;
  60. }
  61. if ($weapons[$i][$k] > $max[$k]) $max[$k] = $weapons[$i][$k];
  62. }
  63. }
  64. // calculate scale width of pct's based on max
  65. $scale = 200;
  66. $ofs = $scale; // + 40;
  67. for ($i=0; $i < count($weapons); $i++) {
  68. foreach ($keys as $k) {
  69. if ($max[$k] == 0) {
  70. $weapons[$i][$k.'width'] = $ofs - ceil($weapons[$i][$k] / 1 * $scale);
  71. } else {
  72. $weapons[$i][$k.'width'] = $ofs - ceil($weapons[$i][$k] / $max[$k] * $scale);
  73. }
  74. }
  75. }
  76.  
  77. if ($xml) {
  78. $ary = array();
  79. foreach ($weapons as $w) {
  80. unset($w['dataid']);
  81. $ary[ $w['uniqueid'] ] = $w;
  82. }
  83. print_xml($ary);
  84. }
  85.  
  86. // organize the weapons by 'class'
  87. $weaponclasses = array();
  88. foreach ($weapons as $w) {
  89. $class = !empty($w['class']) ? $w['class'] : $cms->trans('Unclassified');
  90. $weaponclasses[$class][] = $w;
  91. }
  92. ksort($weaponclasses);
  93.  
  94.  
  95. // build a dynamic table that plugins can use to add custom columns of data
  96. $table = $cms->new_table($weapons);
  97. $table->if_no_data($cms->trans("No Weapons Found"));
  98. $table->attr('class', 'ps-table ps-weapon-table');
  99. $table->start_and_sort($start, $sort, $order);
  100. $table->columns(array(
  101. 'uniqueid' => array( 'label' => $cms->trans("Weapon"), 'callback' => 'ps_table_weapon_link' ),
  102. 'kills' => array( 'label' => $cms->trans("Kills"), 'modifier' => 'commify' ),
  103. 'headshotkills' => array( 'label' => $cms->trans("HS"), 'modifier' => 'commify', 'tooltip' => $cms->trans("Headshot Kills") ),
  104. 'headshotkillspct' => array( 'label' => $cms->trans("HS%"), 'modifier' => '%s%%', 'tooltip' => $cms->trans("Headshot Kills Percentage") ),
  105. 'ffkills' => array( 'label' => $cms->trans("FF"), 'modifier' => 'commify', 'tooltip' => $cms->trans("Friendly Fire Kills") ),
  106. 'ffkillspct' => array( 'label' => $cms->trans("FF%"), 'modifier' => '%s%%', 'tooltip' => $cms->trans("Friendly Fire Kills Percentage") ),
  107. 'accuracy' => array( 'label' => $cms->trans("Acc"), 'modifier' => '%s%%', 'tooltip' => $cms->trans("Accuracy") ),
  108. 'shotsperkill' => array( 'label' => $cms->trans("S:K"), 'tooltip' => $cms->trans("Shots Per Kill") ),
  109. 'damage' => array( 'label' => $cms->trans("Dmg"), 'modifier' => 'abbrnum0', 'tooltip' => $cms->trans("Damage") ),
  110. ));
  111. $table->column_attr('uniqueid', 'class', 'first');
  112. $ps->weapons_table_mod($table);
  113. $cms->filter('weapons_table_object', $table);
  114.  
  115. // assign variables to the theme
  116. $cms->theme->assign(array(
  117. 'weapons_by_class' => $weaponclasses, // allow a theme to use either ...
  118. 'weapons' => $weapons, // ... way to display weapons
  119. 'weapons_table' => $table->render(),
  120. 'weapon_classes' => array_keys($weaponclasses),
  121. 'totalweapons' => $totalweapons,
  122. 'totalkills' => $stats['kills'],
  123. 'totaldamage' => $stats['damage'],
  124. ));
  125.  
  126. // display the output
  127. $basename = basename(__FILE__, '.php');
  128. //$cms->theme->add_css('css/tabs.css');
  129. $cms->full_page($basename, $basename, $basename.'_header', $basename.'_footer');
  130.  
  131. ?>

To forum nie raz mi pomagało więc mam nadzieję, że teraz też ktoś będzie wiedział o co chodzi i mi pomoże.

Pozdrawiam smile.gif
Barczi
Zapytanie do bazy w index.php i po problemie winksmiley.jpg

Przyjżyj się temu:

  1. 'totalkills' => $stats['kills'],
  2. 'totaldamage' => $stats['damage'],
botnaizi
Wszystko byłoby ok gdybym wiedział jak to zapytanie ma wyglądać smile.gif Gdzie ono w plikach jest ?
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2024 Invision Power Services, Inc.