Официальный сайт студ.городка НГТУ
Программирование и БД » Связь server Conter-strike 1.6MySQL->сайт 

#1  19.12.06 01:30

Связь server Conter-strike 1.6MySQL->сайт

Ситуация такая плагин amx_mystatus_v.3 запускаю на серваке он присоединяется к MySQL создает базу AMX и отсылает туда информацию о том кто играет, какая карта и все настроики тапа mp_limitteamce *
Праблема в том что работает все, НО показывается на сайте что играет все 1 человек!!!
Даже если там из 32 что делать в этой ситуации подскажите пожалуйста.
А то я уже незнаю что делать :(

Offline

#2  19.12.06 10:25

Re: Связь server Conter-strike 1.6MySQL->сайт

настроить =)
- девачка, тебя как зовут?
- я не помню
- как это?
- помню только последние 3 буквы
- надя?
- нет
- аадя?
- нет
- бадя?
- нет... такого имени
- вадя?
- нееет
- гадя?
- да
- гадя?
- да!

Offline

#3  19.12.06 16:08

Re: Связь server Conter-strike 1.6MySQL->сайт

Код::

DROP TABLE IF EXISTS amx_mystatus_admin;
CREATE TABLE amx_mystatus_admin (
  admin_id smallint(5) unsigned NOT NULL auto_increment,
  user varchar(20) NOT NULL default '',
  pass varchar(32) NOT NULL default '',
  PRIMARY KEY  (admin_id)
) TYPE=MyISAM;

DROP TABLE IF EXISTS amx_mystatus_player_info;
CREATE TABLE amx_mystatus_player_info (
  server_id tinyint(3) unsigned NOT NULL default '1',
  wonid varchar(20) default NULL,
  team varchar(16) default NULL,
  name varchar(32) default NULL,
  status tinyint(3) unsigned default NULL,
  frags smallint(5) unsigned default NULL,
  deaths smallint(5) unsigned default NULL,
  ping smallint(5) unsigned default NULL,
  loss smallint(5) unsigned default NULL,
  UNIQUE KEY wonid (wonid)
) TYPE=MyISAM;

DROP TABLE IF EXISTS amx_mystatus_server_info;
CREATE TABLE amx_mystatus_server_info (
  server_id smallint(6) NOT NULL default '1',
  hostname varchar(64) default NULL,
  hostport smallint(6) default NULL,
  map varchar(20) default NULL,
  maxplayers tinyint(3) unsigned default NULL,
  modname varchar(10) default NULL,
  mp_autokick tinyint(3) unsigned default NULL,
  mp_autoteambalance tinyint(3) unsigned default NULL,
  mp_c4timer smallint(5) unsigned default NULL,
  mp_flashlight tinyint(3) unsigned default NULL,
  mp_footsteps tinyint(3) unsigned default NULL,
  mp_forcechasecam tinyint(3) unsigned default NULL,
  mp_freezetime tinyint(3) unsigned default NULL,
  mp_friendlyfire tinyint(3) unsigned default NULL,
  mp_hostagepenalty tinyint(3) unsigned default NULL,
  mp_limitteams tinyint(3) unsigned default NULL,
  mp_logmessages tinyint(3) unsigned default NULL,
  mp_mapvoteratio decimal(4,2) unsigned default NULL,
  mp_roundtime smallint(5) unsigned default NULL,
  mp_timelimit mediumint(8) unsigned default NULL,
  mp_startmoney mediumint(8) unsigned default NULL,
  mp_tkpunish tinyint(3) unsigned default NULL,
  net_address varchar(20) default NULL,
  nextmap varchar(20) default NULL,
  timeleft int(11) default NULL,
  ct_score tinyint(3) unsigned NOT NULL default '0',
  terrorist_score tinyint(3) unsigned NOT NULL default '0',
  PRIMARY KEY  (server_id)
) TYPE=MyISAM;

INSERT INTO `amx_mystatus_server_info` (`server_id`, `hostname`, `hostport`, `map`, `maxplayers`, `modname`, `mp_autokick`, `mp_autoteambalance`, `mp_c4timer`, `mp_flashlight`, `mp_footsteps`, `mp_forcechasecam`, `mp_freezetime`, `mp_friendlyfire`, `mp_hostagepenalty`, `mp_limitteams`, `mp_logmessages`, `mp_mapvoteratio`, `mp_roundtime`, `mp_timelimit`, `mp_startmoney`, `mp_tkpunish`, `net_address`, `nextmap`, `timeleft`, `ct_score`, `terrorist_score`) VALUES ('1', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '0', '0'); 

DROP TABLE IF EXISTS amx_mystatus_style;
CREATE TABLE amx_mystatus_style (
  server_id tinyint(3) unsigned NOT NULL default '1',
  table_bgcolor varchar(10) NOT NULL default '#CCCCCC',
  table_font_color varchar(10) NOT NULL default '#000000',
  body_bgcolor varchar(10) NOT NULL default '#000000',
  td_font_size varchar(10) NOT NULL default '12',
  td_font_family varchar(255) NOT NULL default 'Verdana, A',
  td_cthead_font_size varchar(10) NOT NULL default '12',
  td_cthead_font_color varchar(10) NOT NULL default '#ffffff',
  td_cthead_bgcolor varchar(10) NOT NULL default '#336699',
  td_tshead_font_size varchar(10) NOT NULL default '12',
  td_tshead_font_color varchar(10) NOT NULL default '#ffffff',
  td_tshead_bgcolor varchar(10) NOT NULL default '#990033',
  tr_plr_live_font_size varchar(10) NOT NULL default '10',
  tr_plr_live_font_color varchar(10) NOT NULL default 'lime',
  tr_plr_live_bgcolor varchar(10) NOT NULL default '#666666',
  tr_plr_dead_font_size varchar(10) NOT NULL default '10',
  tr_plr_dead_font_color varchar(10) NOT NULL default 'lime',
  tr_plr_dead_bgcolor varchar(10) NOT NULL default '#666666',
  tr_plr_head_font_size varchar(10) NOT NULL default '10',
  tr_plr_head_font_color varchar(10) NOT NULL default 'lime',
  tr_plr_head_bgcolor varchar(10) NOT NULL default '#666666',
  td_cvar_font_size varchar(10) NOT NULL default '10',
  td_cvar_font_color varchar(10) NOT NULL default 'lime',
  td_cvar_bgcolor varchar(10) NOT NULL default '#333333',
  PRIMARY KEY  (server_id)
) TYPE=MyISAM;

код базы и че там не так я хз

Offline

#4  19.12.06 16:10

Re: Связь server Conter-strike 1.6MySQL->сайт

Код::

/* AMX Mod Script
* 
* AMX MyStatus .3 by SDE  <sde@ocsclan.com>
* (c) Copyright 2002
* 
* View README for installation and configuration.
*
*/

#include <amxmod>
#include <mysql>

new mhost[64]
new muser[32]
new mpass[32]
new mdb[32]
new merror[32]
new mysql = 0

public update_server_info(){

  new server_id = get_cvar_num("amx_server_id")
  
  // cvars
  new hostname[64]
  get_cvar_string("hostname",hostname,63)
  new hostport = get_cvar_num("hostport")
  new map[16]
  get_mapname(map,16)
  new maxplayers
  maxplayers = get_maxplayers()
  new modname[10]
  get_modname(modname,10)
  new mp_autokick = get_cvar_num("mp_autokick")
  new mp_autoteambalance = get_cvar_num("mp_autoteambalance")
  new mp_c4timer = get_cvar_num("mp_c4timer")
  new mp_flashlight = get_cvar_num("mp_flashlight")
  new mp_footsteps = get_cvar_num("mp_footsteps")
  new mp_forcechasecam = get_cvar_num("mp_forcechasecam")
  new mp_freezetime = get_cvar_num("mp_freezetime")
  new mp_friendlyfire = get_cvar_num("mp_friendlyfire")
  new mp_hostagepenalty = get_cvar_num("mp_hostagepenalty")
  new mp_limitteams = get_cvar_num("mp_limitteams")
  new mp_logmessages = get_cvar_num("mp_logmessages")
  new Float:mp_mapvoteratio = get_cvar_float("mp_mapvoteratio")
  new mp_roundtime = get_cvar_num("mp_roundtime")
  new mp_startmoney = get_cvar_num("mp_startmoney")
  new mp_timelimit = get_cvar_num("mp_timelimit")
  new mp_tkpunish = get_cvar_num("mp_tkpunish")
  new net_address[32] 
  get_cvar_string("net_address",net_address,31) 
  new nextmap[16]
  get_cvar_string("amx_nextmap",nextmap,16)  

  new query[1535]
  format(query,1535,"UPDATE amx_mystatus_server_info set mp_autokick='%d',mp_autoteambalance='%d',mp_c4timer='%d',mp_flashlight='%d',mp_footsteps='%d',mp_forcechasecam='%d',mp_freezetime='%d',mp_friendlyfire='%d',mp_hostagepenalty='%d',mp_limitteams='%d' where server_id='%d'",mp_autokick,mp_autoteambalance,mp_c4timer,mp_flashlight,mp_footsteps,mp_forcechasecam,mp_freezetime,mp_friendlyfire,mp_hostagepenalty,mp_limitteams,server_id) 
  mysql_query(mysql,query)
    
  new query_b[1535]
  format(query_b,1535,"UPDATE amx_mystatus_server_info set hostname='%s',hostport='%d',map='%s',maxplayers='%d',modname='%s',mp_logmessages='%d',mp_mapvoteratio='%.2f',mp_roundtime='%d',mp_startmoney='%d',mp_timelimit='%d',mp_tkpunish='%d',net_address='%s',nextmap='%s' where server_id='%d'",hostname,hostport,map,maxplayers,modname,mp_logmessages,mp_mapvoteratio,mp_roundtime,mp_startmoney,mp_timelimit,mp_tkpunish,net_address,nextmap,server_id)
  mysql_query(mysql,query_b)  

  return PLUGIN_CONTINUE
}

public update_player_info(){

  new server_id = get_cvar_num("amx_server_id")

  new players[32]
  new team[16]
  new name[32]
  new wonid
  new status
  new frags
  new deaths 
  new ping
  new loss 
  new i
  new inum
  
  new query_a[256]
  format(query_a,256,"DELETE FROM amx_mystatus_player_info")
  mysql_query(mysql,query_a)
      
  // set player info
  get_players(players,inum) 
  for(i = 0 ;i < inum; ++i){
    get_user_name(players[i],name,32)
    status = is_user_alive(players[i])
    wonid = get_user_wonid(players[i])
    frags = get_user_frags(players[i])
    deaths = get_user_deaths(players[i])
    get_user_ping(players[i], ping, loss)
    get_user_team(players[i], team, 16 )   
    
    new query_b[1024]
    format(query_b,1024,"INSERT INTO amx_mystatus_player_info set server_id='%d',wonid='%d',team='%s',name='%s',status='%d',frags='%d',deaths='%d',ping='%d',loss='%d'",server_id,wonid,team,name,status,frags,deaths,ping,loss)
    mysql_query(mysql,query_b)    
  }
  
  return PLUGIN_CONTINUE
}

// reset scores 
//
public reset_scores(){

  new server_id = get_cvar_num("amx_server_id")

  new query[256]
  format(query,256,"Update amx_mystatus_server_info set ct_score='0',terrorist_score='0' where server_id='%d'",server_id)
  mysql_query(mysql,query)
  
  return PLUGIN_CONTINUE 
}

public init_functions(){

  server_cmd("exec addons/amx/mysql.cfg")

  get_cvar_string("amx_mysql_host",mhost,64) 
  get_cvar_string("amx_mysql_user",muser,32) 
  get_cvar_string("amx_mysql_pass",mpass,32) 
  get_cvar_string("amx_mysql_db",mdb,32) 

  mysql=mysql_connect(mhost,muser,mpass,mdb,merror,32) 
  
  if(mysql < 1){
    server_print("[AMX] MyStatus error : could not connect :: init_function failed")
  }
  else{  
    reset_scores()
    update_server_info()  
  }
}

// Short Functions
public short_functions(){

  new server_id = get_cvar_num("amx_server_id")

  get_cvar_string("amx_mysql_host",mhost,64) 
  get_cvar_string("amx_mysql_user",muser,32) 
  get_cvar_string("amx_mysql_pass",mpass,32) 
  get_cvar_string("amx_mysql_db",mdb,32) 

  new timeleft = get_timeleft()
  
  mysql=mysql_connect(mhost,muser,mpass,mdb,merror,32) 
  
  if(mysql < 1){
    server_print("[AMX] MyStatus error :: could not connect :: short_function() failed")
  }
  else{    
    new query[256]
    format(query,256,"Update amx_mystatus_server_info set timeleft='%d' where server_id='%d'",timeleft,server_id)
    mysql_query(mysql,query)
  
    update_player_info()
  
    mysql_close(mysql)
    mysql=0
  }
  
  return PLUGIN_CONTINUE
}

// Get Team Score
//
public team_score(){  

  new server_id = get_cvar_num("amx_server_id")
  
  get_cvar_string("amx_mysql_host",mhost,64) 
  get_cvar_string("amx_mysql_user",muser,32) 
  get_cvar_string("amx_mysql_pass",mpass,32) 
  get_cvar_string("amx_mysql_db",mdb,32) 
	
  new ct_score = 0 
  new terrorist_score = 0 
  new team[32] 
  read_data(1,team,32)

  mysql=mysql_connect(mhost,muser,mpass,mdb,merror,32) 
  
  if(mysql < 1){
    server_print("[AMX] MyStatus error :: could not connect :: team_score() failed")
  }
  else{
    if (equal(team,"CT")){ 
      ct_score = read_data(2)

      new query[256]
      format(query,256,"Update amx_mystatus_server_info set ct_score='%d' where server_id='%d'",ct_score,server_id)
      mysql_query(mysql,query)
    } 
    else if (equal(team,"TERRORIST")){ 
      terrorist_score = read_data(2)

      new query[256]
      format(query,256,"Update amx_mystatus_server_info set terrorist_score='%d' where server_id='%d'",terrorist_score,server_id)
      mysql_query(mysql,query)
    }
    mysql_close(mysql)
    mysql=0
  }  
  return PLUGIN_CONTINUE 
}

public plugin_init(){
  register_plugin("AMX MyStatus","0.3","SDE")
  register_cvar("amx_server_id","1")
  register_cvar("amx_mystatus_freq","15")
  register_cvar("amx_mysql_host","127.0.0.1")
  register_cvar("amx_mysql_user","root")
  register_cvar("amx_mysql_pass","1111")
  register_cvar("amx_mysql_db","amx")   
  init_functions()
  
  new Float:freq = get_cvar_float("amx_mystatus_freq")
  set_task(freq,"short_functions",0,"",0,"b")
  register_event("TeamScore", "team_score", "a")
  return PLUGIN_CONTINUE
}

содержание mystatus.sma (после компиляции mystatus.amx )

Offline

#5  19.12.06 19:12

Re: Связь server Conter-strike 1.6MySQL->сайт

Извени конечно но в MySQL я не селен обьяснити что именно и что должно быть.

Offline

#6  19.12.06 19:13

Re: Связь server Conter-strike 1.6MySQL->сайт

Я просто токо начинаю работать с MySQL и сразу проблемы начались :(

Offline

#7  19.12.06 19:28

Re: Связь server Conter-strike 1.6MySQL->сайт

читай ман к стате

Offline

#8  20.12.06 19:31

Re: Связь server Conter-strike 1.6MySQL->сайт

чего чего ?

Offline

#9  20.12.06 19:39

Re: Связь server Conter-strike 1.6MySQL->сайт

"читай ман к стате", если перевести на русский язык, значит "убей себя головой об стол".

читай файлы, названия которых напоминают readme, manual, help и т.д.

Offline

#10  21.12.06 16:04

Maq
Профиль

Re: Связь server Conter-strike 1.6MySQL->сайт

глянь число игроков в MyPHPAdmin (или любом другом администраторе MySQL-а)
число игроков - число записей в таблице amx_mystatus_player_info
если и там один, то проблема в моде, если там больше одого, то проблема в сайте:))

Offline

#11  21.12.06 18:45

Re: Связь server Conter-strike 1.6MySQL->сайт

скорее всего проблема в сайте...

new maxplayers
maxplayers = get_maxplayers()

тут все правильно получает и обновляет БД
код на ПХП давай смотреть

Offline

#12  21.12.06 19:51

Re: Связь server Conter-strike 1.6MySQL->сайт

Я через phpMyadmin сматрел там 1 игрок показавается.

Исправлено server_cs (21.12.06 19:52)

Offline

#13  22.12.06 10:47

Re: Связь server Conter-strike 1.6MySQL->сайт

ты давай код на ПХП
то, что у тебя заносится maxplayers=1, похоже на косяк... какой у тебя AMX? или AMXX? плагин ты компилировал под свой дистр или положил уже готовый amx-файл?

в любом случае, число игроков не должно зависить от максимального числа, т.к. на каждого игрока делается запись в БД...

Offline

#14  23.12.06 02:49

Re: Связь server Conter-strike 1.6MySQL->сайт

Компилировал сам так как готовый не под мою базу ( pass, root не подходят ) сам все сделал пароль и пользователя.

Offline

#15  23.12.06 02:52

Re: Связь server Conter-strike 1.6MySQL->сайт

define_tpl.php

Код::

<?
// ** do not edit :: see config.php **
/*****************************************************
*
*  AMX MyStatus Template Definitions
*  (c)2002 Michael Milano
*          aka SDE <sde@ocsclan.com>
*          http://mystatus.ocsclan.com
*
******************************************************/

$tpl->define(array("main" => $path_to_templates . "main.tpl",
		   "cvar_table" => $path_to_templates . "cvar_table.tpl",
		   "player_table" => $path_to_templates . "player_table.tpl",
		   "server_table" => $path_to_templates . "server_table.tpl"));

// setup map filenames		   
if(file_exists($path_to_map_images . $status->map . ".jpg"))
{
  $tpl->assign("map_image","$status->map.jpg");
}
else
{
  $tpl->assign("map_image","na.jpg");
}

if(file_exists($path_to_map_images . $status->nextmap . ".jpg"))
{
  $tpl->assign("nextmap_image","$status->nextmap.jpg");
}
else
{
  $tpl->assign("nextmap_image","na.jpg");
}

$tpl->assign("TITLE","AMX MyStatus");
$tpl->assign("path_to_map_images","$path_to_map_images");
$tpl->assign("hostname","$status->hostname");
$tpl->assign("hostport","$status->hostport");
$tpl->assign("map","$status->map");
$tpl->assign("maxplayers","$status->");
$tpl->assign("mp_autokick","$stamaxplayers");
$tpl->assign("modname","$status->modnametus->mp_autokick");
$tpl->assign("mp_autoteambalance","$status->mp_autoteambalance");
$tpl->assign("mp_c4timer","$status->mp_c4timer");
$tpl->assign("mp_flashlight","$status->mp_flashlight");
$tpl->assign("mp_footsteps","$status->mp_footsteps");
$tpl->assign("mp_forcechasecam","$status->mp_forcechasecam");
$tpl->assign("mp_freezetime","$status->mp_freezetime");
$tpl->assign("mp_friendlyfire","$status->mp_friendlyfire");
$tpl->assign("mp_hostagepenalty","$status->mp_hostagepenalty");
$tpl->assign("mp_limitteams","$status->mp_limitteams");
$tpl->assign("mp_logmessages","$status->mp_logmessages");
$tpl->assign("mp_mapvoteratio","$status->mp_mapvoteratio");
$tpl->assign("mp_roundtime","$status->mp_roundtime");
$tpl->assign("mp_timelimit","$status->mp_timelimit");
$tpl->assign("mp_startmoney","$status->mp_startmoney");
$tpl->assign("mp_tkpunish","$status->mp_tkpunish");
$tpl->assign("net_address","$status->net_address");
$tpl->assign("nextmap","$status->nextmap");
$tpl->assign("timeleft","$status->timeleft");
$tpl->assign("ct_score","$status->ct_score");
$tpl->assign("terrorist_score","$status->terrorist_score");
$tpl->assign("total_cts","$status->total_cts");
$tpl->assign("total_ts","$status->total_ts");
$tpl->assign("total_players","$status->total_players");

$cts_display = $status->print_cts();
$tpl->assign("cts_display","$cts_display");

$ts_display = $status->print_ts();
$tpl->assign("ts_display","$ts_display");

$tpl->assign("CSS","$status->css");

$tpl->parse("CVAR_TABLE","cvar_table");
$tpl->parse("PLAYER_TABLE","player_table");
$tpl->parse("SERVER_TABLE","server_table");
$tpl->parse("MAIN", "main");
?>

Offline

#16  23.12.06 02:55

Re: Связь server Conter-strike 1.6MySQL->сайт

class.FastTemplate.php

Код::

<?

/*
	CVS Revision. 1.1.0
*/

class FastTemplate {

	var $FILELIST	=	array();	//	Holds the array of filehandles
						//	FILELIST[HANDLE] == "fileName"

	var $DYNAMIC	=	array();	//	Holds the array of dynamic
						//	blocks, and the fileHandles they
						//	live in.

	var $PARSEVARS	=	array();	//	Holds the array of Variable
						//	handles.
						//	PARSEVARS[HANDLE] == "value"

	var $LOADED	=	array();	//	We only want to load a template
						//	once - when it's used.
						//	LOADED[FILEHANDLE] == 1 if loaded
						//	undefined if not loaded yet.

	var $HANDLE	=	array();	//	Holds the handle names assigned
						//	by a call to parse()

	var $ROOT	=	"";		//	Holds path-to-templates

	var $WIN32	=	true;		//	Set to true if this is a WIN32 server

	var $ERROR	=	"";		//	Holds the last error message

	var $LAST	=	"";		//	Holds the HANDLE to the last
						//	template parsed by parse()

	var $STRICT	=	true;		//	Strict template checking.
						//	Unresolved vars in templates will
						//	generate a warning when found.

//	************************************************************

	function FastTemplate ($pathToTemplates = "")
	{
		global $php_errormsg;

		if(!empty($pathToTemplates))
		{
			$this->set_root($pathToTemplates);
		}

	}	// end (new) FastTemplate ()


//	************************************************************
//	All templates will be loaded from this "root" directory
//	Can be changed in mid-process by re-calling with a new
//	value.

	function set_root ($root)
	{
		$trailer = substr($root,-1);

		if(!$this->WIN32)
		{
			if( (ord($trailer)) != 47 )
			{
				$root = "$root". chr(47);
			}

			if(is_dir($root))
			{
				$this->ROOT = $root;
			}
			else
			{
				$this->ROOT = "";
				$this->error("Specified ROOT dir [$root] is not a directory");
			}
		}
		else
		{
			// WIN32 box - no testing
			if( (ord($trailer)) != 92 )
			{
				$root = "$root" . chr(92);
			}
			$this->ROOT = $root;
		}

	}	// End set_root()


//  **************************************************************
//  Calculates current microtime
//	I throw this into all my classes for benchmarking purposes
//	It's not used by anything in this class and can be removed
//	if you don't need it.


	function utime ()
	{
		$time = explode( " ", microtime());
		$usec = (double)$time[0];
		$sec = (double)$time[1];
		return $sec + $usec;
    }

//  **************************************************************
//	Strict template checking, if true sends warnings to STDOUT when
//	parsing a template with undefined variable references
//	Used for tracking down bugs-n-such. Use no_strict() to disable.

	function strict ()
	{
		$this->STRICT = true;
	}

//	************************************************************
//	Silently discards (removes) undefined variable references
//	found in templates

	function no_strict ()
	{
		$this->STRICT = false;
	}

//	************************************************************
//	A quick check of the template file before reading it.
//	This is -not- a reliable check, mostly due to inconsistencies
//	in the way PHP determines if a file is readable.

	function is_safe ($filename)
	{
		if(!file_exists($filename))
		{
			$this->error("[$filename] does not exist",0);
			return false;
		}
		return true;
	}

//	************************************************************
//	Grabs a template from the root dir and 
//	reads it into a (potentially REALLY) big string

	function get_template ($template)
	{
		if(empty($this->ROOT))
		{
			$this->error("Cannot open template. Root not valid.",1);
			return false;
		}

		$filename	=	"$this->ROOT"."$template";

		$contents = implode("",(@file($filename)));
		if( (!$contents) or (empty($contents)) )
		{
			$this->error("get_template() failure: [$filename] $php_errormsg",1);
		}

		return $contents;

	} // end get_template

//	************************************************************
//	Prints the warnings for unresolved variable references
//	in template files. Used if STRICT is true

	function show_unknowns ($Line)
	{
		$unknown = array();
		
		// BUG : modify
		//if (ereg("({[A-Z0-9_]+})",$Line,$unknown))
		if (ereg("(\{[A-Z0-9_]+\})",$Line,$unknown))
		{
			$UnkVar = $unknown[1];
			if(!(empty($UnkVar)))
			{
				@error_log("[FastTemplate] Warning: no value found for variable: $UnkVar ",0);
			}
		}
	}	// end show_unknowns()

//	************************************************************
//	This routine get's called by parse() and does the actual
//	{VAR} to VALUE conversion within the template.

	function parse_template ($template, $tpl_array)
	{
		while ( list ($key,$val) = each ($tpl_array) )
		{
			if (!(empty($key)))
			{
				if(gettype($val) != "string")
				{
					settype($val,"string");
				}

// Pour PHP 3
//$template = ereg_replace("{$key}","$val","$template");
//$template = str_replace("{$key}","$val","$template");


// Pour PHP 4
$key = '{'."$key}";
$template = str_replace("$key","$val","$template");

			}
		}

// BUG : sur les regex 

		if(!$this->STRICT)
		  {
		    // Silently remove anything not already found
		    
		    // BUG : modify
		    //$template = ereg_replace("{([A-Z0-9_]+)}","",$template);
		    $template = ereg_replace("\{([A-Z0-9_]+)\}","",$template);
		}
		else
		{
		  // Warn about unresolved template variables
		  
		  // BUG : modify
		  //if (ereg("({[A-Z0-9_]+})", $template))
		  if (ereg("(\{[A-Z0-9_]+\})", $template))
		    {
		      $unknown = split("\n",$template);
		      while (list ($Element,$Line) = each($unknown) )
			{
			  $UnkVar = $Line;
			  if(!(empty($UnkVar)))
			    {
			      $this->show_unknowns($UnkVar);
			    }
			}
		    }
		}
		









		return $template;

	}	// end parse_template();

//	************************************************************
//	The meat of the whole class. The magic happens here.

	function parse ( $ReturnVar, $FileTags )
	{
		$append = false;
		$this->LAST = $ReturnVar;
		$this->HANDLE[$ReturnVar] = 1;

		if (gettype($FileTags) == "array")
		{
			unset($this->$ReturnVar);	// Clear any previous data

			while ( list ( $key , $val ) = each ( $FileTags ) )
			{
				if ( (!isset($this->$val)) || (empty($this->$val)) )
				{
					$this->LOADED["$val"] = 1;
					if(isset($this->DYNAMIC["$val"]))
					{
						$this->parse_dynamic($val,$ReturnVar);
					}
					else
					{
						$fileName = $this->FILELIST["$val"];
						$this->$val = $this->get_template($fileName);
					}
				}

				//	Array context implies overwrite

				$this->$ReturnVar = $this->parse_template($this->$val,$this->PARSEVARS);

				//	For recursive calls.

				$this->assign( array( $ReturnVar => $this->$ReturnVar ) );

			}
		}	// end if FileTags is array()
		else
		{
			// FileTags is not an array

			$val = $FileTags;

			if( (substr($val,0,1)) == '.' )
			{
				// Append this template to a previous ReturnVar

				$append = true;
				$val = substr($val,1);
			}

			if ( (!isset($this->$val)) || (empty($this->$val)) )
			{
					$this->LOADED["$val"] = 1;
					if(isset($this->DYNAMIC["$val"]))
					{
						$this->parse_dynamic($val,$ReturnVar);
					}
					else
					{
						$fileName = $this->FILELIST["$val"];
						$this->$val = $this->get_template($fileName);
					}
			}

			if($append)
			{
				$this->$ReturnVar .= $this->parse_template($this->$val,$this->PARSEVARS);
			}
			else
			{
				$this->$ReturnVar = $this->parse_template($this->$val,$this->PARSEVARS);
			}

			//	For recursive calls.

			$this->assign(array( $ReturnVar => $this->$ReturnVar) );

		}
		return;
	}	//	End parse()


//	************************************************************

	function FastPrint ( $template = "" )
	{
		if(empty($template))
		{
			$template = $this->LAST;
		}

		if( (!(isset($this->$template))) || (empty($this->$template)) )
		{
			$this->error("Nothing parsed, nothing printed",0);
			return;
		}
		else
		{
			print $this->$template;
		}
		return;
	}

//	************************************************************

	function fetch ( $template = "" )
	{
		if(empty($template))
		{
			$template = $this->LAST;
		}
		if( (!(isset($this->$template))) || (empty($this->$template)) )
		{
			$this->error("Nothing parsed, nothing printed",0);
			return "";
		}

		return($this->$template);
	}


//	************************************************************

	function define_dynamic ($Macro, $ParentName)
	{
		//	A dynamic block lives inside another template file.
		//	It will be stripped from the template when parsed
		//	and replaced with the {$Tag}.

		$this->DYNAMIC["$Macro"] = $ParentName;
		return true;
	}

//	************************************************************

	function parse_dynamic ($Macro,$MacroName)
	{
		// The file must already be in memory.

		$ParentTag = $this->DYNAMIC["$Macro"];
		if( (!$this->$ParentTag) or (empty($this->$ParentTag)) )
		{
			$fileName = $this->FILELIST[$ParentTag];
			$this->$ParentTag = $this->get_template($fileName);
			$this->LOADED[$ParentTag] = 1;
		}
		if($this->$ParentTag)
		{
			$template = $this->$ParentTag;
			$DataArray = split("\n",$template);
			$newMacro = "";
			$newParent = "";
			$outside = true;
			$start = false;
			$end = false;
			while ( list ($lineNum,$lineData) = each ($DataArray) )
			{
				$lineTest = trim($lineData);
				if("<!-- BEGIN DYNAMIC BLOCK: $Macro -->" == "$lineTest" )
				{
					$start = true;
					$end = false;
					$outside = false;
				}
				if("<!-- END DYNAMIC BLOCK: $Macro -->" == "$lineTest" )
				{
					$start = false;
					$end = true;
					$outside = true;
				}
				if( (!$outside) and (!$start) and (!$end) )
				{
					$newMacro .= "$lineData\n"; // Restore linebreaks
				}
				if( ($outside) and (!$start) and (!$end) )
				{
					$newParent .= "$lineData\n"; // Restore linebreaks
				}
				if($end)
				{
// Pour PHP 3					
// $newParent .= "{$MacroName}\n";

// Pour PHP 4
$newParent .= '{'."$MacroName}\n";

				}
				// Next line please
				if($end) { $end = false; }
				if($start) { $start = false; }
			}	// end While

			$this->$Macro = $newMacro;
			$this->$ParentTag = $newParent;
			return true;

		}	// $ParentTag NOT loaded - MAJOR oopsie
		else
		{
			@error_log("ParentTag: [$ParentTag] not loaded!",0);
			$this->error("ParentTag: [$ParentTag] not loaded!",0);
		}
		return false;
	}

//	************************************************************
//	Strips a DYNAMIC BLOCK from a template.

	function clear_dynamic ($Macro="")
	{
		if(empty($Macro)) { return false; }

		// The file must already be in memory.

		$ParentTag = $this->DYNAMIC["$Macro"];

		if( (!$this->$ParentTag) or (empty($this->$ParentTag)) )
		{
			$fileName = $this->FILELIST[$ParentTag];
			$this->$ParentTag = $this->get_template($fileName);
			$this->LOADED[$ParentTag] = 1;
		}

		if($this->$ParentTag)
		{
			$template = $this->$ParentTag;
			$DataArray = split("\n",$template);
			$newParent = "";
			$outside = true;
			$start = false;
			$end = false;
			while ( list ($lineNum,$lineData) = each ($DataArray) )
			{
				$lineTest = trim($lineData);
				if("<!-- BEGIN DYNAMIC BLOCK: $Macro -->" == "$lineTest" )
				{
					$start = true;
					$end = false;
					$outside = false;
				}
				if("<!-- END DYNAMIC BLOCK: $Macro -->" == "$lineTest" )
				{
					$start = false;
					$end = true;
					$outside = true;
				}
				if( ($outside) and (!$start) and (!$end) )
				{
					$newParent .= "$lineData\n"; // Restore linebreaks
				}
				// Next line please
				if($end) { $end = false; }
				if($start) { $start = false; }
			}	// end While

			$this->$ParentTag = $newParent;
			return true;

		}	// $ParentTag NOT loaded - MAJOR oopsie
		else
		{
			@error_log("ParentTag: [$ParentTag] not loaded!",0);
			$this->error("ParentTag: [$ParentTag] not loaded!",0);
		}
		return false;
	}


//	************************************************************

	function define ($fileList)
	{
		while ( list ($FileTag,$FileName) = each ($fileList) )
		{
			$this->FILELIST["$FileTag"] = $FileName;
		}
		return true;
	}

//	************************************************************

	function clear_parse ( $ReturnVar = "")
	{
		$this->clear($ReturnVar);
	}

//	************************************************************

	function clear ( $ReturnVar = "" )
	{
		// Clears out hash created by call to parse()

		if(!empty($ReturnVar))
		{
			if( (gettype($ReturnVar)) != "array")
			{
				unset($this->$ReturnVar);
				return;
			}
			else
			{
				while ( list ($key,$val) = each ($ReturnVar) )
				{
					unset($this->$val);
				}
				return;
			}
		}

		// Empty - clear all of them

		while ( list ( $key,$val) = each ($this->HANDLE) )
		{
			$KEY = $key;
			unset($this->$KEY);
		}
		return;

	}	//	end clear()

//	************************************************************

	function clear_all ()
	{
		$this->clear();
		$this->clear_assign();
		$this->clear_define();
		$this->clear_tpl();

		return;

	}	//	end clear_all

//	************************************************************

	function clear_tpl ($fileHandle = "")
	{
		if(empty($this->LOADED))
		{
			// Nothing loaded, nothing to clear

			return true;
		}
		if(empty($fileHandle))
		{
			// Clear ALL fileHandles

			while ( list ($key, $val) = each ($this->LOADED) )
			{
				unset($this->$key);
			}
			unset($this->LOADED);

			return true;
		}
		else
		{
			if( (gettype($fileHandle)) != "array")
			{
				if( (isset($this->$fileHandle)) || (!empty($this->$fileHandle)) )
				{
					unset($this->LOADED[$fileHandle]);
					unset($this->$fileHandle);
					return true;
				}
			}
			else
			{
				while ( list ($Key, $Val) = each ($fileHandle) )
				{
					unset($this->LOADED[$Key]);
					unset($this->$Key);
				}
				return true;
			}
		}

		return false;

	}	// end clear_tpl

//	************************************************************

	function clear_define ( $FileTag = "" )
	{
		if(empty($FileTag))
		{
			unset($this->FILELIST);
			return;
		}

		if( (gettype($Files)) != "array")
		{
			unset($this->FILELIST[$FileTag]);
			return;
		}
		else
		{
			while ( list ( $Tag, $Val) = each ($FileTag) )
			{
				unset($this->FILELIST[$Tag]);
			}
			return;
		}
	}

//	************************************************************
//
/*	Aliased function - used for compatibility with CGI::FastTemplate
	function clear_parse ()
	{
		$this->clear_assign();
	}
*/
//	************************************************************
//	Clears all variables set by assign()

	function clear_assign ()
	{
		if(!(empty($this->PARSEVARS)))
		{
			while(list($Ref,$Val) = each ($this->PARSEVARS) )
			{
				unset($this->PARSEVARS["$Ref"]);
			}
		}
	}

//	************************************************************

	function clear_href ($href)
	{
		if(!empty($href))
		{
			if( (gettype($href)) != "array")
			{
				unset($this->PARSEVARS[$href]);
				return;
			}
			else
			{
				while (list ($Ref,$val) = each ($href) )
				{
					unset($this->PARSEVARS[$Ref]);
				}
				return;
			}
		}
		else
		{
			// Empty - clear them all

			$this->clear_assign();
		}
		return;
	}

//	************************************************************

	function assign ($tpl_array, $trailer="")
	{
		if(gettype($tpl_array) == "array")
		{
			while ( list ($key,$val) = each ($tpl_array) )
			{
				if (!(empty($key)))
				{
					//	Empty values are allowed
					//	Empty Keys are NOT

					$this->PARSEVARS["$key"] = $val;
				}
			}
		}
		else
		{
			// Empty values are allowed in non-array context now.
			if (!empty($tpl_array))
			{
				$this->PARSEVARS["$tpl_array"] = $trailer;
			}
		}
	}

//	************************************************************
//	Return the value of an assigned variable.
//	Christian Brandel cbrandel@gmx.de

	function get_assigned($tpl_name = "")
	{
		if(empty($tpl_name)) { return false; }
		if(isset($this->PARSEVARS["$tpl_name"]))
		{
			return ($this->PARSEVARS["$tpl_name"]);
		}
		else
		{
			return false;
        }
	}

//	************************************************************

	function error ($errorMsg, $die = 0)
	{
		$this->ERROR = $errorMsg;
		echo "ERROR: $this->ERROR <BR> \n";
		if ($die == 1)
		{
			exit;
		}

		return;

	} // end error()


//	************************************************************



//	************************************************************

} // End class.FastTemplate.php

?>

Offline

#17  23.12.06 14:28

Re: Связь server Conter-strike 1.6MySQL->сайт

server_cs написал(а):

Компилировал сам так как готовый не под мою базу ( pass, root не подходят ) сам все сделал пароль и пользователя.

Бгогого.

Нафик ты последние файлы выложил? Как они влияют интересно на отображения числа игроков?

Offline

#18  23.12.06 16:30

Re: Связь server Conter-strike 1.6MySQL->сайт

не найти помощи тебе здесь.
лень враг твой.
маны читать следует тебе.
иначе ответа не найдешь ты на вопрос свой.

Offline

Программирование и БД » Связь server Conter-strike 1.6MySQL->сайт 

ФутЕр:)

© Hostel Web Group, 2002-2025.   Сообщить об ошибке

Сгенерировано за 0.064 сек.
Выполнено 14 запросов.