Location: PHPKode > projects > Warp.cms - php/mysql content management > warp_121/ax_main.php
<?php

// [warp administration module - MyISAM-MySQL ADMIN v.1.2.1]
// xantis.warp.cms - version 1.2
// (c) 2002 xantis - all rights reserved
// this code is registered and protected by international copyrights laws


//####### Register Globals !

extract($HTTP_ENV_VARS);
extract($HTTP_GET_VARS);
extract($HTTP_POST_VARS);
extract($HTTP_COOKIE_VARS);
extract($HTTP_SERVER_VARS);

//#########################

$xnt_control_var = 'xnt2002warp.cms';

require("lib_adv.php");


if (empty($op)) {
	$op = 'intro';
} //end if

//$qval = rawurldecode($qval);
$q_url = rawurlencode(stripslashes($qval));
$qval = stripslashes($qval);


//---------------------------------------------------------page header
if (!empty($d)) {
	$ax_hlx_btlx_title = '`'.$d.'`';
} //end if
else {
	$ax_hlx_btlx_title = '[Tables List]';
} //end else
xheader (':: warp.cms.admin .:. '.$ax_hlx_btlx_title.' ::', 'admin');
//---------------------------------------------------------



//################################################# TABLE MENU BAR


function xshow_title () {

//-----------------globals general
global	$arr_var_result, $arr_var_fields, $var_result_size, $xmy_wr_ok_msg, $xmy_wr_aff_msg, $warp_numform_decimal_sep, $warp_numform_thousand_sep ;
global	$dbname ;

//-----------------ax lib globals
global	$ax_website_addr, $ax_picts_dir, $ax_txt_lnk_color, $ax_bg_color, $ax_th_color, $ax_td_color, $ax_td_color_alt, $ax_tx_color,
$ax_tx_color_err, $ax_tx_color_sp, $ax_tx_color_qe ;

//---------------- internal
global	$d, $op, $xid, $offset, $qval, $q_url;

//---------------- auth
global	$PHP_AUTH_USER, $PHP_AUTH_PW ;



	//THE MAIN BAR
	//-------------------------------------------------
	xnewline();
	xhr_line ('100%');
	xcenter_start();

	xtable_start ('100%');
		xtable_row_start ();
			xtable_column_start_vcenter ('1', '', "$ax_bg_color");
				xtext_title_admin (xhtml_text ('::warp.cms.admin::', 'n', 'l'));
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_bg_color");
				xcenter_right_start();
					xpict_link ("$ax_website_addr"."$ax_picts_dir".'/db_tables.gif', 'Tables List - Database'.' ['."$dbname".']', '30', '30', "$ax_website_addr"."ax_main.php"."?op=intro", '_self');
					xspace();
					xpict_link ("$ax_website_addr"."$ax_picts_dir".'/db_querry.gif', 'Free Query On Database'.' ['."$dbname".']', '30', '30', "$ax_website_addr"."ax_main.php"."?d=$d&op=free&offset=$offset&qval=$q_url", '_self');
					xspace();
					if (!empty($d)) {
						xpict ("$ax_website_addr"."$ax_picts_dir".'/hxliner.gif', '1', '30');
						xspace();
						xpict_link ("$ax_website_addr"."$ax_picts_dir".'/db_status.gif', 'Table Maintaining'.' ['."$d".']', '30', '30', "$ax_website_addr"."ax_main.php"."?d=$d&op=status&offset=$offset&qval=$q_url", '_self');
						xspace();
						xpict_link ("$ax_website_addr"."$ax_picts_dir".'/db_list.gif', 'Table Data'.' ['."$d".']', '30', '30', "$ax_website_addr"."ax_main.php"."?d=$d&op=list&offset=$offset&qval=$q_url", '_self');
						xspace();
					} //end if
					else {
						xpict ("$ax_website_addr"."$ax_picts_dir".'/hxliner.gif', '1', '30');
						xspace();
						xpict_link ("$ax_website_addr"."$ax_picts_dir".'/db_save.gif', 'Backup Database'.' ['."$dbname".']', '30', '30', "$ax_website_addr"."ax_main.php"."?d=$d&op=backup&offset=$offset&qval=$q_url", '_self');
						xspace();
						xpict_link ("$ax_website_addr"."$ax_picts_dir".'/db_restore.gif', 'Restore Database'.' ['."$dbname".']', '30', '30', "$ax_website_addr"."ax_main.php"."?d=$d&op=restore&offset=$offset&qval=$q_url", '_self');
						xspace();
					} //end else
					xpict ("$ax_website_addr"."$ax_picts_dir".'/hxliner.gif', '1', '30');
					xspace();
					xpict_link ("$ax_website_addr"."$ax_picts_dir".'/contact_app.gif', 'Warp Contact Messenger', '30', '30', "$ax_website_addr"."ax_cxapp.php", '_blank');
					xspace();
					xpict_link ("$ax_website_addr"."$ax_picts_dir".'/file_manager.gif', 'Warp File Explorer', '30', '30', "$ax_website_addr"."ax_fm.php", '_blank');
					xspace();
					xpict_link ("$ax_website_addr"."$ax_picts_dir".'/html_edt.gif', 'Warp HTML Editor', '30', '30', "$ax_website_addr"."ax_htmled.php", '_blank');
					xspace();
					xpict ("$ax_website_addr"."$ax_picts_dir".'/hxliner.gif', '1', '30');
					xspace();
					xpict_link ("$ax_website_addr"."$ax_picts_dir".'/help.gif', 'Warp Documentation', '30', '30', "$ax_website_addr"."ax_help.php", '_blank');
				xcenter_end();
			xtable_column_end ();
		xtable_row_end ();
	xtable_end();

	xhr_line ('100%');

	if (stristr(rawurlencode(rawurldecode($d)), '%20')) {
		xtext_admin_error ('<br>&nbsp;&nbsp;&nbsp;ERROR : Invalid space character in table name `'.$d.'` !') ;
		die('');
	} //end if

	if ( ($op != 'help') AND ($op != 'intro') AND ($op != 'answer') AND ($op != 'free') AND ($op != 'freex') AND ($op != 'backup') AND ($op != 'restore') AND ($op != 'restorex') ) {
		$result = @mysql_query (" SHOW COLUMNS FROM $d LIKE 'id' ");

		if ( (@mysql_errno() == 0) AND (@mysql_num_rows($result) > 0) ) {
			xtable_start ('100%');
				xtable_row_start ();
					xtable_column_start_vcenter ('1', '', "$ax_bg_color");
						xtext_admin ('<b>'.xhtml_text ('Database in use : `'.$dbname.'` / Table in use : `'.$d.'` - [ '.date("Y-m-d").' '.date("H:i:s").' ]', 'n', 'c').'</b>');
					xtable_column_end ();
				xtable_row_end ();
			xtable_end();
		} //end if
		else {
			if (empty($d)) {
				xtext_admin_error ('<br>&nbsp;&nbsp;&nbsp;ERROR : No table selected !') ;
			} //end if
			else if (@mysql_num_rows($result) <= 0) {
				xtext_admin_error ('<br>&nbsp;&nbsp;&nbsp;ERROR : Cannot select ID field from table `'.$d.'` !') ;
			} //end else if
			else {
				xtext_admin_error ('<br>&nbsp;&nbsp;&nbsp;ERROR : Cannot select table `'.$d.'` !') ;
			} //end else
			die('');
		} //end else
		@mysql_free_result ($result);
	} //end if
	else {
		xtable_start ('100%');
			xtable_row_start ();
				xtable_column_start_vcenter ('1', '', "$ax_bg_color");
					xtext_admin ('<b>'.xhtml_text ('Database in use : `'.$dbname.'` - [ '.date("Y-m-d").' '.date("H:i:s").' ]', 'n', 'c').'</b>');
				xtable_column_end ();
			xtable_row_end ();
		xtable_end();
	} //end else



	xcenter_end();
	xhr_line ('100%');
	//-------------------------------------------------


} //END FUNCTION


//################################################# LIST TABLES

function xshow_list_tables () {

//-----------------globals general
global	$arr_var_result, $arr_var_fields, $var_result_size, $xmy_wr_ok_msg, $xmy_wr_aff_msg, $warp_numform_decimal_sep, $warp_numform_thousand_sep ;
global	$dbname ;

//-----------------ax lib globals
global	$ax_website_addr, $ax_picts_dir, $ax_txt_lnk_color, $ax_bg_color, $ax_th_color, $ax_td_color, $ax_td_color_alt, $ax_tx_color,
$ax_tx_color_err, $ax_tx_color_sp, $ax_tx_color_qe ;

//---------------- internal
global	$d, $op, $xid, $offset, $qval, $q_url;

//---------------- auth
global	$PHP_AUTH_USER, $PHP_AUTH_PW ;


	xmysql_read_data_ax (" SELECT tbl_name, sect_own, tbl_descr, tbl_hint, special FROM warp_tables_defs ORDER BY id ASC, tbl_id ASC ");
	$arr_tbl_lst_wrp = array();
	$arr_tbl_lst_wrp = $arr_var_result;
	$arr_var_result = array();


	xtable_start_brd('900');

		xtable_row_start ();
			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xtext_admin ('<b>'.xhtml_text ('#', 'n', 'c').'</b>');
			xtable_column_end ();

			xtable_column_start_vcenter ('2', '', "$ax_tx_color");
				xtext_admin ('<b>'.xhtml_text ('Table_Name', 'n', 'c').'</b>');
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xtext_admin ('<b>'.xhtml_text ('Warp_Section', 'n', 'c').'</b>');
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xtext_admin ('<b>'.xhtml_text ('Records_No.', 'n', 'c').'</b>');
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xtext_admin ('<b>'.xhtml_text ('Last_Update', 'n', 'c').'</b>');
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xtext_admin ('<b>'.xhtml_text ('Table_Description', 'n', 'c').'</b>');
			xtable_column_end ();
		xtable_row_end ();


		$axl_i_alt = 0;
		for ($i=0; $i<count($arr_tbl_lst_wrp); $i++) {

			$i_tbl_nam = $i;
			$i_sect = $i + 1;
			$i_descr = $i + 2;
			$i_hint = $i + 3;
			$i_sp = $i + 4;
			$i = $i + 4;

			$axl_i_alt = $axl_i_alt + 1;
			//------------------
			//alternate
			if( $axl_i_alt % 2 ) {
				$axl_altx_color = $ax_td_color;
			} //end if
			else {
				$axl_altx_color = $ax_td_color_alt;
			} //end else
			//------------------

			//get info
			xmysql_read_data_ax (" SHOW TABLE STATUS LIKE '$arr_tbl_lst_wrp[$i_tbl_nam]' ");
			//$arr_var_result

			xtable_row_start ();
				xtable_column_start_vcenter ('1', '', "$axl_altx_color");
					xcenter_right_start();
					xtext_admin ($axl_i_alt.'.');
					xcenter_end();
				xtable_column_end ();

				xtable_column_start_vcenter ('1', '', "$axl_altx_color");
					xcenter_right_start();
						xpict_link ("$ax_website_addr"."$ax_picts_dir".'/warp_cp.gif', 'Select Table'.' ['."$arr_tbl_lst_wrp[$i_tbl_nam]".']', '30', '30', "$ax_website_addr"."ax_main.php"."?d=$arr_tbl_lst_wrp[$i_tbl_nam]&op=status&offset=0&qval=", '_self');
					xcenter_end();
				xtable_column_end ();

				xtable_column_start_vcenter ('1', '', "$axl_altx_color");
					if ($arr_tbl_lst_wrp[$i_sp] == 'y') {
						xtext_admin ('<font color="'.$ax_tx_color_sp.'">&nbsp;'.$arr_tbl_lst_wrp[$i_tbl_nam].'&nbsp;</font>');
					} //end if
					else {
						xtext_admin ('<font color="'.$ax_tx_color_qe.'">&nbsp;'.$arr_tbl_lst_wrp[$i_tbl_nam].'&nbsp;</font>');
					} //end else
				xtable_column_end ();

				xtable_column_start_vcenter ('1', '', "$axl_altx_color");
					xtext_admin (xhtml_text ($arr_tbl_lst_wrp[$i_sect], 'n', 'c'));
				xtable_column_end ();

				xtable_column_start_vcenter ('1', '', "$axl_altx_color");
					xcenter_start();

					xtext_admin (number_format($arr_var_result[3], 0, $warp_numform_decimal_sep, $warp_numform_thousand_sep));
					xcenter_end();
				xtable_column_end ();

				xtable_column_start_vcenter ('1', '', "$axl_altx_color");
					xcenter_start();
					xtext_admin ($arr_var_result[11]);
					xcenter_end();
				xtable_column_end ();

				xtable_column_start_vcenter ('1', '', "$axl_altx_color");
					xtext_admin (xhtml_text ('['.$arr_tbl_lst_wrp[$i_descr].'] : '.$arr_tbl_lst_wrp[$i_hint], 'n', 'l'));
				xtable_column_end ();
			xtable_row_end ();

		} //end for

	xtable_end();



} //END FUNCTION


//################################################# TABLE PROPERTIES


function xshow_tbl_properties ($ytable) {

//-----------------globals general
global	$arr_var_result, $arr_var_fields, $var_result_size, $xmy_wr_ok_msg, $xmy_wr_aff_msg, $warp_numform_decimal_sep, $warp_numform_thousand_sep ;

//-----------------ax lib globals
global	$ax_website_addr, $ax_picts_dir, $ax_txt_lnk_color, $ax_bg_color, $ax_th_color, $ax_td_color, $ax_td_color_alt, $ax_tx_color,
$ax_tx_color_err, $ax_tx_color_sp, $ax_tx_color_qe ;

//---------------- auth
global	$PHP_AUTH_USER, $PHP_AUTH_PW ;



	mysql_read_fields_ax ($ytable);
	//$arr_var_result
	//$arr_var_fields

	xtable_start_brd('');

		xtable_row_start ();
			xtable_column_start_vcenter ('8', '', "$ax_tx_color");
				xtext_title_admin (xhtml_text ('Table Properties : '.$ytable, 'n', ''));
			xtable_column_end ();
		xtable_row_end ();


		xtable_row_start ();

			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xtext_admin ('<b>'.xhtml_text ('Field', 'n', 'c').'</b>');
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xtext_admin ('<b>'.xhtml_text ('Type', 'n', 'c').'</b>');
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xtext_admin ('<b>'.xhtml_text ('Size', 'n', 'c').'</b>');
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xtext_admin ('<b>'.xhtml_text ('Default', 'n', 'c').'</b>');
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xtext_admin ('<b>'.xhtml_text ('Null', 'n', 'c').'</b>');
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xtext_admin ('<b>'.xhtml_text ('Key', 'n', 'c').'</b>');
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xtext_admin ('<b>'.xhtml_text ('Extra', 'n', 'c').'</b>');
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xtext_admin ('<b>'.xhtml_text ('Attributes', 'n', 'c').'</b>');
			xtable_column_end ();


		xtable_row_end ();


	$axl_i_alt = 0;
	for ($i=0; $i<count($arr_var_result); $i++) {
		$i_field = $i;
		$i_type = $i + 1;
		$i_size = $i + 2;
		$i_def = $i + 3;
		$i_null = $i + 4;
		$i_key = $i + 5;
		$i_ext = $i + 6;
		$i_attr = $i + 7;
		$i = $i + 7;


		$axl_i_alt = $axl_i_alt + 1;
		//------------------
		//alternate
		if( $axl_i_alt % 2 ) {
			$axl_altx_color = $ax_td_color;
		} //end if
		else {
			$axl_altx_color = $ax_td_color_alt;
		} //end else
		//------------------
			
		xtable_row_start ();

			xtable_column_start_vcenter ('1', '', "$axl_altx_color");
				xtext_admin (xhtml_text ($arr_var_result[$i_field], 'n', ''));
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$axl_altx_color");
				xtext_admin (xhtml_text (strtoupper($arr_var_result[$i_type]), 'n', 'c'));
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$axl_altx_color");
				xtext_admin (xhtml_text ($arr_var_result[$i_size], 'n', 'r'));
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$axl_altx_color");
				xtext_admin (xhtml_text ($arr_var_result[$i_def], 'n', ''));
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$axl_altx_color");
				xtext_admin (xhtml_text ($arr_var_result[$i_null], 'n', 'c'));
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$axl_altx_color");
				xtext_admin (xhtml_text ($arr_var_result[$i_key], 'n', 'c'));
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$axl_altx_color");
				xtext_admin (xhtml_text ($arr_var_result[$i_ext], 'n', ''));
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$axl_altx_color");
				xtext_admin (xhtml_text ($arr_var_result[$i_attr], 'n', ''));
			xtable_column_end ();

		xtable_row_end ();

	} //end for


	xtable_end();

} //END FUNCTION


//################################################# TABLE STATUS


function xshow_tbl_status ($ytable) {

//-----------------globals general
global	$arr_var_result, $arr_var_fields, $var_result_size, $xmy_wr_ok_msg, $xmy_wr_aff_msg, $warp_numform_decimal_sep, $warp_numform_thousand_sep ;

//-----------------ax lib globals
global	$ax_website_addr, $ax_picts_dir, $ax_txt_lnk_color, $ax_bg_color, $ax_th_color, $ax_td_color, $ax_td_color_alt, $ax_tx_color,
$ax_tx_color_err, $ax_tx_color_sp, $ax_tx_color_qe ;

//---------------- internal
global	$d, $op, $xid, $offset, $qval, $q_url;

//---------------- auth
global	$PHP_AUTH_USER, $PHP_AUTH_PW ;



	xmysql_read_data_ax (" SHOW TABLE STATUS LIKE '$ytable' ");
	//$arr_var_result


	xtable_start_brd('');
		xtable_row_start ();
			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				if ($arr_var_result[8] > 0) {
					xpict_link ("$ax_website_addr"."$ax_picts_dir".'/db_optimize.gif', 'Optimize Table'.' ['."$d".']', '30', '30', "$ax_website_addr"."ax_main.php"."?d=$d&op=optimize&offset=$offset&qval=$q_url", '_self');
				} //end if
				else {
					xpict_alt ("$ax_website_addr"."$ax_picts_dir".'/db_optimize_x.gif', '30', '30', 'Optimize Table'.' ['."$d".']');
				} //end else
				xspace();
				xpict ("$ax_website_addr"."$ax_picts_dir".'/hxliner.gif', '1', '30');
				xspace();
				xpict_link ("$ax_website_addr"."$ax_picts_dir".'/db_check.gif', 'Check Table'.' ['."$d".']', '30', '30', "$ax_website_addr"."ax_main.php"."?d=$d&op=check&offset=$offset&qval=$q_url", '_self');
				xspace();
				xpict ("$ax_website_addr"."$ax_picts_dir".'/hxliner.gif', '1', '30');
				xspace();
				xpict_link ("$ax_website_addr"."$ax_picts_dir".'/db_repair.gif', 'Repair Table'.' ['."$d".']', '30', '30', "$ax_website_addr"."ax_main.php"."?d=$d&op=repair&offset=$offset&qval=$q_url", '_self');
			xtable_column_end ();
		xtable_row_end ();
	xtable_end();


	xnewline();


	xtable_start_brd('');

		xtable_row_start ();
			xtable_column_start_vcenter ('2', '', "$ax_tx_color");
				xtext_title_admin (xhtml_text ('Table Status : '.$ytable, 'n', ''));
			xtable_column_end ();
		xtable_row_end ();


		xtable_row_start ();
			xtable_column_start_vcenter ('1', '', "$ax_td_color");
				xtext_admin ('<b>'.xhtml_text ('Table Comments', 'n', '').'</b>');
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_td_color");
				xtext_admin (xhtml_text ('`'.$arr_var_result[14].'`', 'n', ''));
			xtable_column_end ();
		xtable_row_end ();


		xtable_row_start ();
			xtable_column_start_vcenter ('1', '', "$ax_td_color_alt");
				xtext_admin ('<b>'.xhtml_text ('Table Type', 'n', '').'</b>');
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_td_color_alt");
				xtext_admin (xhtml_text ($arr_var_result[1], 'n', ''));
			xtable_column_end ();
		xtable_row_end ();

		xtable_row_start ();
			xtable_column_start_vcenter ('1', '', "$ax_td_color");
				xtext_admin ('<b>'.xhtml_text ('Records Format', 'n', '').'</b>');
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_td_color");
				xtext_admin (xhtml_text ($arr_var_result[2], 'n', ''));
			xtable_column_end ();
		xtable_row_end ();

		xtable_row_start ();
			xtable_column_start_vcenter ('1', '', "$ax_td_color_alt");
				xtext_admin ('<b>'.xhtml_text ('Total Records', 'n', '').'</b>');
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_td_color_alt");
				xtext_admin (xhtml_text (number_format($arr_var_result[3], 0, $warp_numform_decimal_sep, $warp_numform_thousand_sep), 'n', ''));
			xtable_column_end ();
		xtable_row_end ();

		xtable_row_start ();
			xtable_column_start_vcenter ('1', '', "$ax_td_color");
				xtext_admin ('<b>'.xhtml_text ('Next AutoIndex', 'n', '').'</b>');
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_td_color");
				xtext_admin (xhtml_text (number_format($arr_var_result[9], 0, $warp_numform_decimal_sep, $warp_numform_thousand_sep), 'n', ''));
			xtable_column_end ();
		xtable_row_end ();

		xtable_row_start ();
			xtable_column_start_vcenter ('1', '', "$ax_td_color_alt");
				xtext_admin ('<b>'.xhtml_text ('Data Length (kb)', 'n', '').'</b>');
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_td_color_alt");
				xtext_admin (xhtml_text (number_format($arr_var_result[5]/1024, 2, $warp_numform_decimal_sep, $warp_numform_thousand_sep), 'n', ''));
			xtable_column_end ();
		xtable_row_end ();

		xtable_row_start ();
			xtable_column_start_vcenter ('1', '', "$ax_td_color");
				xtext_admin ('<b>'.xhtml_text ('Index Length (kb)', 'n', '').'</b>');
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_td_color");
				xtext_admin (xhtml_text (number_format($arr_var_result[7]/1024, 2, $warp_numform_decimal_sep, $warp_numform_thousand_sep), 'n', ''));
			xtable_column_end ();
		xtable_row_end ();

		xtable_row_start ();
			xtable_column_start_vcenter ('1', '', "$ax_td_color_alt");
				xtext_admin ('<b>'.xhtml_text ('Total Length (kb)', 'n', '').'</b>');
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_td_color_alt");
				xtext_admin (xhtml_text (number_format(($arr_var_result[5]+$arr_var_result[7])/1024, 2, $warp_numform_decimal_sep, $warp_numform_thousand_sep), 'n', ''));
			xtable_column_end ();
		xtable_row_end ();

		xtable_row_start ();
			xtable_column_start_vcenter ('1', '', "$ax_td_color");
				xtext_admin ('<b>'.xhtml_text ('Average Record Length (kb)', 'n', '').'</b>');
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_td_color");
				xtext_admin (xhtml_text (number_format($arr_var_result[4]/1024, 2, $warp_numform_decimal_sep, $warp_numform_thousand_sep), 'n', ''));
			xtable_column_end ();
		xtable_row_end ();

		xtable_row_start ();
			xtable_column_start_vcenter ('1', '', "$ax_td_color_alt");
				xtext_admin ('<b>'.xhtml_text ('Overhead Data (kb)', 'n', '').'</b>');
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_td_color_alt");
				xtext_admin (xhtml_text (number_format($arr_var_result[8]/1024, 2, $warp_numform_decimal_sep, $warp_numform_thousand_sep), 'n', ''));
			xtable_column_end ();
		xtable_row_end ();

		xtable_row_start ();
			xtable_column_start_vcenter ('1', '', "$ax_td_color");
				xtext_admin ('<b>'.xhtml_text ('Overhead Status', 'n', '').'</b>');
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_td_color");
				if ($arr_var_result[8] > 0) {
					xtext_admin ('<font color="'.$ax_tx_color_err.'">'.xhtml_text ('Table is NOT OPTIMIZED !', 'n', '').'</font>');
				} //end if
				else {
					xtext_admin (xhtml_text ('Table is OPTIMIZED', 'n', ''));
				} //end else
			xtable_column_end ();
		xtable_row_end ();

		xtable_row_start ();
			xtable_column_start_vcenter ('1', '', "$ax_td_color_alt");
				xtext_admin ('<b>'.xhtml_text ('Created On', 'n', '').'</b>');
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_td_color_alt");
				xtext_admin (xhtml_text ($arr_var_result[10], 'n', ''));
			xtable_column_end ();
		xtable_row_end ();

		xtable_row_start ();
			xtable_column_start_vcenter ('1', '', "$ax_td_color");
				xtext_admin ('<b>'.xhtml_text ('Updated On', 'n', '').'</b>');
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_td_color");
				xtext_admin (xhtml_text ($arr_var_result[11], 'n', ''));
			xtable_column_end ();
		xtable_row_end ();

		xtable_row_start ();
			xtable_column_start_vcenter ('1', '', "$ax_td_color_alt");
				xtext_admin ('<b>'.xhtml_text ('Checked On', 'n', '').'</b>');
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_td_color_alt");
				xtext_admin (xhtml_text ($arr_var_result[12], 'n', ''));
			xtable_column_end ();
		xtable_row_end ();

	xtable_end();


} //END FUNCTION


//################################################# TABLE KEYS


function xshow_tbl_keys ($ytable) {

//-----------------globals general
global	$arr_var_result, $arr_var_fields, $var_result_size, $xmy_wr_ok_msg, $xmy_wr_aff_msg, $warp_numform_decimal_sep, $warp_numform_thousand_sep ;

//-----------------ax lib globals
global	$ax_website_addr, $ax_picts_dir, $ax_txt_lnk_color, $ax_bg_color, $ax_th_color, $ax_td_color, $ax_td_color_alt, $ax_tx_color,
$ax_tx_color_err, $ax_tx_color_sp, $ax_tx_color_qe ;

//---------------- auth
global	$PHP_AUTH_USER, $PHP_AUTH_PW ;



	xmysql_read_data_ax (" SHOW INDEX FROM $ytable ");
	//$arr_var_result

	xtable_start_brd('');

		xtable_row_start ();
			xtable_column_start_vcenter ('5', '', "$ax_tx_color");
				xtext_title_admin (xhtml_text ('Table Keys : '.$ytable, 'n', ''));
			xtable_column_end ();
		xtable_row_end ();


		xtable_row_start ();

			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xtext_admin ('<b>'.xhtml_text ('Field', 'n', 'c').'</b>');
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xtext_admin ('<b>'.xhtml_text ('Keyname', 'n', 'c').'</b>');
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xtext_admin ('<b>'.xhtml_text ('Type', 'n', 'c').'</b>');
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xtext_admin ('<b>'.xhtml_text ('Unique', 'n', 'c').'</b>');
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xtext_admin ('<b>'.xhtml_text ('Cardinality', 'n', 'c').'</b>');
			xtable_column_end ();

		xtable_row_end ();

	$axl_i_alt = 0;
	for ($i=0; $i<count($arr_var_result); $i++) {
		$i_table = $i;
		$i_non_uniq = $i + 1;
		$i_key_name = $i + 2;
		$i_seq_idx = $i + 3;
		$i_col_name = $i + 4;
		$i_collation = $i + 5;
		$i_cardinality = $i + 6;
		$i_subpart = $i + 7;
		$i_packed = $i + 8;
		$i_comment = $i + 9;
		$i = $i + 9;


		$axl_i_alt = $axl_i_alt + 1;
		//------------------
		//alternate
		if( $axl_i_alt % 2 ) {
			$axl_altx_color = $ax_td_color;
		} //end if
		else {
			$axl_altx_color = $ax_td_color_alt;
		} //end else
		//------------------
			
		xtable_row_start ();

			$hmy_keytyp = '';
			if (eregi('PRIMARY', $arr_var_result[$i_key_name])) {
				$hmy_keytyp = 'PRIMARY';
			} //end if
			if ( (empty($hmy_keytyp)) AND ($arr_var_result[$i_non_uniq] == '0') ) {
				$hmy_keytyp = 'UNIQUE';
			} //end if

			if ( (empty($hmy_keytyp)) AND ($arr_var_result[$i_non_uniq] == '1') AND (empty($arr_var_result[$i_comment])) ) {
				$hmy_keytyp = 'INDEX';
			} //end if

			if ( (empty($hmy_keytyp)) AND ($arr_var_result[$i_non_uniq] == '1') AND (eregi('FULLTEXT', $arr_var_result[$i_comment])) ) {
				$hmy_keytyp = 'FULLTEXT';
			} //end if


			xtable_column_start_vcenter ('1', '', "$axl_altx_color");
				xtext_admin (xhtml_text ($arr_var_result[$i_col_name], 'n', ''));
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$axl_altx_color");
				xtext_admin (xhtml_text ($arr_var_result[$i_key_name], 'n', ''));
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$axl_altx_color");
				xtext_admin (xhtml_text ($hmy_keytyp, 'n', ''));
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$axl_altx_color");
				if ($arr_var_result[$i_non_uniq] == '0') {
					xtext_admin (xhtml_text ('Yes', 'n', 'c'));
				} //end if
				else {
					xtext_admin (xhtml_text ('No', 'n', 'c'));
				} //end if
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$axl_altx_color");
				if (is_numeric($arr_var_result[$i_cardinality])) {
					xtext_admin (xhtml_text ($arr_var_result[$i_cardinality], 'n', 'r'));
				} //end if
				else {
					xtext_admin (xhtml_text ('None', 'n', 'r'));
				} //end if
			xtable_column_end ();

		xtable_row_end ();

	} //end for


	xtable_end();


} //END FUNCTION



//################################################# TABLE DATA


function xshow_tbl_data ($ytable) {

//the first field of each table must be 'id - primary_key (unique) - auto_increment'

//-----------------globals general
global	$arr_var_result, $arr_var_fields, $var_result_size, $xmy_wr_ok_msg, $xmy_wr_aff_msg, $warp_numform_decimal_sep, $warp_numform_thousand_sep ;

//-----------------ax lib globals
global	$ax_website_addr, $ax_picts_dir, $ax_txt_lnk_color, $ax_bg_color, $ax_th_color, $ax_td_color, $ax_td_color_alt, $ax_tx_color,
$ax_tx_color_err, $ax_tx_color_sp, $ax_tx_color_qe ;

//---------------- internal
global	$d, $op, $xid, $offset, $qval, $q_url;

//---------------- auth
global	$PHP_AUTH_USER, $PHP_AUTH_PW ;


//get table defs
xmysql_read_data_ax ( " SELECT can_view, can_edit, can_insert, can_delete, tbl_descr, tbl_hint, id FROM warp_tables_defs WHERE (tbl_name='$d') " );
$arr_x_tbldefs = array();
$arr_x_tbldefs = $arr_var_result;
$arr_var_result = array();

//get field names
xmysql_read_data_ax ( " SELECT field_name FROM warp_tables_fields WHERE (table_own='$ytable') ORDER BY field_id ASC " );
$arr_x_fields = array();
$arr_x_fields = $arr_var_result;
$arr_var_result = array();

//---------------------- CHECK
	if ( (empty($arr_x_tbldefs[6])) OR (count($arr_x_fields) <= 0) ) {
		xcenter_start();
			xtext_admin_error ('<br>&nbsp;&nbsp;&nbsp;ERROR : Table `'.$d.'` has not been defined for accessing with warp.cms.admin !') ;
		xcenter_end();
		die('');
	} //end if
//----------------------------

//get field descr
xmysql_read_data_ax ( " SELECT field_descr FROM warp_tables_fields WHERE (table_own='$ytable') ORDER BY field_id ASC " );
$arr_x_fields_des = array();
$arr_x_fields_des = $arr_var_result;
$arr_var_result = array();

//get field rd procs
xmysql_read_data_ax ( " SELECT field_read_proc FROM warp_tables_fields WHERE (table_own='$ytable') ORDER BY field_id ASC " );
$arr_x_fields_proc = array();
$arr_x_fields_proc = $arr_var_result;
$arr_var_result = array();


	//build keys-check from special table
	$hmy_keys_compare_warp_fld = ' ';
	for($i=0; $i<count($arr_x_fields); $i++) {
		if ($i < (count($arr_x_fields)-1) ) {
			$hmy_keys_compare_warp_fld = $hmy_keys_compare_warp_fld.$arr_x_fields[$i].', ';
		} //end if
		else {
			$hmy_keys_compare_warp_fld = $hmy_keys_compare_warp_fld.$arr_x_fields[$i].' ';
		} //end else
	} //end for


$limit = '10';
//---------------------
if (empty($offset)) {
	$offset = 0;
} //end if
//---------------------


	//[set text if filtered] or [empty querry]
	if (empty($qval)) {
		$querry_srcc = ' ';
		$axl_filteredby = '';
	} //end if
	else {
		$querry_srcc = ' WHERE ('."$qval".')';
		$axl_filteredby = ' - <b>Filtered</b>' ;
	} //end else



	$hmy_querryx = " SELECT $hmy_keys_compare_warp_fld FROM $ytable $querry_srcc ORDER BY id ASC LIMIT $offset, $limit ";
	$hmy_querryx_c = " SELECT COUNT(*) FROM $ytable $querry_srcc ";

	xmysql_read_data_ax ($hmy_querryx);
	$arr_my_table_data = array();
	$arr_my_table_data = $arr_var_result;
	$arr_var_result = array();

	$arr_my_table_fields = array();
	$arr_my_table_fields = $arr_var_fields;
	$arr_var_fields = array();

	xmysql_count_data_ax ($hmy_querryx_c);
	$arr_my_table_size = $var_result_size;
	$var_result_size = '';

	// CHECK ID (PRIMARY KEY)
	mysql_read_fields_ax ($ytable);
	//$arr_var_result
	if ( ($arr_my_table_fields[0] != 'id') OR ($arr_var_result[5] != 'PRI') ) {
		xtext_error ('Warning : The first field of this table is not the primary (unique) key `ID`. All related operations such as `edit`, `view` or `delete` are using the primary key `ID` key. This can lead to unpredictable results in `view / edit / delete`.<br><br>');
	} //end if
	$arr_var_result = array();


	//build keys-check from real table
	$hmy_keys_compare_warp = ' ';
	for($i=0; $i<count($arr_my_table_fields); $i++) {
		if ($i < (count($arr_my_table_fields)-1) ) {
			$hmy_keys_compare_warp = $hmy_keys_compare_warp.$arr_my_table_fields[$i].', ';
		} //end if
		else {
			$hmy_keys_compare_warp = $hmy_keys_compare_warp.$arr_my_table_fields[$i].' ';
		} //end else
	} //end for

	//if are defined in special table and not match
	if ($hmy_keys_compare_warp != $hmy_keys_compare_warp_fld) {
		xtext_error ('Warning : The table definition does not match the warp administration table values.<br><br>');
	} //end if

	//---------------------------------------------
	//nav vars
	$newoffsetnext = $offset + $limit ;
	$newoffsetprev = $offset - $limit ;
	$offsetlistedmin = $offset + 1;

	if ($newoffsetnext <= $arr_my_table_size) {
		$offsetlistedmax = $newoffsetnext;
	} //end if
	else {
		$offsetlistedmax = $arr_my_table_size;
	} //end else

	if ($offsetlistedmax == 0) {
		$offsetlistedmin = 0;
	} //end if
	//---------------------------------------------

	//build url's
	$xurl = "$ax_website_addr"."ax_main.php"."?d=$d&op=$op&offset=0";
	$xurl_prev = "$ax_website_addr"."ax_main.php"."?d=$d&op=$op&offset=$newoffsetprev&qval=$q_url";
	$xurl_next = "$ax_website_addr"."ax_main.php"."?d=$d&op=$op&offset=$newoffsetnext&qval=$q_url";

	//---------------------------------------------



	//--------------- THE QUERRY FORM (WHERE)

	//querry form
	xcenter_start();
	xtable_start ('');
		xtable_row_start ();
			xtable_column_start_vcenter ('1', '', "$ax_bg_color");
				xform_start ('querry_form', $xurl);
					xtext_admin ('WHERE : ');
					xform_text_box ('qval', '150', '50', rawurldecode($q_url));
					xspace();
					xform_send_bttn ('Filter');
				xform_end ();
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_bg_color");
				echo ('&nbsp;&nbsp;');
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_bg_color");
				xform_start ('querry_form_reset', $xurl);
					xform_send_bttn ('Show All');
				xform_end ();
			xtable_column_end ();
		xtable_row_end ();
	xtable_end();

	xnewline();

	//--------------- THE TABLE DATA

	xtable_start_brd('');

		xtable_row_start ();
			xtable_column_start_vcenter (count($arr_my_table_fields)+3, '', "$ax_tx_color");
				xtext_title_admin (xhtml_text ('Table Data : '.$ytable, 'n', ''));
				if ( (!empty($arr_x_tbldefs[4])) OR (!empty($arr_x_tbldefs[5])) ) {
					xnewline();
					xhr_line ('100%');
					xtext_admin ('<i><b>'.xhtml_text ($arr_x_tbldefs[4], 'n', '').'</b> - </i>');
					xtext_admin ('<i>'.xhtml_text ($arr_x_tbldefs[5], 'n', '').'</i>');
				} //end if
			xtable_column_end ();
		xtable_row_end ();

		xtable_row_start ();
			xtable_column_start_vcenter (count($arr_my_table_fields)+3, '', "$ax_tx_color");
				xtext_admin ('<font color="'.$ax_tx_color_qe.'"><b>&nbsp;Query :</b>'.xhtml_text ($hmy_querryx, 'n', '').'</font>');
			xtable_column_end ();
		xtable_row_end ();

		xtable_row_start ();
			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xcenter_start();
				xpict_link ("$ax_website_addr"."$ax_picts_dir".'/db_empty.gif', 'Empty Table'.' ['."$d".']', '30', '30', "$ax_website_addr"."ax_main.php"."?d=$d&op=empty&offset=$offset&qval=$q_url", '_self');
				xcenter_end();
			xtable_column_end ();

			xtable_column_start_vcenter (count($arr_my_table_fields)+2, '', "$ax_tx_color");
				xtext_admin ("&nbsp;&nbsp;&nbsp;&nbsp;<b>Records</b> [<b>$offsetlistedmin</b> - <b>$offsetlistedmax</b> (<b>$arr_my_table_size</b> total)]".' - '.'Listed in ascending order by `id`'."$axl_filteredby".'&nbsp;');
			xtable_column_end ();
		xtable_row_end ();

		xtable_row_start ();
			xtable_column_start_vcenter ('3', '', "$ax_tx_color");
				xcenter_start();
				xtext_admin ('<i>'.xhtml_text ('[Operations]', 'n', '').'</i>');
				xcenter_end();
			xtable_column_end ();

			for ($i=0; $i<count($arr_my_table_fields); $i++) {
			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xtext_admin ('<b>'.xhtml_text ($arr_x_fields_des[$i], 'n', 'c').'</b>');
			xtable_column_end ();
			} //end for
		xtable_row_end ();

		xtable_row_start ();
			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				//Show PREV
				if ($newoffsetprev >= 0) {
					xcenter_start();
					xpict_link ("$ax_website_addr"."$ax_picts_dir".'/nav_prev.gif', 'Prev &lt;&lt;', '30', '30', $xurl_prev, '_self');
					xcenter_end();
				} //end if
				else {
					xcenter_start();
					xpict ("$ax_website_addr"."$ax_picts_dir".'/nav_prev_x.gif', '30', '30');
					xcenter_end();
				} //end else
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				if ($arr_x_tbldefs[2] != 'n') {
					xcenter_start();
					xpict_link ("$ax_website_addr"."$ax_picts_dir".'/op_insert.gif', 'Insert New Record', '30', '30', "$ax_website_addr"."ax_main.php"."?d=$d&op=insert&offset=$offset&qval=$q_url", '_self');
					xcenter_end();
				} //end if
				else {
					xcenter_start();
					xpict_alt ("$ax_website_addr"."$ax_picts_dir".'/op_insert_x.gif', '30', '30', 'Insert New Record');
					xcenter_end();
				} //end else
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				//Show NEXT
				if ($newoffsetnext < $arr_my_table_size) {
					xcenter_start();
					xpict_link ("$ax_website_addr"."$ax_picts_dir".'/nav_next.gif', 'Next &gt;&gt;', '30', '30', $xurl_next, '_self');
					xcenter_end();
				} //end if
				else {
					xcenter_start();
					xpict ("$ax_website_addr"."$ax_picts_dir".'/nav_next_x.gif', '30', '30');
					xcenter_end();
				} //end else
			xtable_column_end ();

			for ($i=0; $i<count($arr_my_table_fields); $i++) {
			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xtext_admin ('<font color="'.$ax_tx_color_sp.'"><b>'.xhtml_text ($arr_my_table_fields[$i], 'n', 'c').'</b></font>');
			xtable_column_end ();
			} //end for
		xtable_row_end ();


		$axl_i_alt = $offset;
		for ($i=0; $i<count($arr_my_table_data); $i++) {

			$axl_i_alt = $axl_i_alt + 1;
			//------------------
			//alternate
			if( $axl_i_alt % 2 ) {
				$axl_altx_color = $ax_td_color;
			} //end if
			else {
				$axl_altx_color = $ax_td_color_alt;
			} //end else
			//------------------

			xtable_row_start ();

				xtable_column_start_vcenter ('1', '', "$axl_altx_color");
					if ($arr_x_tbldefs[3] != 'n') {
						xcenter_start();
						xpict_link ("$ax_website_addr"."$ax_picts_dir".'/op_delete.gif', 'Delete Record', '30', '30', "$ax_website_addr"."ax_main.php"."?d=$d&op=delete&xid=$arr_my_table_data[$i]&offset=$offset&qval=$q_url", '_self');
						xcenter_end();
					} //end if
					else {
						xcenter_start();
						xpict_alt ("$ax_website_addr"."$ax_picts_dir".'/op_delete_x.gif', '30', '30', 'Delete Record');
						xcenter_end();
					} //end else
				xtable_column_end ();

				xtable_column_start_vcenter ('1', '', "$axl_altx_color");
					if ($arr_x_tbldefs[1] != 'n') {
						xcenter_start();
						xpict_link ("$ax_website_addr"."$ax_picts_dir".'/op_edit.gif', 'Edit Record', '30', '30', "$ax_website_addr"."ax_main.php"."?d=$d&op=edit&xid=$arr_my_table_data[$i]&offset=$offset&qval=$q_url", '_self');
						xcenter_end();
					} //end if
					else {
						xcenter_start();
						xpict_alt ("$ax_website_addr"."$ax_picts_dir".'/op_edit_x.gif', '30', '30', 'Edit Record');
						xcenter_end();
					} //end else
				xtable_column_end ();

				xtable_column_start_vcenter ('1', '', "$axl_altx_color");
					if ($arr_x_tbldefs[0] != 'n') {
						xcenter_start();
						xpict_link ("$ax_website_addr"."$ax_picts_dir".'/op_view.gif', 'View Record', '30', '30', "$ax_website_addr"."ax_main.php"."?d=$d&op=view&xid=$arr_my_table_data[$i]&offset=$offset&qval=$q_url", '_self');
						xcenter_end();
					} //end if
					else {
						xcenter_start();
						xpict_alt ("$ax_website_addr"."$ax_picts_dir".'/op_view_x.gif', '30', '30', 'View Record');
						xcenter_end();
					} //end else
				xtable_column_end ();



			$i_xeval = 0;
			for ($ii=0; $ii<count($arr_my_table_fields); $ii++) {
				$iii = $i + $ii;
				xtable_column_start_vcenter ('1', '', "$axl_altx_color");
					if (!empty($arr_x_fields_proc[$i_xeval])) {
						//$arr_my_table_data[$iii]
						eval (' '."\n"."$arr_x_fields_proc[$i_xeval]".' '."\n");
					} //end if
					else {
						xtext_admin (xhtml_text ($arr_my_table_data[$iii], 'y', ''));
					} //end else
				xtable_column_end ();
				$i_xeval = $i_xeval + 1;
			} //end for

			xtable_row_end ();
			$i = $i + count($arr_my_table_fields) - 1;
		} //end for

	xtable_end();

	xcenter_end();


} //END FUNCTION


//################################################# TABLE VIEW ID / DELETE ID


function xshow_tbl_view ($ytable, $yconfdel) {

//the first field of each table must be 'id - primary_key (unique) - auto_increment'

//-----------------globals general
global	$arr_var_result, $arr_var_fields, $var_result_size, $xmy_wr_ok_msg, $xmy_wr_aff_msg, $warp_numform_decimal_sep, $warp_numform_thousand_sep ;

//-----------------ax lib globals
global	$ax_website_addr, $ax_picts_dir, $ax_txt_lnk_color, $ax_bg_color, $ax_th_color, $ax_td_color, $ax_td_color_alt, $ax_tx_color,
$ax_tx_color_err, $ax_tx_color_sp, $ax_tx_color_qe ;

//---------------- internal
global	$d, $op, $xid, $offset, $qval, $q_url;

//---------------- auth
global	$PHP_AUTH_USER, $PHP_AUTH_PW ;



	//[set text if filtered] or [empty querry]
	if (empty($qval)) {
		$querry_srcc = ' ';
		$axl_filteredby = '';
	} //end if
	else {
		$querry_srcc = ' AND ('."$qval".')';
		$axl_filteredby = ' - [Filtered] : '.htmlspecialchars($qval) ;
	} //end else


//get table defs
xmysql_read_data_ax ( " SELECT can_view, can_edit, can_insert, can_delete, note_delete, id FROM warp_tables_defs WHERE (tbl_name='$d') " );
$arr_x_tbldefs = array();
$arr_x_tbldefs = $arr_var_result;
$arr_var_result = array();


//get field names
xmysql_read_data_ax ( " SELECT field_name FROM warp_tables_fields WHERE (table_own='$ytable') ORDER BY field_id ASC " );
$arr_x_fields = array();
$arr_x_fields = $arr_var_result;
$arr_var_result = array();


//---------------------- CHECK
	if ( (empty($arr_x_tbldefs[5])) OR (count($arr_x_fields) <= 0) ) {
		xtext_admin_error ('<br>&nbsp;&nbsp;&nbsp;ERROR : Table `'.$d.'` has not been defined for accessing with warp.cms.admin !') ;
		die('');
	} //end if
//----------------------------


//get field descr
xmysql_read_data_ax ( " SELECT field_descr FROM warp_tables_fields WHERE (table_own='$ytable') ORDER BY field_id ASC " );
$arr_x_fields_des = array();
$arr_x_fields_des = $arr_var_result;
$arr_var_result = array();

//get field vw procs
xmysql_read_data_ax ( " SELECT field_view_proc FROM warp_tables_fields WHERE (table_own='$ytable') ORDER BY field_id ASC " );
$arr_x_fields_proc = array();
$arr_x_fields_proc = $arr_var_result;
$arr_var_result = array();


	//build keys-check from special table
	$hmy_keys_compare_warp_fld = ' ';
	for($i=0; $i<count($arr_x_fields); $i++) {
		if ($i < (count($arr_x_fields)-1) ) {
			$hmy_keys_compare_warp_fld = $hmy_keys_compare_warp_fld.$arr_x_fields[$i].', ';
		} //end if
		else {
			$hmy_keys_compare_warp_fld = $hmy_keys_compare_warp_fld.$arr_x_fields[$i].' ';
		} //end else
	} //end for


	//----------------------

	$hmy_querryx = " SELECT $hmy_keys_compare_warp_fld FROM $ytable WHERE (id='$xid') ";


	xmysql_read_data_ax ($hmy_querryx);
	$arr_my_table_data = array();
	$arr_my_table_data = $arr_var_result;
	$arr_var_result = array();

	$arr_my_table_fields = array();
	$arr_my_table_fields = $arr_var_fields;
	$arr_var_fields = array();


	//get prev
	xmysql_read_data_ax (" SELECT id FROM $ytable WHERE ( (id<'$xid') $querry_srcc ) ORDER BY id DESC LIMIT 0,1 ");
	$arr_my_table_prev = array();
	$arr_my_table_prev = $arr_var_result;
	$arr_var_result = array();

	//get next
	xmysql_read_data_ax (" SELECT id FROM $ytable WHERE ( (id>'$xid') $querry_srcc ) ORDER BY id ASC LIMIT 0,1 ");
	$arr_my_table_next = array();
	$arr_my_table_next = $arr_var_result;
	$arr_var_result = array();



	// CHECK ID (PRIMARY KEY)
	mysql_read_fields_ax ($ytable);
	//$arr_var_result
	if ( ($arr_my_table_fields[0] != 'id') OR ($arr_var_result[5] != 'PRI') ) {
		xtext_error ('Warning : The first field of this table is not the primary (unique) key `ID`. All related operations such as `edit`, `view` or `delete` are using the primary key `ID` key. This can lead to unpredictable results in `view / edit / delete`.<br><br>');
	} //end if
	$arr_var_result = array();


	//build keys-check from real table
	$hmy_keys_compare_warp = ' ';
	for($i=0; $i<count($arr_my_table_fields); $i++) {
		if ($i < (count($arr_my_table_fields)-1) ) {
			$hmy_keys_compare_warp = $hmy_keys_compare_warp.$arr_my_table_fields[$i].', ';
		} //end if
		else {
			$hmy_keys_compare_warp = $hmy_keys_compare_warp.$arr_my_table_fields[$i].' ';
		} //end else
	} //end for

	//if are defined in special table and not match
	if ($hmy_keys_compare_warp != $hmy_keys_compare_warp_fld) {
		xtext_error ('Warning : The table definition does not match the warp administration table values.<br><br>');
	} //end if


	//---------------------------------------------



	//--------------- THE TABLE VIEW PARTICULAR DATA

	xtable_start_brd('750');


	//if confirm deletion
	if ($yconfdel != 'y') {

		xtable_row_start ();
			xtable_column_start_vcenter ('1', '', "$ax_tx_color");

				//Show PREV
				if (!empty($arr_my_table_prev[0])) {
					xpict_link ("$ax_website_addr"."$ax_picts_dir".'/nav_prev.gif', 'Prev &lt;&lt;'.$axl_filteredby, '30', '30', "$ax_website_addr"."ax_main.php"."?d=$d&op=view&xid=$arr_my_table_prev[0]&offset=$offset&qval=$q_url", '_self');
				} //end if
				else {
					xpict ("$ax_website_addr"."$ax_picts_dir".'/nav_prev_x.gif', '30', '30');
				} //end else

				echo ('&nbsp;');

				//Show NEXT
				if (!empty($arr_my_table_next[0])) {
					xpict_link ("$ax_website_addr"."$ax_picts_dir".'/nav_next.gif', 'Next &gt;&gt;'.$axl_filteredby, '30', '30', "$ax_website_addr"."ax_main.php"."?d=$d&op=view&xid=$arr_my_table_next[0]&offset=$offset&qval=$q_url", '_self');
				} //end if
				else {
					xpict ("$ax_website_addr"."$ax_picts_dir".'/nav_next_x.gif', '30', '30');
				} //end else

			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_tx_color");

				xcenter_right_start();

				//edit
				if ($arr_x_tbldefs[1] != 'n') {
					xpict_link ("$ax_website_addr"."$ax_picts_dir".'/op_edit.gif', 'Edit Record', '30', '30', "$ax_website_addr"."ax_main.php"."?d=$d&op=edit&xid=$xid&offset=$offset&qval=$q_url", '_self');
				} //end if
				else {
					xpict_alt ("$ax_website_addr"."$ax_picts_dir".'/op_edit_x.gif', '30', '30', 'Edit Record');
				} //end else

				echo ('&nbsp;');

				//delete
				if ($arr_x_tbldefs[3] != 'n') {
					xpict_link ("$ax_website_addr"."$ax_picts_dir".'/op_delete.gif', 'Delete Record', '30', '30', "$ax_website_addr"."ax_main.php"."?d=$d&op=delete&xid=$xid", '_self');
				} //end if
				else {
					xpict_alt ("$ax_website_addr"."$ax_picts_dir".'/op_delete_x.gif', '30', '30', 'Delete Record');
				} //end else

				xcenter_end();

			xtable_column_end ();
		xtable_row_end ();

		} //end if
		else {

		xtable_row_start ();
			xtable_column_start_vcenter ('1', '', "$ax_tx_color");

				xnewline();
				xcenter_start();
				xform_start ('del_form', "$ax_website_addr".'ax_op.php');
					xform_hidden ('d', $d);
					xform_hidden ('op', 'del');
					xform_hidden ('xid', $xid);
					xform_hidden ('offset', $offset);
					xform_hidden ('qval', $q_url);
					xform_hidden ('wxu', MD5($PHP_AUTH_USER));
					xform_hidden ('wxp', MD5(MD5($PHP_AUTH_PW)));

					xform_send_bttn ('Delete Record');
				xform_end ();
				xcenter_end();

			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xtext_title_admin ('<font color="'.$ax_tx_color_sp.'">'.'&nbsp;Delete Record ID=`'.$xid.'`'.'<br>'.'&nbsp;From Table : '.$ytable.' ?'.'</font>');
			xtable_column_end ();
		xtable_row_end ();

		xtable_row_start ();
			xtable_column_start_vcenter ('2', '', "$ax_tx_color");
				xtext_admin ('<font color="'.$ax_tx_color_sp.'">'.xhtml_text ($arr_x_tbldefs[4], 'n', '').'</font>');
			xtable_column_end ();
		xtable_row_end ();

		xtable_row_start ();
			xtable_column_start_vcenter ('2', '', "$ax_bg_color");
				echo ('&nbsp;');
			xtable_column_end ();
		xtable_row_end ();

		} //end else

		xtable_row_start ();
			xtable_column_start_vcenter ('2', '', "$ax_tx_color");
				xtext_title_admin (xhtml_text ('Record View : ID=`'.$xid.'` - '.'Table : '.$ytable, 'n', ''));
			xtable_column_end ();
		xtable_row_end ();

		xtable_row_start ();
			xtable_column_start_vcenter ('2', '', "$ax_tx_color");
				xtext_admin ('<font color="'.$ax_tx_color_qe.'"><b>&nbsp;Query :</b>'.xhtml_text ($hmy_querryx, 'n', '').'</font>');
			xtable_column_end ();
		xtable_row_end ();


		$axl_i_alt = '0';
		$i_xeval = '0';
		$iii = '0';
		for ($i=0; $i<count($arr_my_table_fields); $i++) {

			$i_xeval = $i;
			$iii = $i;

			$axl_i_alt = $axl_i_alt + 1;
			//------------------
			//alternate
			if( $axl_i_alt % 2 ) {
				$axl_altx_color = $ax_td_color;
			} //end if
			else {
				$axl_altx_color = $ax_td_color_alt;
			} //end else
			//------------------

			xtable_row_start ();
				//descr and flds
				xtable_column_start ('1', '200', "$axl_altx_color");
					xtext_admin ('<font color="'.$ax_tx_color_sp.'"><b>'.xhtml_text ($arr_my_table_fields[$i], 'n', 'l').'</b></font>');
					xtext_admin ('<b>'.xhtml_text ($arr_x_fields_des[$i], 'n', 'l').'</b>');
				xtable_column_end ();

				//data
				xtable_column_start_vcenter ('1', '550', "$axl_altx_color");
					if (!empty($arr_x_fields_proc[$i_xeval])) {
						//$arr_my_table_data[$iii]
						eval (' '."\n"."$arr_x_fields_proc[$i_xeval]".' '."\n");
					} //end if
					else {
						xtext_admin (xhtml_text ($arr_my_table_data[$iii], 'n', ''));
					} //end else
				xtable_column_end ();

			xtable_row_end ();
		} //end for

	xtable_end();

	xcenter_end();


} //END FUNCTION


//################################################# TABLE ADD / EDIT


function xshow_tbl_form_ae ($ytable, $yaxe) {

//the first field of each table must be 'id - primary_key (unique) - auto_increment'
//yaxe : upd ; add

//-----------------globals general
global	$arr_var_result, $arr_var_fields, $var_result_size, $xmy_wr_ok_msg, $xmy_wr_aff_msg, $warp_numform_decimal_sep, $warp_numform_thousand_sep ;

//-----------------ax lib globals
global	$ax_website_addr, $ax_picts_dir, $ax_txt_lnk_color, $ax_bg_color, $ax_th_color, $ax_td_color, $ax_td_color_alt, $ax_tx_color,
$ax_tx_color_err, $ax_tx_color_sp, $ax_tx_color_qe ;

//---------------- internal
global	$d, $op, $xid, $offset, $qval, $q_url;

//---------------- auth
global	$PHP_AUTH_USER, $PHP_AUTH_PW ;



//get table defs
xmysql_read_data_ax ( " SELECT can_view, can_edit, can_insert, can_delete, note_delete, id FROM warp_tables_defs WHERE (tbl_name='$d') " );
$arr_x_tbldefs = array();
$arr_x_tbldefs = $arr_var_result;
$arr_var_result = array();


//get field names
xmysql_read_data_ax ( " SELECT field_name FROM warp_tables_fields WHERE (table_own='$ytable') ORDER BY field_id ASC " );
$arr_x_fields = array();
$arr_x_fields = $arr_var_result;
$arr_var_result = array();


//---------------------- CHECK
	if ( (empty($arr_x_tbldefs[5])) OR (count($arr_x_fields) <= 0) ) {
		xtext_admin_error ('<br>&nbsp;&nbsp;&nbsp;ERROR : Table `'.$d.'` has not been defined for accessing with warp.cms.admin !') ;
		die('');
	} //end if
//----------------------------

//get field descr
xmysql_read_data_ax ( " SELECT field_descr FROM warp_tables_fields WHERE (table_own='$ytable') ORDER BY field_id ASC " );
$arr_x_fields_des = array();
$arr_x_fields_des = $arr_var_result;
$arr_var_result = array();

//get field hint
xmysql_read_data_ax ( " SELECT field_hint FROM warp_tables_fields WHERE (table_own='$ytable') ORDER BY field_id ASC " );
$arr_x_fields_hint = array();
$arr_x_fields_hint = $arr_var_result;
$arr_var_result = array();

//get field frm procs
xmysql_read_data_ax ( " SELECT field_form_proc FROM warp_tables_fields WHERE (table_own='$ytable') ORDER BY field_id ASC " );
$arr_x_fields_form = array();
$arr_x_fields_form = $arr_var_result;
$arr_var_result = array();

//init arrays anyway
$arr_my_table_data = array();
$arr_my_table_fields = array();

//identify by add or edit
if ($yaxe == 'upd') {
	//build keys-check from special table
	$hmy_keys_compare_warp_fld = ' ';
	for($i=0; $i<count($arr_x_fields); $i++) {
		if ($i < (count($arr_x_fields)-1) ) {
			$hmy_keys_compare_warp_fld = $hmy_keys_compare_warp_fld.$arr_x_fields[$i].', ';
		} //end if
		else {
			$hmy_keys_compare_warp_fld = $hmy_keys_compare_warp_fld.$arr_x_fields[$i].' ';
		} //end else
	} //end for

	$hmy_querryx = " SELECT $hmy_keys_compare_warp_fld FROM $ytable WHERE id='$xid' ";

	xmysql_read_data_ax ($hmy_querryx);
	$arr_my_table_data = array();
	$arr_my_table_data = $arr_var_result;
	$arr_var_result = array();

	$arr_my_table_fields = array();
	$arr_my_table_fields = $arr_var_fields;
	$arr_var_fields = array();

	// CHECK ID (PRIMARY KEY)
	mysql_read_fields_ax ($ytable);
	//$arr_var_result
	if ( ($arr_my_table_fields[0] != 'id') OR ($arr_var_result[5] != 'PRI') ) {
		xtext_error ('Warning : The first field of this table is not the primary (unique) key `ID`. All related operations such as `edit`, `view` or `delete` are using the primary key `ID` key. This can lead to unpredictable results in `view / edit / delete`.<br><br>');
	} //end if
	$arr_var_result = array();


	//build keys-check from real table
	$hmy_keys_compare_warp = ' ';
	for($i=0; $i<count($arr_my_table_fields); $i++) {
		if ($i < (count($arr_my_table_fields)-1) ) {
			$hmy_keys_compare_warp = $hmy_keys_compare_warp.$arr_my_table_fields[$i].', ';
		} //end if
		else {
			$hmy_keys_compare_warp = $hmy_keys_compare_warp.$arr_my_table_fields[$i].' ';
		} //end else
	} //end for

	//if are defined in special table and not match
	if ($hmy_keys_compare_warp != $hmy_keys_compare_warp_fld) {
		xtext_error ('Warning : The table definition does not match the warp administration table values.<br><br>');
	} //end if


} //end if


	xform_start ('add_edt_form', "$ax_website_addr".'ax_op.php');

	xform_hidden ('d', $d);
	xform_hidden ('op', $yaxe);
	xform_hidden ('xid', $xid);
	xform_hidden ('offset', $offset);
	xform_hidden ('qval', $q_url);
	xform_hidden ('wxu', MD5($PHP_AUTH_USER));
	xform_hidden ('wxp', MD5(MD5($PHP_AUTH_PW)));


	xtable_start_brd('750');

		xtable_row_start ();
			xtable_column_start_vcenter ('2', '', "$ax_tx_color");
				if ($yaxe == 'upd') {
					xtext_title_admin (xhtml_text ('Update Record ID=`'.$xid.'` - Table : '.$ytable, 'n', ''));
				} //end if
				else {
					xtext_title_admin (xhtml_text ('Insert New Record - Table : '.$ytable, 'n', ''));
				} //end else
			xtable_column_end ();
		xtable_row_end ();

		$axl_i_alt = '0';
		for ($i=0; $i<count($arr_x_fields); $i++) {

			$axl_i_alt = $axl_i_alt + 1;
			//------------------
			//alternate
			if( $axl_i_alt % 2 ) {
				$axl_altx_color = $ax_td_color;
			} //end if
			else {
				$axl_altx_color = $ax_td_color_alt;
			} //end else
			//------------------

		if (!empty($arr_x_fields_form[$i])) {
		xtable_row_start ();
			xtable_column_start_vcenter ('1', '', "$axl_altx_color");
				xtext_admin ('<font color="'.$ax_tx_color_sp.'">'.'<b>'.xhtml_text ($arr_x_fields[$i], 'n', '').'</b>'.'</font>');
				xnewline();
				xtext_admin ('<b>'.xhtml_text ($arr_x_fields_des[$i].' : ', 'n', '').'</b>');
				xnewline();
				xtext_admin ('<font color="'.$ax_tx_color_qe.'">'.xhtml_text ($arr_x_fields_hint[$i], 'n', '').'</font>');
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$axl_altx_color");
				//'my_form['.$arr_x_fields[$i].']' - simple varname
				//'my_form['.$arr_x_fields[$i].'][]' - multiple varname
				//$arr_my_table_data[$i] - simple var value
				//htmlspecialchars($arr_my_table_data[$i]) - special var value
				eval (' '."\n"."$arr_x_fields_form[$i]".' '."\n");
			xtable_column_end ();
		xtable_row_end ();
		} //end if

		} //end for


		xtable_row_start ();
			xtable_column_start_vcenter ('2', '', "$ax_tx_color");
				xcenter_start();
				if ($yaxe == 'upd') {
					xform_send_bttn ('Update Record');
				} //end if
				else {
					xform_send_bttn ('Insert New Record');
				} //end else
				xcenter_end();
			xtable_column_end ();
		xtable_row_end ();

	xtable_end();

	xform_end ();



} //END FUNCTION



//################################################# INPUT FREE QUERRY


function xshow_querry_free ($yqqq) {


//-----------------globals general
global	$arr_var_result, $arr_var_fields, $var_result_size, $xmy_wr_ok_msg, $xmy_wr_aff_msg, $warp_numform_decimal_sep, $warp_numform_thousand_sep ;

//-----------------ax lib globals
global	$ax_website_addr, $ax_picts_dir, $ax_txt_lnk_color, $ax_bg_color, $ax_th_color, $ax_td_color, $ax_td_color_alt, $ax_tx_color,
$ax_tx_color_err, $ax_tx_color_sp, $ax_tx_color_qe ;

//---------------- internal
global	$d, $op, $xid, $offset, $qval, $q_url, $qqq;

//---------------- auth
global	$PHP_AUTH_USER, $PHP_AUTH_PW ;



	xform_start ('xfree_form', "$ax_website_addr".'ax_main.php');

	xform_hidden ('d', $d);
	xform_hidden ('op', 'freex');
	xform_hidden ('offset', $offset);
	xform_hidden ('qval', $q_url);

	xtable_start_brd('750');

		xtable_row_start ();
			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xtext_title_admin (xhtml_text ('FREE Query : ', 'n', ''));
			xtable_column_end ();
		xtable_row_end ();

		xtable_row_start ();
			$hmy_warn_txt_f_full = 'Running an undocumented query on warp.cms database can lead to severe damages on warp tables that will can not be restored.';
			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xtext_admin ('<font color="'.$ax_tx_color_sp.'">'.'<b>Warning : </b>'.xhtml_text ($hmy_warn_txt_f_full, 'n', '').'</font>');
			xtable_column_end ();
		xtable_row_end ();

		xtable_row_start ();
			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xcenter_start();
					xnewline();
					xform_text_area ('qqq', '60', '10', htmlspecialchars($yqqq));
					xnewline();
					xnewline();
					xform_send_bttn ('Run Query');
				xcenter_end();
			xtable_column_end ();
		xtable_row_end ();

	xtable_end();

	xform_end();


} //END FUNCTION


//################################################# RUN UTIL QUERRY


function xshow_querry_util ($yquerry) {


//-----------------globals general
global	$arr_var_result, $arr_var_fields, $var_result_size, $xmy_wr_ok_msg, $xmy_wr_aff_msg, $warp_numform_decimal_sep, $warp_numform_thousand_sep ;

//-----------------ax lib globals
global	$ax_website_addr, $ax_picts_dir, $ax_txt_lnk_color, $ax_bg_color, $ax_th_color, $ax_td_color, $ax_td_color_alt, $ax_tx_color,
$ax_tx_color_err, $ax_tx_color_sp, $ax_tx_color_qe ;

//---------------- internal
global	$d, $op, $xid, $offset, $qval, $q_url;

//---------------- auth
global	$PHP_AUTH_USER, $PHP_AUTH_PW ;


	//get rights
	$wxu = $PHP_AUTH_USER ;
	$wxp = MD5($PHP_AUTH_PW) ;
	xmysql_read_data_ax ("SELECT id, x_full FROM admins WHERE ( (name='$wxu') AND (pass='$wxp') )");
	$ylocal_ax_adm_r_full = $arr_var_result[1];

if ($ylocal_ax_adm_r_full == 'y') {

	xmysql_read_data_ax ($yquerry);
	//$arr_var_result
	//$arr_var_fields

	xtable_start_brd('');

		xtable_row_start ();
			xtable_column_start_vcenter (count($arr_var_fields), '', "$ax_tx_color");
				if (strlen($yquerry) > '5000') {
					xtext_admin ('<font color="'.$ax_tx_color_qe.'"><b>&nbsp;Query :</b>'.xhtml_text (substr($yquerry, 0, 5000).' ...', 'n', '').'</font>');
				} //end if
				else {
					xtext_admin ('<font color="'.$ax_tx_color_qe.'"><b>&nbsp;Query :</b>'.xhtml_text (substr($yquerry, 0, 5000), 'n', '').'</font>');
				} //end else
			xtable_column_end ();
		xtable_row_end ();


		if (count($arr_var_fields) <= '0') {
		$xmy_zrows_aff = @mysql_affected_rows();
		xtable_row_start ();
			xtable_column_start_vcenter (count($arr_var_fields), '', "$ax_tx_color");
				xtext_admin ('<font color="'.$ax_tx_color_sp.'"><b>&nbsp;MySQL Rows Affected : '.$xmy_zrows_aff.'</b>'.'</font>');
			xtable_column_end ();
		xtable_row_end ();
		} //end if


		xtable_row_start ();
			for ($i=0; $i<count($arr_var_fields); $i++) {
			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xtext_admin ('<b>'.xhtml_text ($arr_var_fields[$i], 'n', 'c').'</b>');
			xtable_column_end ();
			} //end for
		xtable_row_end ();


		$axl_i_alt = 0;
		for ($i=0; $i<count($arr_var_result); $i++) {

			$axl_i_alt = $axl_i_alt + 1;
			//------------------
			//alternate
			if( $axl_i_alt % 2 ) {
				$axl_altx_color = $ax_td_color;
			} //end if
			else {
				$axl_altx_color = $ax_td_color_alt;
			} //end else
			//------------------

			xtable_row_start ();
			for ($ii=0; $ii<count($arr_var_fields); $ii++) {
				$iii = $i + $ii;
				xtable_column_start_vcenter ('1', '', "$axl_altx_color");
					xtext_admin (xhtml_text ($arr_var_result[$iii], 'n', ''));
				xtable_column_end ();
			} //end for
			xtable_row_end ();
			$i = $i + count($arr_var_fields) - 1;
		} //end for

	xtable_end();

} //end if
else {

	xtable_start_brd('750');

		xtable_row_start ();
			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xtext_admin ('<font color="'.$ax_tx_color_qe.'"><b>&nbsp;Query :</b>'.xhtml_text ($yquerry, 'n', '').'</font>');
			xtable_column_end ();
		xtable_row_end ();

		xtable_row_start ();
			$hmy_warn_txt_f_full = 'You have not enough ADMINISTRATIVE PRIVILEGES in order to complete this operation. Operation FAILED !';
			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xtext_admin ('<font color="'.$ax_tx_color_sp.'"><b>&nbsp;'.xhtml_text ($hmy_warn_txt_f_full, 'n', '').'</b></font>');
			xtable_column_end ();
		xtable_row_end ();

	xtable_end();

} //end else

} //END FUNCTION



//################################################# TABLE EMPTY


function xshow_db_empty () {


//-----------------globals general
global	$arr_var_result, $arr_var_fields, $var_result_size, $xmy_wr_ok_msg, $xmy_wr_aff_msg, $warp_numform_decimal_sep, $warp_numform_thousand_sep ;

//-----------------ax lib globals
global	$ax_website_addr, $ax_picts_dir, $ax_txt_lnk_color, $ax_bg_color, $ax_th_color, $ax_td_color, $ax_td_color_alt, $ax_tx_color,
$ax_tx_color_err, $ax_tx_color_sp, $ax_tx_color_qe ;

//---------------- internal
global	$d, $op, $xid, $offset, $qval, $q_url;

//---------------- auth
global	$PHP_AUTH_USER, $PHP_AUTH_PW ;



	xform_start ('bckp_form', "$ax_website_addr".'ax_op.php');

	xform_hidden ('d', $d);
	xform_hidden ('op', 'empty');
	xform_hidden ('offset', $offset);
	xform_hidden ('qval', $q_url);
	xform_hidden ('wxu', MD5($PHP_AUTH_USER));
	xform_hidden ('wxp', MD5(MD5($PHP_AUTH_PW)));


	xtable_start_brd('550');

		xtable_row_start ();
			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xtext_title_admin (xhtml_text ('Empty - Table : '.$d, 'n', ''));
			xtable_column_end ();
		xtable_row_end ();

		xtable_row_start ();
			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xtext_admin_error('<b>Warning :</b> When a table is emptied all the data is lost (all the records are deleted and the key index is reset). Some tables have also related information with other tables. There are also tables that must not be emptied else the administration module or the website can become un-operational. Check the documentation for more details.');
				xcenter_start();
					xnewline();
					xform_send_bttn ('Empty');
				xcenter_end();
				xnewline();
			xtable_column_end ();
		xtable_row_end ();

	xtable_end();

	xform_end();

} //END FUNCTION




//################################################# DB BACKUP


function xshow_db_backup () {


//-----------------globals general
global	$arr_var_result, $arr_var_fields, $var_result_size, $xmy_wr_ok_msg, $xmy_wr_aff_msg, $warp_numform_decimal_sep, $warp_numform_thousand_sep ;

//-----------------ax lib globals
global	$ax_website_addr, $ax_picts_dir, $ax_txt_lnk_color, $ax_bg_color, $ax_th_color, $ax_td_color, $ax_td_color_alt, $ax_tx_color,
$ax_tx_color_err, $ax_tx_color_sp, $ax_tx_color_qe ;

//---------------- internal
global	$d, $op, $xid, $offset, $qval, $q_url;

//---------------- auth
global	$PHP_AUTH_USER, $PHP_AUTH_PW, $dbname, $ax_backup_sql_dir ;


	xform_start ('bckp_form', "$ax_website_addr".'ax_op.php');

	xform_hidden ('d', $d);
	xform_hidden ('op', 'bkp');
	xform_hidden ('offset', $offset);
	xform_hidden ('qval', $q_url);
	xform_hidden ('wxu', MD5($PHP_AUTH_USER));
	xform_hidden ('wxp', MD5(MD5($PHP_AUTH_PW)));


	xtable_start_brd('550');

		xtable_row_start ();
			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xtext_title_admin (xhtml_text ('Backup - Database : '.$dbname, 'n', ''));
			xtable_column_end ();
		xtable_row_end ();

		xtable_row_start ();
			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xtext_admin_error('<b>Warning :</b> The backup operation will save a SQL file to in the backup folder <b>`'.$ax_backup_sql_dir.'`</b> under warp.cms. To complete this operation the backup folder must have write permissions.');
				xcenter_start();
					xnewline();
					xform_send_bttn ('Backup');
				xcenter_end();
				xnewline();
			xtable_column_end ();
		xtable_row_end ();

	xtable_end();

	xform_end();

} //END FUNCTION


//################################################# DB RESTORE


function xshow_db_restore () {


//-----------------globals general
global	$arr_var_result, $arr_var_fields, $var_result_size, $xmy_wr_ok_msg, $xmy_wr_aff_msg, $warp_numform_decimal_sep, $warp_numform_thousand_sep ;

//-----------------ax lib globals
global	$ax_website_addr, $ax_picts_dir, $ax_txt_lnk_color, $ax_bg_color, $ax_th_color, $ax_td_color, $ax_td_color_alt, $ax_tx_color,
$ax_tx_color_err, $ax_tx_color_sp, $ax_tx_color_qe, $ax_backup_sql_dir ;

//---------------- internal
global	$d, $op, $xid, $offset, $qval, $q_url, $qqq;

//---------------- auth
global	$PHP_AUTH_USER, $PHP_AUTH_PW, $dbname ;



	xform_start ('restore_form', "$ax_website_addr".'ax_main.php');

	xform_hidden ('d', $d);
	xform_hidden ('op', 'restorex');
	xform_hidden ('offset', $offset);
	xform_hidden ('qval', $q_url);

	xtable_start_brd('750');

		xtable_row_start ();
			xtable_column_start_vcenter ('4', '', "$ax_tx_color");
				xtext_title_admin (xhtml_text ('Restore - Database : '.$dbname, 'n', ''));
			xtable_column_end ();
		xtable_row_end ();

		xtable_row_start ();
			$hmy_warn_txt_f_full = 'To complete this operation, a valid warp backup file is needed. The warp backup file follows three steps (drop all warp tables from the database (if any) ; recreate the tables structure ; insert data into tables if any). If other backup files are used the results can become unpredictable.';
			xtable_column_start_vcenter ('4', '', "$ax_tx_color");
				xtext_admin ('<font color="'.$ax_tx_color_sp.'">'.'<b>Warning : </b>'.xhtml_text ($hmy_warn_txt_f_full, 'n', '').'</font>');
				xnewline();
				xtext_admin ('<font color="'.$ax_tx_color_qe.'">'.'<b>Info : </b>'.xhtml_text('The backup file must be placed under `'.$ax_backup_sql_dir.'` folder. Choose a backup file from the listed files under the `'.$ax_backup_sql_dir.'` folder :', 'n', '').'</font>');
			xtable_column_end ();
		xtable_row_end ();

clearstatcache();

if ($handle = opendir($ax_backup_sql_dir)) {
	while (false !== ($file = readdir($handle))) { 
		if ( ($file != ".") AND ($file != "..") AND (is_file($ax_backup_sql_dir.'/'.$file)) AND (substr($file, -4, 4) == '.sql') AND (stristr($file, 'warp_backup')) ) {

		xtable_row_start ();
			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xcenter_right_start();
					xform_radio_bttn ('qqq', $file);
					echo('&nbsp;');
				xcenter_end();
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xtext_admin ('&nbsp;<b>'."$file".'</b>&nbsp;');
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xtext_admin ('&nbsp;'.number_format((filesize($ax_backup_sql_dir.'/'.$file)/1024), 1, $warp_numform_decimal_sep, $warp_numform_thousand_sep).' kb'.'&nbsp;');
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xcenter_right_start();
					xtext_admin ('&nbsp;'.date("Y-m-d H:i:s", filemtime($ax_backup_sql_dir.'/'.$file)).'&nbsp;');
				xcenter_end();
			xtable_column_end ();
		xtable_row_end ();

		} //end if
	} //end while
	closedir($handle); 
} //end if

		xtable_row_start ();
			xtable_column_start_vcenter ('4', '', "$ax_tx_color");
				xcenter_start();
					xnewline();
					xform_send_bttn ('Restore');
				xcenter_end();
			xtable_column_end ();
		xtable_row_end ();


	xtable_end();

	xform_end();


} //END FUNCTION


//################################################# DB RESTORE OP


function xshow_db_restore_xdo ($y_bk_file) {


//-----------------globals general
global	$arr_var_result, $arr_var_fields, $var_result_size, $xmy_wr_ok_msg, $xmy_wr_aff_msg, $warp_numform_decimal_sep, $warp_numform_thousand_sep ;

//-----------------ax lib globals
global	$ax_website_addr, $ax_picts_dir, $ax_txt_lnk_color, $ax_bg_color, $ax_th_color, $ax_td_color, $ax_td_color_alt, $ax_tx_color,
$ax_tx_color_err, $ax_tx_color_sp, $ax_tx_color_qe ;

//---------------- internal
global	$d, $op, $xid, $offset, $qval, $q_url;

//---------------- auth
global	$PHP_AUTH_USER, $PHP_AUTH_PW ;

global	$ax_backup_sql_dir, $dbname ;


	//get rights
	$wxu = $PHP_AUTH_USER ;
	$wxp = MD5($PHP_AUTH_PW) ;
	xmysql_read_data_ax ("SELECT id, x_full FROM admins WHERE ( (name='$wxu') AND (pass='$wxp') )");
	$ylocal_ax_adm_r_full = $arr_var_result[1];

if ($ylocal_ax_adm_r_full == 'y') {

	if (!empty($y_bk_file)) {
		$fax_restorex_fd = fopen ($ax_backup_sql_dir.'/'.$y_bk_file, "r");
		$fax_restorex_content = fread ($fax_restorex_fd, filesize ($ax_backup_sql_dir.'/'.$y_bk_file));
		if (stristr($fax_restorex_content, '[@hide@address.com@hide@address.com@hide@address.com@hide@address.com@hide@address.com@database:'.$dbname.'%w%a%r%p%.%c%m%s%v%1.2%]')) {
			$fax_restorex_content_arr = array();
			$fax_restorex_content_arr = explode(" ;\n", $fax_restorex_content);
			$fax_restorex_content = '';
			for ($xi=0; $xi<count($fax_restorex_content_arr); $xi++) {
				xmysql_write_data_ax ($fax_restorex_content_arr[$xi]);
			} //end for
			xtext_admin_error ('<b>SQL query executed successfully ! ('.$xi.' instructions)</b>');
		} //end if
		else {
			$fax_restorex_content = '';
			xtext_admin_error ('<br>&nbsp;&nbsp;&nbsp;ERROR : Backup file is not valid for database `'.$dbname.'`<br>') ;
		} //end else
		fclose ($fax_restorex_fd);
	} //end if
	else {
		xtext_admin_error ('<b>ERROR : No file has been selected !</b>');
	} //end else
	xnewline();

} //end if
else {

	$hmy_warn_txt_f_full = 'You have not enough ADMINISTRATIVE PRIVILEGES in order to complete this operation. Operation FAILED !';
	xtext_admin ('<font color="'.$ax_tx_color_sp.'"><b>&nbsp;'.xhtml_text ($hmy_warn_txt_f_full, 'n', '').'</b></font>');

} //end else


} //END FUNCTION



//################################################################################################


xshow_title ();
xnewline();


if ($op == 'intro') {
	xcenter_start();
		xshow_list_tables ();
		xnewline();
	xcenter_end();
} //end if


if ($op == 'answer') {
	xcenter_start();
		xtext_admin('<font color="'.$ax_tx_color_sp.'"><b>'.htmlspecialchars($anstxt).'</b></font>');
		xnewline();
		xnewline();
	xcenter_end();
} //end if


if ($op == 'backup') {
	xcenter_start();
		xshow_db_backup ();
		xnewline();
	xcenter_end();
} //end if


if ($op == 'restore') {
	xcenter_start();
		xshow_db_restore ();
		xnewline();
	xcenter_end();
} //end if

if ($op == 'restorex') {
	ini_set(max_execution_time, '900');
	xcenter_start();
		$qqq = rawurldecode($qqq);
		$qqq = stripslashes($qqq);
		xshow_db_restore_xdo ($qqq);
		xnewline();
	xcenter_end();
} //end if


if ($op == 'free') {
	xcenter_start();
		xshow_querry_free ('');
		xnewline();
	xcenter_end();
} //end if


if ($op == 'freex') {
	ini_set(max_execution_time, '900');
	xcenter_start();
		$qqq = rawurldecode($qqq);
		$qqq = stripslashes($qqq);
		xshow_querry_util (" $qqq ");
		xnewline();
	xcenter_end();
} //end if


if ($op == 'list') {
	xshow_tbl_data ($d);
	xnewline();
} //end if


if ($op == 'view') {
	xcenter_start();
		xshow_tbl_view ($d, 'n');
		xnewline();
	xcenter_end();
} //end if


if ($op == 'insert') {
	xcenter_start();
		xshow_tbl_form_ae ($d, 'add');
		xnewline();
	xcenter_end();
} //end if


if ($op == 'edit') {
	xcenter_start();
		xshow_tbl_form_ae ($d, 'upd');
		xnewline();
	xcenter_end();
} //end if


if ($op == 'delete') {
	xcenter_start();
		xshow_tbl_view ($d, 'y');
		xnewline();
	xcenter_end();
} //end if


if ($op == 'empty') {
	xcenter_start();
		xshow_db_empty ();
		xnewline();
	xcenter_end();
} //end if


if ($op == 'status') {
	xcenter_start();
		xshow_tbl_status ($d);
		xnewline();
		xshow_tbl_keys ($d);
		xnewline();
		xshow_tbl_properties ($d);
		xnewline();
	xcenter_end();
} //end if


if ($op == 'optimize') {
	xcenter_start();
		xshow_querry_util (" OPTIMIZE TABLE $d ");
		xnewline();
	xcenter_end();
} //end if


if ($op == 'check') {
	xcenter_start();
		xshow_querry_util (" CHECK TABLE $d ");
		xnewline();
	xcenter_end();
} //end if


if ($op == 'repair') {
	xcenter_start();
		xshow_querry_util (" REPAIR TABLE $d ");
		xnewline();
	xcenter_end();
} //end if



xhr_line ('100%');
xnewline();


//---------------------------------------------------------page footer
xfooter ();
//---------------------------------------------------------

// end of php code
?>
Return current item: Warp.cms - php/mysql content management