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

// [resources module 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


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

if ($warp_module_var_check_auth != 'x99warpv12.cms') {
	$y_hlocalmodz_xdate = date("Y-m-d");
	$y_hlocalmodz_xtime = date("H:i:s");
	$wpmod_xdyech =	"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n".
			"<!--:: xantis.warp.cms :: Xantis Warp - Content Management Server - v.1.2 :: $y_hlocalmodz_xdate :: $y_hlocalmodz_xtime :: -->\n".
			"<html>\n".
			"<head>\n".
			"<title>! ! !</title>\n".
			"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n".
			"</head>\n".
			"<body bgcolor=\"#FFFFFF\" leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\">\n".
			"<br>\n".
			"<div align=\"center\"><object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://active.macromedia.com/flash6/cabs/swflash.cab#version=6,0,0,0\" width=\"30\" height=\"30\">\n".
			"<param name=\"movie\" value=\"flagger.swf\">\n".
			"<param name=\"flashvars\" value=\"&xaction=err&\">\n".
			"<param name=\"quality\" value=\"high\">\n".
			"<param name=\"bgcolor\" value=\"#FFFFFF\">\n".
			"<param name=\"menu\" value=\"false\">\n".
			"<embed src=\"flagger.swf\" flashvars=\"&xaction=err&\" quality=\"high\" bgcolor=\"#FFFFFF\" width=\"30\" height=\"30\" menu=\"false\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\"></embed>\n".
			"</object>\n".
			"</div>\n".
			"</body>\n".
			"</html>\n" ;
	die("$wpmod_xdyech");
} //end if



//--------------------- data display resources


function xshow_rep_resources_data ($ytitle, $ydate, $ytext, $yidx, $yfilesize, $yrankx) {

	global 	$ybar_color, $y_warp_resource_text;
	global 	$ymain_color, $y_warp_picts_dir, $ywebsite_addr;
	global 	$ydisplay_width_corrected;
	global	$wpsid, $y_warp_resources_addon ;
	global	$warp_numform_decimal_sep, $warp_numform_thousand_sep ;
	global	$y_warp_resources_rankx ;

	$ysize = $ydisplay_width_corrected;
	$ysize_icon = '40';
	$ysize_prn = '40';
	$ysize_date = $ysize - ($ysize_icon + $ysize_prn);

	$yfilesize = number_format($yfilesize, 0, $warp_numform_decimal_sep, $warp_numform_thousand_sep);


xtable_start ("$ysize");

	xtable_row_start ();
		xtable_column_start ('1', "$ysize", "$ybar_color");
			xtext_title ("$ytitle");
		xtable_column_end ();
	xtable_row_end ();

	xtable_row_start ();
		xtable_column_start ('1', "$ysize", "$ymain_color");
			xvline ("$ysize");
		xtable_column_end ();
	xtable_row_end ();


	xtable_row_start ();
		xtable_column_start ('1', "$ysize", "$ymain_color");

		xtable_start ("$ysize");

		xtable_row_start ();

			//the icon
			xtable_column_start ('1', "$ysize_icon", "$ymain_color");
				xspace ();
				xpict ("$ywebsite_addr"."$y_warp_picts_dir".'/resources.jpg', '30', '30');
			xtable_column_end ();

			//the text
			xtable_column_start ('1', "$ysize_date", "$ymain_color");
				xspace ();
				xtext_small ('<b>'."$yfilesize".' kb - '.'</b>'.'('."$y_warp_resources_addon".' '."$ydate".')');
				xspace ();
				xtext_small (' [ '.$y_warp_resources_rankx.' '.$yrankx.' ] '.'<br>');
			xtable_column_end ();

			//the view
			xtable_column_start ('1', "$ysize_prn", "$ymain_color");

				xcenter_right_start ();

					$op_var = "$ywebsite_addr"."req_redir.php?xid=$yidx&xop=xres&wpsid=$wpsid";

					xpict_link ("$ywebsite_addr"."$y_warp_picts_dir".'/docs_mini.jpg', "$y_warp_resource_text", '20', '20', "$op_var", 'wnd_dwn');

					xspace ();
				xcenter_end ();

			xtable_column_end ();

		xtable_row_end ();

		xtable_end ();

		xtable_column_end ();
	xtable_row_end ();
	
	//details
	xtable_row_start ();
		xtable_column_start ('1', "$ysize", "$ymain_color");
			xtext_small ("$ytext");
			xnewline ();
			xvline ("$ysize");
		xtable_column_end ();
	xtable_row_end ();


xtable_end ();

} //end function
//----------------




function resources_module ($resop) {
//-------------------


//remote and lib vars
global	$ywebsite_addr, $arr_var_result, $var_result_size, $wpqid, $wpsid ;

//cfg vars
global	$ydisplay_width_corrected, $ysite_back_color, $ybar_menu_color ;
global	$y_warp_total_text, $y_warp_filter_text, $y_warp_filter_text_bttn, $y_warp_filter_hint, $ymain_color, $ysmall_text_color ;
global	$y_warp_prev_text, $y_warp_next_text, $y_warp_filtered_text, $y_warp_picts_dir, $y_warp_filter_remove, $y_warp_filter_sign;

//resources cfg vars
global	$y_warp_resources_text, $y_warp_resources_text_p, $y_warp_max_resources_perpage, $y_warp_resources_subj, $y_warp_resources_descr ;

//local vars
global	$qval,	$offset;

//prod mod vars
global	$pmop, $fcategid, $fitmid, $yprods_show_title, $yprods_back_text, $yprods_item_title_xs, $yprods_item_pname ;


//vars
$y_db_tablename = "resources";
$limit = $y_warp_max_resources_perpage;
$xdesired_fields = 'title, w_date, description, id, size_kb, rank_v';

//------------------------------------------------------search process

if ($resop == 'pres') {

	$hlkx_local_text_dwn = $y_warp_resources_text_p ;

	//vars
	$qval = '';
	$qwval_src = '';
	$qwval_src_arr = array ();
	$qval_url = '';

	$xurl = "$ywebsite_addr"."xw_main.php"."?wpqid=$wpqid&wpsid=$wpsid&offset=0&pmop=$pmop&fcategid=$fcategid&fitmid=$fitmid";

	$w_querryx_bld = " WHERE ( pblock='$fitmid' ) ";

} //end if
else {

	$hlkx_local_text_dwn = $y_warp_resources_text ;

	//vars
	$qval = rawurldecode($qval);
	$qwval_src = trim($qval);
	$qwval_src_arr = array ();
	$qwval_src_arr = explode("$y_warp_filter_sign", $qwval_src);
	$qval_url = rawurlencode(stripslashes($qval));

	$xurl = "$ywebsite_addr"."xw_main.php"."?wpqid=$wpqid&wpsid=$wpsid&offset=0";

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

	//filter empties
	$qwval_src_arr_new = array ();
	for ($i=0 ; $i<count($qwval_src_arr) ; $i++) {
		if ( trim($qwval_src_arr[$i]) <> '' ) {
			array_push ($qwval_src_arr_new, trim($qwval_src_arr[$i]));
		} //end if
	} //end for

	//build the querry
	if (count($qwval_src_arr_new) <> '0') {
		$w_querryx_bld = " WHERE ";
		for ($i=0 ; $i<count($qwval_src_arr_new) ; $i++) {
			$w_querryx_bld_i = $qwval_src_arr_new[$i];
			$w_querryx_bld = " ".$w_querryx_bld." ( (title LIKE '%".$w_querryx_bld_i."%') OR (description LIKE '%".$w_querryx_bld_i."%') ) ";
			if ($i <> ( count($qwval_src_arr_new) - 1 ) ) {
				$w_querryx_bld = $w_querryx_bld." AND " ;
			} //end if
			else {
				$w_querryx_bld = $w_querryx_bld." AND ( pblock='0' ) " ;
			} //end else
		} //end for
	} //end if

	//[set text if filtered] or [empty querry]
	$w_src_filteredby = " - ".$y_warp_filtered_text ;
	if (count($qwval_src_arr_new) == '0') {
		$w_querryx_bld = " WHERE ( pblock='0' ) ";
		$w_src_filteredby = '';
	} //end if

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

} //end else




//---------------------
if (empty($offset)) {
   $offset = 0;
}
//---------------------

	$w_querryx = "  ".$w_querryx_bld." ";

	$wquerry_main = "SELECT $xdesired_fields FROM $y_db_tablename ".$w_querryx;

	$wquerry_main_c = "SELECT COUNT(*) FROM $y_db_tablename ".$w_querryx;

	$arr_xds_prod_nam = array();
	xmysql_read_data ("SELECT title FROM prod_items WHERE (id='$fitmid') ");
	$arr_xds_prod_nam = $arr_var_result;

	xmysql_count_data ($wquerry_main_c);
	xmysql_read_data ($wquerry_main." ORDER BY id DESC LIMIT $offset, $limit");


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

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

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


//=====================================


if ($resop == 'pres') {

	xtable_start ("$ydisplay_width_corrected");
		xtable_row_start ();
			xtable_column_start_vcenter ('1', '30%', "$ybar_menu_color");
				xcenter_right_start ();
					xvpix_h ('5');
					xnewline ();
					xpict_alt ("$ywebsite_addr"."$y_warp_picts_dir".'/prod_categ.jpg', '30', '30', "$yprods_show_title");
					xspace ();
					xspace ();
				xcenter_end ();
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '50%', "$ybar_menu_color");
				xtext_link ("$yprods_back_text", "$ywebsite_addr"."xw_main.php"."?wpqid=$wpqid&wpsid=$wpsid&pmop=pdet&fcategid=$fcategid&fitmid=$fitmid", '_self');
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '20%', "$ybar_menu_color");
					xspace ();
			xtable_column_end ();
		xtable_row_end ();
	xtable_end ();

	xnewline ();

	xtable_start ("$ydisplay_width_corrected");
		xtable_row_start ();
			xtable_column_start_vcenter ('1', '30%', "$ymain_color");
				xcenter_right_start ();
					xvpix_h ('5');
					xnewline ();
					xpict_alt ("$ywebsite_addr"."$y_warp_picts_dir".'/prod_item.jpg', '30', '30', "$yprods_item_title_xs");
					xspace ();
					xspace ();
				xcenter_end ();
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '50%', "$ymain_color");
				xtext_small ('<i>'."$yprods_item_pname".' : </i>');
				xnewline ();
				xtext_small ('<b>'."$arr_xds_prod_nam[0]".'</b>');
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '20%', "$ymain_color");
					xspace ();
			xtable_column_end ();
		xtable_row_end ();
	xtable_end ();

} //end if
else {

	xtable_start ("$ydisplay_width_corrected");
		xtable_row_start ();
			xtable_column_start ('1', '', "$ysite_back_color");
				xcenter_start ();
					xwriteflash_nobg_var ("$ywebsite_addr"."src_frm.swf",
						"&flash_form_backcolor=".rawurlencode($ymain_color).
						"&flash_form_textcolor=".rawurlencode($ysmall_text_color).
						"&flash_form_text_flby=".rawurlencode($y_warp_filter_text).
						"&flash_form_text_hint=".rawurlencode($y_warp_filter_hint).
						"&flash_form_text_bttn=".rawurlencode($y_warp_filter_text_bttn).
						"&flash_form_logo=".rawurlencode("$ywebsite_addr"."$y_warp_picts_dir".'/resources.jpg').
						"&flash_form_listall=".rawurlencode($y_warp_filter_remove).
						"&qval_hint=".rawurlencode("[$y_warp_resources_subj | $y_warp_resources_descr]").
						"&qval=".$qval_url.
						"&xurl=".rawurlencode("$xurl").
						"&"
					, '500', '40');
				xcenter_end ();
			xtable_column_end ();
		xtable_row_end ();
	xtable_end ();

} //end else


xnewline ();


//====================

if ($resop == 'pres') {

	$hlkx_local_prev_url = "$ywebsite_addr"."xw_main.php"."?wpqid=$wpqid&wpsid=$wpsid&offset=$newoffsetprev&pmop=$pmop&fcategid=$fcategid&fitmid=$fitmid" ;
	$hlkx_local_next_url = "$ywebsite_addr"."xw_main.php"."?wpqid=$wpqid&wpsid=$wpsid&offset=$newoffsetnext&pmop=$pmop&fcategid=$fcategid&fitmid=$fitmid" ;

} //end if
else {

	$hlkx_local_prev_url = "$ywebsite_addr"."xw_main.php"."?wpqid=$wpqid&wpsid=$wpsid&offset=$newoffsetprev&qval=$qval_url" ;
	$hlkx_local_next_url = "$ywebsite_addr"."xw_main.php"."?wpqid=$wpqid&wpsid=$wpsid&offset=$newoffsetnext&qval=$qval_url" ;

} //end else

//====================

xtable_start ("$ydisplay_width_corrected");
	xtable_row_start ();
		xtable_column_start ('1', '', "$ybar_menu_color");
			xtext_small ('|');
			xspace ();
			xtext_small ("<b>$hlkx_local_text_dwn</b> [<b>$offsetlistedmin</b> - <b>$offsetlistedmax</b> (<b>$var_result_size</b> $y_warp_total_text)]"."$w_src_filteredby");
			xspace ();
			xtext_small ('|');
		xtable_column_end ();

		xtable_column_start ('1', '', "$ybar_menu_color");
			xcenter_right_start ();
				xtext_small ('|');
					xspace ();
					//Show PREV
					if ($newoffsetprev >= 0) {
						xtext_link ("$y_warp_prev_text", $hlkx_local_prev_url, '_self');
						xspace ();
						xtext_small ('|');
						xspace ();
					} //end if

					//Show NEXT
					if ($newoffsetnext < $var_result_size) {
						xtext_link ("$y_warp_next_text", $hlkx_local_next_url, '_self');
						xspace ();
						xtext_small ('|');
						xspace ();
					} //end if
			xcenter_end ();
		xtable_column_end ();
	xtable_row_end ();
xtable_end ();

xnewline ();

//=====================================


$arr_count = count($arr_var_result);
for ($i=0; $i < $arr_count; $i++) {
	$i_title = $i;
	$i_date = $i +1;
	$i_text = $i + 2;
	$i_idx = $i + 3;
	$i_size = $i + 4;
	$i_rankd = $i + 5;
	$i = $i + 5;

	xshow_rep_resources_data ($arr_var_result[$i_title], $arr_var_result[$i_date], $arr_var_result[$i_text], $arr_var_result[$i_idx], $arr_var_result[$i_size], $arr_var_result[$i_rankd]);

	xnewline ();
} //end for


//====================

xtable_start ("$ydisplay_width_corrected");
	xtable_row_start ();
		xtable_column_start ('1', '', "$ybar_menu_color");
			xtext_small ('|');
			xspace ();
			xtext_small ("<b>$hlkx_local_text_dwn</b> [<b>$offsetlistedmin</b> - <b>$offsetlistedmax</b> (<b>$var_result_size</b> $y_warp_total_text)]"."$w_src_filteredby");
			xspace ();
			xtext_small ('|');
		xtable_column_end ();

		xtable_column_start ('1', '', "$ybar_menu_color");
			xcenter_right_start ();
				xtext_small ('|');
					xspace ();
					//Show PREV
					if ($newoffsetprev >= 0) {
						xtext_link ("$y_warp_prev_text", $hlkx_local_prev_url, '_self');
						xspace ();
						xtext_small ('|');
						xspace ();
					} //end if

					//Show NEXT
					if ($newoffsetnext < $var_result_size) {
						xtext_link ("$y_warp_next_text", $hlkx_local_next_url, '_self');
						xspace ();
						xtext_small ('|');
						xspace ();
					} //end if
			xcenter_end ();
		xtable_column_end ();
	xtable_row_end ();
xtable_end ();

xnewline ();

//=====================================


}//-------------------end function



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

//resources_module ('nres'); //normal
//resources_module ('pres'); //products

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

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