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

// [main functions library 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


//#################### extra
	// warp_picts_dir/liner.gif [alias var]
	// warp_picts_dir/pix.gif
//##########################


if (empty($yfilename)) {
	$yfilename = 'lib_main.php';
} //end if


require("config.php");



//--------------------------------------------------------TABLES [HTML]

function xtable_start ($ysize) {
	echo("<table width=\"$ysize\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n");
} //end function

function xtable_start_sp ($ysize) {
	echo("<table width=\"$ysize\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\">\n");
} //end function

function xtable_start_brd ($ysize) {
	echo("<table width=\"$ysize\" border=\"1\" cellspacing=\"0\" cellpadding=\"4\">\n");
} //end function

function xtable_end () {
	echo ("</table>\n");
} //end function


function xtable_row_start () {
	echo ("<tr>\n");
} //end function


function xtable_row_end () {
	echo ("</tr>\n");
} //end function


function xtable_column_start ($ycolsize, $ywidth, $ycolor) {
	echo ("<td colspan=\"$ycolsize\" width=\"$ywidth\" bgcolor=\"$ycolor\" valign=\"top\">\n");
} //end function


function xtable_column_start_vcenter ($ycolsize, $ywidth, $ycolor) {
	echo ("<td colspan=\"$ycolsize\" width=\"$ywidth\" bgcolor=\"$ycolor\" valign=\"center\">\n");
} //end function


function xtable_column_start_vbottom ($ycolsize, $ywidth, $ycolor) {
	echo ("<td colspan=\"$ycolsize\" width=\"$ywidth\" bgcolor=\"$ycolor\" valign=\"bottom\">\n");
} //end function


function xtable_column_end () {
	echo ("</td>\n");
} //end function



//--------------------------------------------------------SPACE, NEWLINE, HR [HTML]

function xspace () {
	echo ("&nbsp;\n");
} //end function


function xnewline () {
	echo ("<br>");
} //end function

function xhr_line ($ysize) {
	echo ("<hr width=\"$ysize\" size=\"1\" align=\"center\" noshade>\n");
} //end function


//--------------------------------------------------------TEXT, PICTURES [HTML]


//website text

function xtext_simple ($ytext) {
	global	$ysite_the_text_color ;
	echo ("<font face=\"Verdana, Tahoma, Arial, sans-serif\" size=\"2\" color=\"$ysite_the_text_color\">$ytext</font>");
} //end function


function xtext_title ($ytext) {
	global	$ybig_text_color ;
	echo ("<font face=\"Verdana, Tahoma, Arial, sans-serif\" size=\"2\" color=\"$ybig_text_color\"><b>$ytext</b></font>");
} //end function


function xtext_small ($ytext) {
	global	$ysmall_text_color ;
	echo ("<font face=\"Verdana, Tahoma, Arial, sans-serif\" size=\"1\" color=\"$ysmall_text_color\">$ytext</font>");
} //end function


//internal text

function xtext_error ($ytext) {
	global	$y_err_text_color ;
	echo ("<font face=\"Verdana, Tahoma, Arial, sans-serif\" size=\"2\" color=\"$y_err_text_color\">$ytext</font>");
} //end function


function xtext_print ($ytext) {
	echo ("<font face=\"Verdana, Tahoma, Arial, sans-serif\" size=\"1\" color=\"#000000\">$ytext</font>");
} //end function


//--------------------------------------------------------PICTURES [HTML]


function xpict ($ypict, $ywidth, $yheight) {
	echo ("<img src=\"$ypict\" width=\"$ywidth\" height=\"$yheight\" border=\"0\">");
} //end function


function xpict_alt ($ypict, $ywidth, $yheight, $ypictalt) {
	echo ("<img src=\"$ypict\" width=\"$ywidth\" height=\"$yheight\" border=\"0\" alt=\"$ypictalt\">");
} //end function


function xpict_border ($ypict, $ywidth, $yheight) {
	echo ("<img src=\"$ypict\" width=\"$ywidth\" height=\"$yheight\" border=\"1\">");
} //end function


//--------------------------------------------------------LINKS [HTML]

function xtext_link ($ytext, $ylink, $ytarget) {
	global	$ysmall_links_color ;
	echo ("&nbsp;<a href=\"$ylink\" target=\"$ytarget\"><font face=\"Verdana, Tahoma, Arial, sans-serif\" size=\"1\" color=\"$ysmall_links_color\">&middot;&middot;$ytext</font></a>&nbsp;");
} //end function


function xpict_link ($ypict, $ypictalt, $ywidth, $yheight, $ylink, $ytarget) {
	echo ("<a href=\"$ylink\" target=\"$ytarget\"><img src=\"$ypict\" width=\"$ywidth\" height=\"$yheight\" border=\"0\" alt=\"$ypictalt\"></a>");
} //end function


function xpict_link_border ($ypict, $ypictalt, $ywidth, $yheight, $ylink, $ytarget) {
	echo ("<a href=\"$ylink\" target=\"$ytarget\"><img src=\"$ypict\" width=\"$ywidth\" height=\"$yheight\" border=\"1\" alt=\"$ypictalt\"></a>");
} //end function


//--------------------------------------------------------ALIGN [HTML]

function xcenter_start () {
	echo ("<div align=\"center\">");
} //end function


function xcenter_right_start () {
	echo ("<div align=\"right\">");
} //end function


function xcenter_end () {
	echo ("</div>\n");
} //end function



//--------------------------------------------------------FLASH OBJECT [HTML]

function xwriteflash_bg ($ymovie, $ywidth, $yheight, $ybgcolor) {

	echo ("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://active.macromedia.com/flash6/cabs/swflash.cab#version=6,0,0,0\" width=\"$ywidth\" height=\"$yheight\">\n");
	echo ("<param name=\"movie\" value=\"$ymovie\">\n");
	echo ("<param name=\"quality\" value=\"high\">\n");
	echo ("<param name=\"bgcolor\" value=\"$ybgcolor\">\n");
	echo ("<param name=\"menu\" value=\"false\">\n");
	echo ("<embed src=\"$ymovie\" quality=\"high\" bgcolor=\"$ybgcolor\" width=\"$ywidth\" height=\"$yheight\" menu=\"false\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\">");
	echo ("</embed>\n");
	echo ("</object>\n");
} //end function


function xwriteflash_nobg ($ymovie, $ywidth, $yheight) {
	echo ("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://active.macromedia.com/flash6/cabs/swflash.cab#version=6,0,0,0\" width=\"$ywidth\" height=\"$yheight\">\n");
	echo ("<param name=\"movie\" value=\"$ymovie\">\n");
	echo ("<param name=\"quality\" value=\"high\">\n");
	echo ("<param name=\"menu\" value=\"false\">\n");
	echo ("<embed src=\"$ymovie\" quality=\"high\" width=\"$ywidth\" height=\"$yheight\" menu=\"false\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\">");
	echo ("</embed>\n");
	echo ("</object>\n");
} //end function


function xwriteflash_bg_var ($ymovie, $yvars, $ywidth, $yheight, $ybgcolor) {

	echo ("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://active.macromedia.com/flash6/cabs/swflash.cab#version=6,0,0,0\" width=\"$ywidth\" height=\"$yheight\">\n");
	echo ("<param name=\"movie\" value=\"$ymovie\">\n");
	echo ("<param name=\"flashvars\" value=\"$yvars\">\n");
	echo ("<param name=\"quality\" value=\"high\">\n");
	echo ("<param name=\"bgcolor\" value=\"$ybgcolor\">\n");
	echo ("<param name=\"menu\" value=\"false\">\n");
	echo ("<embed src=\"$ymovie\" flashvars=\"$yvars\" quality=\"high\" bgcolor=\"$ybgcolor\" width=\"$ywidth\" height=\"$yheight\" menu=\"false\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\">");
	echo ("</embed>\n");
	echo ("</object>\n");
} //end function


function xwriteflash_nobg_var ($ymovie, $yvars, $ywidth, $yheight) {
	echo ("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://active.macromedia.com/flash6/cabs/swflash.cab#version=6,0,0,0\" width=\"$ywidth\" height=\"$yheight\">\n");
	echo ("<param name=\"movie\" value=\"$ymovie\">\n");
	echo ("<param name=\"flashvars\" value=\"$yvars\">\n");
	echo ("<param name=\"quality\" value=\"high\">\n");
	echo ("<param name=\"menu\" value=\"false\">\n");
	echo ("<embed src=\"$ymovie\" flashvars=\"$yvars\" quality=\"high\" width=\"$ywidth\" height=\"$yheight\" menu=\"false\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\">");
	echo ("</embed>\n");
	echo ("</object>\n");
} //end function


//--------------------------------------------------------FORMS [HTML]

function xform_start ($yfrm_name, $yfile) {
	echo ("<form name=\"$yfrm_name\" method=\"post\" action=\"$yfile\">\n");
} //end function


function xform_start_enc ($yfrm_name, $yfile) {
	echo ("<form name=\"$yfrm_name\" method=\"post\" action=\"$yfile\" enctype=\"multipart/form-data\">\n");
} //end function


function xform_start_get ($yfrm_name, $yfile) {
	echo ("<form name=\"$yfrm_name\" method=\"get\" action=\"$yfile\">\n");
} //end function


function xform_end () {
	echo ("</form>");
} //end function


function xform_send_bttn ($y_label) {
	echo ("<input type=\"submit\" name=\"submit\" value=\"$y_label\">");
} //end function


function xform_reset_bttn ($y_label) {
	echo ("<input type=\"reset\" name=\"reset\" value=\"$y_label\">");
} //end function


function xform_file_field ($y_var, $ysize) {
	// !! require multi-part form (enc)
	echo ("<input name=\"$y_var\" type=\"file\" size=\"$ysize\" maxlength=\"255\">");
} //end function


function xform_text_box ($y_var, $y_var_len, $ysize, $yvalue) {
	echo ("<input type=\"text\" name=\"$y_var\" maxlength=\"$y_var_len\" size=\"$ysize\" value=\"$yvalue\">\n");
} //end function


function xform_passw_box ($y_var, $y_var_len, $ysize, $yvalue) {
	echo ("<input type=\"password\" name=\"$y_var\" maxlength=\"$y_var_len\" size=\"$ysize\" value=\"$yvalue\">\n");
} //end function


function xform_text_area ($y_var, $ysize_h, $ysize_v, $yvalue) {
	echo ("<textarea name=\"$y_var\" cols=\"$ysize_h\" rows=\"$ysize_v\">$yvalue</textarea>\n");
} //end function


function xform_hidden ($y_var, $y_var_value) {
	echo ("<input type=\"hidden\" name=\"$y_var\" value=\"$y_var_value\">\n");
} //end function


function xform_list_start ($y_var) {
	echo ("<select name=\"$y_var\" size=\"1\">\n");
} //end function


function xform_list_multi_start ($y_var) {
	//var[] type !!!
	echo ("<select name=\"$y_var\" size=\"10\" multiple>\n");
} //end function


function xform_list_end () {
	echo ("</select>\n");
} //end function


function xform_list_value ($y_valname, $y_value) {
	echo ("<option value=\"$y_value\">$y_valname</option>\n");
} //end function


function xform_list_value_sel ($y_valname, $y_value) {
	echo ("<option value=\"$y_value\" selected>$y_valname</option>\n");
} //end function


function xform_radio_bttn ($y_valname, $y_value) {
	echo ("<input type=\"radio\" name=\"$y_valname\" value=\"$y_value\">\n");
} //end function

function xform_radio_bttn_chk ($y_valname, $y_value) {
	echo ("<input type=\"radio\" name=\"$y_valname\" value=\"$y_value\" checked>\n");
} //end function


function xform_check_box ($y_valname, $y_value) {
	echo ("<input type=\"checkbox\" name=\"$y_valname\" value=\"$y_value\">\n");
} //end function


//--------------------------------------------------------ADMIN PARTICULAR [HTML]


$ax_website_addr = $ywebsite_addr ;
$ax_picts_dir = 'warp_admin/picts';
$ax_backup_sql_dir = 'warp_admin/sql_backup';
$ax_content_dir = 'warp_content';
$ax_txt_lnk_color = '#000000';
$ax_tx_color = '#FFFFFF';
$ax_tx_color_err = '#FF0000';
$ax_tx_color_sp = '#FF0000';
$ax_tx_color_qe = '#003366';
$ax_bg_color = '#D8DDBF';
$ax_th_color = '#E1E4CE';
$ax_td_color = '#F6F7FB';
$ax_td_color_alt = '#E1E4CE';


function xtext_admin ($ytext) {
	global	$ax_txt_lnk_color ;
	echo ("<font face=\"Courier New, Courier, mono\" size=\"2\" color=\"$ax_txt_lnk_color\">$ytext</font>");
} //end function


function xtext_admin_error ($ytext) {
	global	$ax_tx_color_err ;
	echo ("<font face=\"Courier New, Courier, mono\" size=\"2\" color=\"$ax_tx_color_err\">$ytext</font>");
} //end function


function xtext_title_admin ($ytext) {
	global	$ax_txt_lnk_color;
	echo ("<font face=\"Courier New, Courier, mono\" size=\"4\" color=\"$ax_txt_lnk_color\"><b>$ytext</b></font>");
} //end function


function xtext_link_admin ($ytext, $ylink, $ytarget) {
	global	$ax_txt_lnk_color;
	echo ("&nbsp;<a href=\"$ylink\" target=\"$ytarget\"><font face=\"Courier New, Courier, mono\" size=\"2\" color=\"$ax_txt_lnk_color\">$ytext</font></a>&nbsp;");
} //end function


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

function xhtml_text ($ytext, $ycut, $yalign) {
	if ( (strlen($ytext) > '50') AND ($ycut == 'y') ) {
		$ytext = substr($ytext, 0, 50).'...';
	} //end if
	$ytext = htmlspecialchars($ytext);
	$ytext = '&nbsp;'.$ytext.'&nbsp;';
	switch ($yalign) {
		case 'c':
			$ytext = "<div align=\"center\">".$ytext."</div>\n" ;
			break;
		case 'r':
			$ytext = "<div align=\"right\">".$ytext."</div>\n" ;
			break;
		case 'l':
			$ytext = "<div align=\"left\">".$ytext."</div>\n" ;
			break;
		default :
			$ytext = $ytext ;
	} //end switch
	return $ytext;
} //end function


//--------------------------------------------------------WEBSITE PARTICULAR - VLINE, PIX [HTML]


function xvline ($ywidth) {
	global $y_warp_picts_dir, $ywarp_hz_liner;

	$y_pictx = "$y_warp_picts_dir"."/"."$ywarp_hz_liner";

	echo ("\n<img src=\"$y_pictx\" width=\"$ywidth\" height=\"1\">\n");
} //end function


function xvpix ($ywidth) {
	global $y_warp_picts_dir;

	$y_pictx = "$y_warp_picts_dir"."/"."pix.gif";

	echo ("<img src=\"$y_pictx\" width=\"$ywidth\" height=\"1\">\n");
} //end function

function xvpix_h ($yheight) {
	global $y_warp_picts_dir;

	$y_pictx = "$y_warp_picts_dir"."/"."pix.gif";

	echo ("<img src=\"$y_pictx\" width=\"1\" height=\"$yheight\">");
} //end function




//--------------------------------------------------------HEADER, FOOTER, SECURE [HTML]

function xheader_warp ($ytitle, $xheadtyp, $yshowmeta) {

	global 	$ysite_back_color, $ysite_the_text_color, $ysite_the_links_color,
		$ax_txt_lnk_color, $ax_bg_color;

	global 	$y_warp_xdate, $y_warp_xtime ;

	global	$warp_meta_author, $warp_meta_copyright, $warp_meta_keywords, $warp_meta_description ;

	if ($xheadtyp == 'adm') {
		$hh_bg_color = $ax_bg_color ;
		$hh_txt_color = $ax_txt_lnk_color;
		$hh_lnk_color = $ax_txt_lnk_color;
	} //end if
	else {
		$hh_bg_color = $ysite_back_color ;
		$hh_txt_color = $ysite_the_text_color;
		$hh_lnk_color = $ysite_the_links_color;
	} //end if

	echo ("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n");
	echo ("<!--:: xantis.warp.cms :: Xantis Warp - Content Management Server - v.1.2 :: ".$y_warp_xdate." :: ".$y_warp_xtime." :: -->\n");
	echo ("<html>\n");
	echo ("<head>\n");
	echo ("<title>$ytitle</title>\n");
	echo ("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n");
	echo ("<meta http-equiv=\"expires\" content=\"1\">\n");
	echo ("<meta http-equiv=\"pragma\" content=\"no-cache\">\n");
	echo ("<meta http-equiv=\"cache-control\" content=\"private\">\n");
	if ($yshowmeta == 'y') {
		echo ("<meta name=\"resource-type\" content=\"document\">\n");
		echo ("<meta name=\"author\" content=\"$warp_meta_author\">\n");
		echo ("<meta name=\"copyright\" content=\"$warp_meta_copyright\">\n");
		echo ("<meta name=\"KEYWORDS\" content=\"$warp_meta_keywords\">\n");
		echo ("<meta name=\"DESCRIPTION\" content=\"$warp_meta_description\">\n");
		echo ("<meta name=\"ROBOTS\" content=\"INDEX,FOLLOW\">\n");
		echo ("<meta name=\"REVISIT-AFTER\" content=\"1 DAYS\">\n");
		echo ("<meta name=\"RATING\" content=\"GENERAL\">\n");
		echo ("<meta name=\"GENERATOR\" content=\"xantis.warp.cms\">\n");
	} //end if
	echo ("</head>\n");
	echo ("<body bgcolor=\"$hh_bg_color\" text=\"$hh_txt_color\" link=\"$hh_lnk_color\" vlink=\"$hh_lnk_color\" alink=\"$hh_lnk_color\" leftmargin=\"10\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\">\n");
	echo ("<!-- start page content -->\n\n");

} //end function


function xfooter () {
	echo ("\n\n<!-- end page content -->\n");
	echo ("</body>\n</html>\n");
} //end function


function xhead_err_msg ($yshow_lnks) {

	global 	$warp_user_can_register, $warp_user_new_register_txt, $warp_user_forget_passw, $ybar_color, 
		$warp_registrat_fail, $warp_click_here_txt, $ymain_color, $ydisplay_width, $ywebsite_addr,
		$y_warp_back_text_x, $warp_user_admin_contact, $ywebsite_name ;

	global 	$wpsid;


	//-----------------------
	xheader_warp ("$ywebsite_name".' - '."$warp_registrat_fail", '', 'y');
	//-----------------------


	if ($yshow_lnks <> 'xwndz') {
		$yl_usr_fgt_url = "usr_fgt.php?wpsid=$wpsid" ;
	} //end if
	else {
		$yl_usr_fgt_url = "usr_fgt.php?wpsid=$wpsid&wsfgt=x" ;
	} //end else


	xcenter_start ();
	xnewline ();
	xtable_start ("$ydisplay_width");

		xtable_row_start ();
			xtable_column_start ('2', '100%', "$ybar_color");
				xtext_title ("&nbsp;"."$ywebsite_name".' - '."$warp_registrat_fail");
			xtable_column_end ();
		xtable_row_end ();


		xtable_row_start ();
			xtable_column_start_vcenter ('2', '100%', "$ymain_color");
				xvline ("100%");
			xtable_column_end ();
		xtable_row_end ();


		xtable_row_start ();
			xtable_column_start_vcenter ('2', '100%', "$ymain_color");
				xcenter_start ();
					xwriteflash_nobg_var ("flagger.swf",
					"&xaction=".rawurlencode('err').
					"&"
					, '30', '30');
				xcenter_end ();
			xtable_column_end ();
		xtable_row_end ();


		xtable_row_start ();
			xtable_column_start_vcenter ('2', '100%', "$ymain_color");
				xvline ("100%");
			xtable_column_end ();
		xtable_row_end ();


		xtable_row_start ();
			xtable_column_start_vcenter ('1', '25%', "$ymain_color");
				xcenter_right_start ();
					xwriteflash_nobg_var ("flagger.swf",
					"&xaction=".rawurlencode('qst').
					"&"
					, '30', '30');
				xcenter_end ();
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '75%', "$ymain_color");
				xvpix ('10');
				xtext_link ("$warp_user_forget_passw"." "."$warp_click_here_txt", "$ywebsite_addr".$yl_usr_fgt_url, '_self');
			xtable_column_end ();
		xtable_row_end ();

		xtable_row_start ();
			xtable_column_start_vcenter ('2', '100%', "$ymain_color");
				xvline ("100%");
			xtable_column_end ();
		xtable_row_end ();

if ($yshow_lnks <> 'xwndz') {

	if ($warp_user_can_register == 'y') {

		xtable_row_start ();
			xtable_column_start_vcenter ('1', '25%', "$ymain_color");
				xcenter_right_start ();
					xwriteflash_nobg_var ("flagger.swf",
					"&xaction=".rawurlencode('inf').
					"&"
					, '30', '30');
				xcenter_end ();
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '75%', "$ymain_color");
				xvpix ('10');
				xtext_link ("$warp_user_new_register_txt"." "."$warp_click_here_txt", "$ywebsite_addr"."usr_reg.php?wpsid=$wpsid", '_self');
			xtable_column_end ();
		xtable_row_end ();

		xtable_row_start ();
			xtable_column_start_vcenter ('2', '100%', "$ymain_color");
				xvline ("100%");
			xtable_column_end ();
		xtable_row_end ();

	} //end if


		xtable_row_start ();
			xtable_column_start_vcenter ('1', '25%', "$ymain_color");
				xcenter_right_start ();
					xwriteflash_nobg_var ("flagger.swf",
					"&xaction=".rawurlencode('wrn').
					"&"
					, '30', '30');
				xcenter_end ();
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '75%', "$ymain_color");
				xvpix ('10');
				xtext_link ("$warp_user_admin_contact"." "."$warp_click_here_txt", "$ywebsite_addr"."adm_contact.php?wpsid=$wpsid", '_self');
			xtable_column_end ();
		xtable_row_end ();




		xtable_row_start ();
			xtable_column_start_vcenter ('2', '100%', "$ymain_color");
				xvline ("100%");
			xtable_column_end ();
		xtable_row_end ();

		xtable_row_start ();
			xtable_column_start_vcenter ('2', '100%', "$ymain_color");
				xcenter_start ();
					xtext_link ("$y_warp_back_text_x", "$ywebsite_addr"."xw_main.php?wpsid=$wpsid", '_self');
				xcenter_end ();
			xtable_column_end ();
		xtable_row_end ();


		xtable_row_start ();
			xtable_column_start_vcenter ('2', '100%', "$ymain_color");
				xvline ("100%");
			xtable_column_end ();
		xtable_row_end ();

} //end if


	xtable_end ();
	xcenter_end ();

	//-----------------------
	xfooter ();
	//-----------------------

} //end function



function xsecure_header ($yshow_lnks) {

	global $PHP_AUTH_USER;
	global $PHP_AUTH_PW;
	global $ywebsite_name, $warp_authentif_msg;


//---------------------
	$var_auth_check = '';

	// do query
	$WARP_B64_ENC_AUTH_PASSW = base64_encode($PHP_AUTH_PW);
	$result = @mysql_query("SELECT usr_name, usr_pass from users WHERE ( (usr_name='$PHP_AUTH_USER') AND (usr_pass='$WARP_B64_ENC_AUTH_PASSW') ) " );
	$number_of_rows = @mysql_num_rows($result);

	$var_auth_check = $number_of_rows;
     
	//check mysql error
	if (@mysql_errno() <> 0) {
		$xresult = @mysql_error();
		xtext_error ('<br>&nbsp;&nbsp;&nbsp;MySQL ERROR : '.htmlspecialchars($xresult));
		die('');
	} //end if

	@mysql_free_result ($result);

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

	if($var_auth_check != '1') {
		header("WWW-Authenticate: Basic realm=\":: $ywebsite_name :: $warp_authentif_msg \"");
		header("HTTP/1.0 401 Unauthorized");
		xhead_err_msg ($yshow_lnks);
		die("");
	} //end if

} //end function



function xsecure_admin_header () {

	global 	$PHP_AUTH_USER;
	global 	$PHP_AUTH_PW;
	global	$ywebsite_addr ;
	global	$ax_tx_color;

//---------------------
	$var_auth_check = '';

	// do query
	$WARP_ADMIN_AUTH_PASSW = md5($PHP_AUTH_PW);
	$result = @mysql_query("SELECT name, pass from admins WHERE ( (name='$PHP_AUTH_USER') AND (pass='$WARP_ADMIN_AUTH_PASSW') ) " );
	$number_of_rows = @mysql_num_rows($result);

	$var_auth_check = $number_of_rows;
     
	//check mysql error
	if (@mysql_errno() <> 0) {
		$xresult = @mysql_error();
		xtext_error ('<br>&nbsp;&nbsp;&nbsp;MySQL ERROR : '.htmlspecialchars($xresult));
		die('');
	} //end if

	@mysql_free_result ($result);

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

	if($var_auth_check != '1') {
		header("WWW-Authenticate: Basic realm=\":: warp.cms :: Administration Area \"");
		header("HTTP/1.0 401 Unauthorized");

		xheader_warp ($ytitle, 'adm', 'n');
		xnewline();

		xcenter_start ();
			xtable_start ('');
				xtable_row_start ();
					xtable_column_start_vcenter ('1', '40', "$ax_tx_color");
						xspace ();
						xwriteflash_bg_var ("$ywebsite_addr".'flagger.swf',
						"&xaction=".rawurlencode('err').
						"&"
						, '30', '30', "$ax_tx_color");
					xtable_column_end ();

					xtable_column_start_vcenter ('1', '', "$ax_tx_color");
						xtext_admin ('Authorization failed !');
						xspace ();
						xspace ();
					xtable_column_end ();
				xtable_row_end ();
			xtable_end ();
		xcenter_end ();

		echo("\n");
		die("</body>\n</html>\n");
	} //end if

} //end function


function xheader ($ytitle, $ysecure) {

	global $ysite_back_color;

	global $y_warp_xdate, $y_warp_xtime ;

	$yhead_chk = 'xempty';

	if ($ysecure == 'secure') {
		xsecure_header ('');
		xheader_warp ($ytitle, '', 'y');
		$yhead_chk = 'xfull';
	} //end if

	if ($ysecure == 'secure_x') {
		xsecure_header ('xwndz');
		xheader_warp ($ytitle, '', 'y');
		$yhead_chk = 'xfull';
	} //end if

	if ($ysecure == 'admin') {
		xsecure_admin_header ();
		xheader_warp ($ytitle, 'adm', 'n');
		$yhead_chk = 'xfull';
	} //end if

	if ($yhead_chk == 'xempty') {
		xheader_warp ($ytitle, '', 'y');
	} // end if

} //end function



//--------------------------------------------------------MySQL [DATA]


//------------------------- NORMAL

function xmysql_read_data ($queryval) {

	global $arr_var_result;

	// result arr vars
	$arr_var_result = array();

	// def query vars
	//$queryval = "SELECT * FROM tablename WHERE (field='x') ORDER BY field ASC";

	// do query
	$result = @mysql_query($queryval);
	$number_of_rows = @mysql_num_rows($result);
	$number_of_fields = @mysql_num_fields($result);

	//check mysql error
	if (@mysql_errno() == 0) {
		for ($i = 0; $i < $number_of_rows; $i++) {
			$record = @mysql_fetch_row($result);
			for ($ii=0; $ii < $number_of_fields; $ii++) {
				array_push ($arr_var_result , $record[$ii]);
			} // end for
		} //end for
	} //end if
	else {
		$xresult = @mysql_error();
		xtext_error ('<br>&nbsp;&nbsp;&nbsp;MySQL ERROR : '.htmlspecialchars($xresult));
		die('');
	} //end else


	@mysql_free_result ($result);

} //end function


function xmysql_count_data ($queryval) {

	global $var_result_size;

	// result vars
	$var_result_size = '';

	// def query vars
	//$queryval = "SELECT COUNT(*) FROM tablename WHERE (field='x') ORDER BY field ASC";

	// do query
	$result = @mysql_query($queryval);

	//check mysql error
	if (@mysql_errno() == 0) {
		$record = @mysql_fetch_row($result);
		$var_result_size = $record[0];
	} //end if
	else {
		$xresult = @mysql_error();
		xtext_error ('<br>&nbsp;&nbsp;&nbsp;MySQL ERROR : '.htmlspecialchars($xresult));
		die('');
	} //end else

	@mysql_free_result ($result);

} //end function


function xmysql_write_data ($queryval) {

	global $xmy_wr_ok_msg;

	// def query vars
	//$queryval = "UPDATE tablename SET field='value' WHERE (id_field='val1')";
	//$queryval = "INSERT INTO tablename (desiredfield1, desiredfield2) VALUES ('val1', 'val2')";
	//$queryval = "DELETE FROM tablename WHERE (id_field='val1')";

	// do query
	$result = @mysql_query($queryval);
	$xmy_wr_ok_msg = '';


	//check mysql error
	if (@mysql_errno() == 0) {
		$xmy_wr_ok_msg = 'okmysqlwriteoperation';
	} //end if
	else {
		$xresult = @mysql_error();
		xtext_error ('<br>&nbsp;&nbsp;&nbsp;MySQL ERROR : '.htmlspecialchars($xresult));
		die('');
	} //end else


	@mysql_free_result ($result);

} //end function


//------------------------- FLASH

function xmysql_read_data_fl ($queryval) {

	global $arr_var_result;

	// result arr vars
	$arr_var_result = array();

	// def query vars
	//$queryval = "SELECT * FROM tablename WHERE (field='x') ORDER BY field ASC";

	// do query
	$result = @mysql_query($queryval);
	$number_of_rows = @mysql_num_rows($result);
	$number_of_fields = @mysql_num_fields($result);

	//check mysql error
	if (@mysql_errno() == 0) {
		for ($i = 0; $i < $number_of_rows; $i++) {
			$record = @mysql_fetch_row($result);
			for ($ii=0; $ii < $number_of_fields; $ii++) {
				array_push ($arr_var_result , $record[$ii]);
			} // end for
		} //end for
	} //end if
	else {
		$xresult = @mysql_error();

		echo(
		"&xcheck_load_controlvar=".rawurlencode('ok').
		"&xcheck_data_controlvar=".rawurlencode('notok').
		"&flash_form_text_err=".rawurlencode('MySQL ERROR : '.$xresult).
		"&"
		);
		die ('');
	} //end else


	@mysql_free_result ($result);

} //end function


function xmysql_count_data_fl ($queryval) {

	global $var_result_size;

	// result vars
	$var_result_size = '';

	// def query vars
	//$queryval = "SELECT COUNT(*) FROM tablename WHERE (field='x') ORDER BY field ASC";

	// do query
	$result = @mysql_query($queryval);

	//check mysql error
	if (@mysql_errno() == 0) {
		$record = @mysql_fetch_row($result);
		$var_result_size = $record[0];
	} //end if
	else {
		$xresult = @mysql_error();

		echo(
		"&xcheck_load_controlvar=".rawurlencode('ok').
		"&xcheck_data_controlvar=".rawurlencode('notok').
		"&flash_form_text_err=".rawurlencode('MySQL ERROR : '.$xresult).
		"&"
		);
		die ('');
	} //end else

	@mysql_free_result ($result);

} //end function


function xmysql_write_data_fl ($queryval) {

	global $xmy_wr_ok_msg;

	// def query vars
	//$queryval = "UPDATE tablename SET field='value' WHERE (id_field='val1')";
	//$queryval = "INSERT INTO tablename (desiredfield1, desiredfield2) VALUES ('val1', 'val2')";
	//$queryval = "DELETE FROM tablename WHERE (id_field='val1')";

	// do query
	$result = @mysql_query($queryval);
	$xmy_wr_ok_msg = '';


	//check mysql error
	if (@mysql_errno() == 0) {
		$xmy_wr_ok_msg = 'okmysqlwriteoperation';
	} //end if
	else {
		$xresult = @mysql_error();

		echo(
		"&xcheck_load_controlvar=".rawurlencode('ok').
		"&xcheck_data_controlvar=".rawurlencode('notok').
		"&flash_form_text_err=".rawurlencode('MySQL ERROR : '.$xresult).
		"&"
		);
		die ('');
	} //end else


	@mysql_free_result ($result);

} //end function



//================================================= ADMIN

function xmysql_read_data_ax ($queryval) {

	global $arr_var_result;
	global $arr_var_fields;

	// result arr vars
	$arr_var_result = array();
	$arr_var_fields = array();

	// def query vars
	//$queryval = "SELECT * FROM tablename WHERE (field='x') ORDER BY field ASC";

	// do query
	$result = @mysql_query($queryval);
	$number_of_rows = @mysql_num_rows($result);
	$number_of_fields = @mysql_num_fields($result);

	//check mysql error
	if (@mysql_errno() == 0) {
		for ($i=0; $i < $number_of_fields; $i++) {
			$field = @mysql_field_name($result, $i);
			array_push ($arr_var_fields , $field);
		} // end for

		for ($i = 0; $i < $number_of_rows; $i++) {
			$record = @mysql_fetch_row($result);
			for ($ii=0; $ii < $number_of_fields; $ii++) {
				array_push ($arr_var_result , $record[$ii]);
			} // end for
		} //end for
	} //end if
	else {
		$xresult = @mysql_error();
		xtext_admin_error ('<br>&nbsp;&nbsp;&nbsp;MySQL ERROR : '.htmlspecialchars($xresult));
		xtext_admin ('<br>MySQL Query : '.htmlspecialchars($queryval));
		die('');
	} //end else


	@mysql_free_result ($result);

} //end function


function xmysql_count_data_ax ($queryval) {

	global $var_result_size;

	// result vars
	$var_result_size = '';

	// def query vars
	//$queryval = "SELECT COUNT(*) FROM tablename WHERE (field='x') ORDER BY field ASC";

	// do query
	$result = @mysql_query($queryval);

	//check mysql error
	if (@mysql_errno() == 0) {
		$record = @mysql_fetch_row($result);
		$var_result_size = $record[0];
	} //end if
	else {
		$xresult = @mysql_error();
		xtext_admin_error ('<br>&nbsp;&nbsp;&nbsp;MySQL ERROR : '.htmlspecialchars($xresult));
		xtext_admin ('<br>MySQL Query : '.htmlspecialchars($queryval));
		die('');
	} //end else

	@mysql_free_result ($result);

} //end function


function xmysql_write_data_ax ($queryval) {

	global $xmy_wr_ok_msg, $xmy_wr_aff_msg;

	// def query vars
	//$queryval = "UPDATE tablename SET field='value' WHERE (id_field='val1')";
	//$queryval = "INSERT INTO tablename (desiredfield1, desiredfield2) VALUES ('val1', 'val2')";
	//$queryval = "DELETE FROM tablename WHERE (id_field='val1')";

	// do query
	$result = @mysql_query($queryval);
	$xmy_wr_ok_msg = '';
	$xmy_wr_aff_msg = '';


	//check mysql error
	if (@mysql_errno() == 0) {
		$xmy_wr_ok_msg = 'okmysqlwriteoperation';
		$xmy_wr_aff_msg = @mysql_affected_rows();
	} //end if
	else {
		$xresult = @mysql_error();
		xtext_admin_error ('<br>&nbsp;&nbsp;&nbsp;MySQL ERROR : '.htmlspecialchars($xresult));
		xtext_admin ('<br>MySQL Query : '.htmlspecialchars($queryval));
		die('');
	} //end else


	@mysql_free_result ($result);

} //end function


function mysql_read_fields_ax ($table_name) {

	global 	$arr_var_result;

	// result arr vars
	$arr_var_result = array();


	$queryval = " DESCRIBE $table_name " ;
	$result = @mysql_query($queryval);

	// The fields returned from DESCRIBE are: Field, Type, Null, Key, Default, Extra

	//check mysql error
	if (@mysql_errno() == 0) {
		while ($row = @mysql_fetch_array($result, MYSQL_ASSOC)) {
			// Separate type from size. Format is: type(size)
			if (ereg("(.*)\\((.*)\\)", $row["Type"], $ret)) {
				$type = $ret[1];
				$size = $ret[2];
			} //end if
			else {
				$type = $row["Type"];
				$size = "";
			} //end else
			// MySQL sets nullable to "YES" or "", so we need to set "NO"
			$null = $row["Null"];
			if ($null == "") {
				$null = "NO";
			} //end if

			$attributes = '';
			if (eregi('BINARY', $row['Type'])) {
				$attributes = 'BINARY';
			} //end if
			if (eregi('UNSIGNED', $row['Type'])) {
				$attributes = 'UNSIGNED';
			} //end if
			if (eregi('ZEROFILL', $row['Type'])) {
				$attributes = 'ZEROFILL';
			} //end if

			//-----------------build array

			//field
			array_push ($arr_var_result , $row["Field"]);

			//type
			array_push ($arr_var_result , $type);

			//size
			array_push ($arr_var_result , $size);

			//default
			array_push ($arr_var_result , $row["Default"]);

			//null
			array_push ($arr_var_result , $null);

			//key
			array_push ($arr_var_result , $row["Key"]);

			//extra
			array_push ($arr_var_result , $row["Extra"]);

			//attributes
			array_push ($arr_var_result , $attributes);


		} //end while
	} //end if
	else {
		$xresult = @mysql_error();
		xtext_admin_error ('<br>&nbsp;&nbsp;&nbsp;MySQL ERROR : '.htmlspecialchars($xresult));
		xtext_admin ('<br>MySQL Query : '.htmlspecialchars($queryval));
		die('');
	} //end else


	@mysql_free_result ($result);


} //end function


//--------------------------------------------------------[DATA] encrypt / decrypt

//encryptor
function xdex_warp_crypt ($ytext) {
	$crypt = "";
	for ($i = 0; $i < strlen($ytext); $i++) {
		$byte = dechex((ord(substr($ytext, $i, 1)) ^ 101) & 255);
		$byte = str_pad($byte, 2, '0', STR_PAD_LEFT);
		$crypt .= $byte;
	} //end for
	return strtolower($crypt);
} //end xmcrypt

//decriptor
function xdex_warp_decrypt ($crypt) {
	$ytext = "";
	for ($i = 0; $i < strlen($crypt); $i += 2) {
		$byte = hexdec(substr($crypt, $i, 2)) ^ 101;
		$ytext .= chr($byte);
	} //end for
	return $ytext;
} //end xmdecrypt


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

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