// $debug=yes;
/**********************
landing page for the directory will show a list of categories
// first version will show everything ... hiding nothing
-- updates to do secure and insecure
**********************/
require'../commonfiles/Functions.php';
require'../commonfiles/MyFunctions.php';
require'../commonfiles/brandconfig.php3';
require'../commonfiles/newtemplate.php';
// connect mysql
$crm = new MySQL_class;
$crm->Create($crm_db,$crm_user,$crm_host,$crm_pass);
$gc_sql = $crm;
$cdc = new MySQL_class;
$cdc->Create($cdc_db,$cdc_user,$cdc_host,$cdc_pass);
$tmp = new MySQL_class;
$tmp->Create($template_db,$template_user,$template_host,$template_pass);
$dir = new MySQL_class;
$dir->Create($directory_db,$directory_user,$directory_host,$directory_pass);
$brnd = new MySQL_class;
$brnd->Create($db,$user,$host2,$pass);
// foil hackers
unset($u_type,$u_id,$session_email);
// start session
start_session($php_sessid);
if(page_auth(3,$u_type,$cdc) == "yes")
{
$staging=yes;
}
unset($u_id);
start_session($sessid);
lock_down("directory",$u_id,$code,$array);
// log it
app_log('directory',$PHP_SELF,$search_word,$application_id,'view',$code,$array);
// start template engine
$tpl = new rFastTemplate(".");
$tpl->no_strict();
// getting the header and other needed pages
$tpl->define_raw( array( main => get_template('2',$TEMPLATE,$tmp,$code,$staging),
body => get_template('3',$TEMPLATE,$tmp,$code,$staging),
alpha_contact => get_template('140',$TEMPLATE,$tmp,$code,$staging),
alpha => get_template('24',$TEMPLATE,$tmp,$code,$staging) ));
$tpl = show_login($u_id,$tpl);
$tpl->assign( array( SELF => $PHP_SELF ));
$tpl->assign(array( TODAY => date("l, F j, Y") ));
if($dump_directory && $code=='VENTURA')
{
// list all the dir categories and if there are companies in there list them and there contacts
// see if they are paid member
$query = "select id
from $AUTH_DURATION
where type_revenue = 'MEMBERSHIP'
and contact_id = '$u_id'
and end_date >= '".date("Ymd115959")."'
and brand = '$code' ";
$data = $crm->mydata($query);
if($data[id][0]=='' || !$u_id)
{
header("location: /store/?message=
You must purchase a membership before downloading the member list.");
exit();
}
header("Content-type: application/xls");
header("Content-Disposition: attachment; filename=exported_data.csv");
// lets get a list of categories
$query = "select name, category_id from $DIR_CATEGORY_NAME
where level = '0'
and category_type in ('COMPANY','ARTICLE')
and brand = '$code' and hide != 'Y' order by name";
$data = $dir->mydata($query);
for($a=0;$amydata($query);
for($b=0;$bmydata($query);
for($c=0;$c= '".date("Ymd115959")."'
and brand = '$code' ";
$data = $crm->mydata($query);
if($data[id][0]=='' || !$u_id)
{
header("location: /store/?message=
You must purchase a membership before downloading the member list.");
exit();
}
header("Content-type: application/xls");
header("Content-Disposition: attachment; filename=exported_data.csv");
}
$tpl = list_dir_cats($tpl,'COMPANY',$code,$dir);
$query = "select cdc_id, first_name, last_name
from $CRM_CDC
where private = 'N'
and brand = '$code'
and disabled = '0'
and first_name != ''
and last_name != ''
order by last_name, first_name ";
$data = $crm->mydata($query);
for($a=0;$amydata($query);
for($b=0;$bmydata($query);
if(trim($dir_data[company_name][0]))
{
if(!$company_comma)
{
$company_comma = "".ss($dir_data[company_name][0])."";
$companys = ss($dir_data[company_name][0]);
} else {
$company_comma .= ", ".ss($dir_data[company_name][0])."";
$companys .= ", ".ss($dir_data[company_name][0]);
}
}
}
if($company_comma)
{
$tpl->assign(array( FIRST_NAME => $data[first_name][$a],
COMPANY_COMMA => $company_comma,
LAST_NAME => $data[last_name][$a] ));
$tpl->parse("CONTACTS",".contacts");
}
if($download_file)
{
$contact = get_cdc($data[cdc_id][$a],$code,$cdc);
echo"\"$contact[first_name]\",\"$contact[last_name]\",\"$companys\",\"$contact[email]\",\"$contact[telephone_1]\"\n";
}
unset($company_comma,$companys);
}
if($download_file)
{
exit();
}
$tpl->parse( MAIN, array( "alpha_contact", "main" ));
$tpl->FastPrint();
exit();
}
if($alpha)
{
// make two columns and start formating them
$tpl = list_dir_cats($tpl,'COMPANY',$code,$dir);
$query = "select company_name, cdc_id from $DIR_CDC
where brand = '$code'
and hide != '1'
and cdc_id != ''
order by company_name ";
$data = $dir->mydata($query);
for($a=0;$amydata($query);
$contact = get_cdc($contact_data[contact_id][0],$code,$cdc);
if(eregi("^[0-9]",$data[company_name][$a]))
{
$tpl->assign(array( "O9_COMPANY_NAME" => stripslashes($data[company_name][$a]),
"09_CONTACT_NAME" => "$contact[first_name] $contact[last_name]",
"O9_COMPANY_ID" => $data[cdc_id][$a] ));
$tpl->parse("O_9",".O_9");
}
if(eregi("^[a-b]",$data[company_name][$a]))
{
$tpl->assign(array( AB_COMPANY_NAME => stripslashes($data[company_name][$a]),
AB_CONTACT_NAME => "$contact[first_name] $contact[last_name]",
AB_COMPANY_ID => $data[cdc_id][$a] ));
$tpl->parse("A_B",".a_b");
}
if(eregi("^[c-e]",$data[company_name][$a]))
{
$tpl->assign(array( CE_COMPANY_NAME => stripslashes($data[company_name][$a]),
CE_CONTACT_NAME => "$contact[first_name] $contact[last_name]",
CE_COMPANY_ID => $data[cdc_id][$a] ));
$tpl->parse("C_E",".c_e");
}
if(eregi("^[f-h]",$data[company_name][$a]))
{
$tpl->assign(array( FH_COMPANY_NAME => stripslashes($data[company_name][$a]),
FH_CONTACT_NAME => "$contact[first_name] $contact[last_name]",
FH_COMPANY_ID => $data[cdc_id][$a] ));
$tpl->parse("F_H",".f_h");
}
if(eregi("^[i-k]",$data[company_name][$a]))
{
$tpl->assign(array( IK_COMPANY_NAME => stripslashes($data[company_name][$a]),
IK_CONTACT_NAME => "$contact[first_name] $contact[last_name]",
IK_COMPANY_ID => $data[cdc_id][$a] ));
$tpl->parse("I_K",".i_k");
}
if(eregi("^[l-n]",$data[company_name][$a]))
{
$tpl->assign(array( LN_COMPANY_NAME => stripslashes($data[company_name][$a]),
LN_CONTACT_NAME => "$contact[first_name] $contact[last_name]",
LN_COMPANY_ID => $data[cdc_id][$a] ));
$tpl->parse("L_N",".l_n");
}
if(eregi("^[o-r]",$data[company_name][$a]))
{
$tpl->assign(array( OR_COMPANY_NAME => stripslashes($data[company_name][$a]),
OR_CONTACT_NAME => "$contact[first_name] $contact[last_name]",
OR_COMPANY_ID => $data[cdc_id][$a] ));
$tpl->parse("O_R",".o_r");
}
if(eregi("^[s-t]",$data[company_name][$a]))
{
$tpl->assign(array( ST_COMPANY_NAME => stripslashes($data[company_name][$a]),
ST_CONTACT_NAME => "$contact[first_name] $contact[last_name]",
ST_COMPANY_ID => $data[cdc_id][$a] ));
$tpl->parse("S_T",".s_t");
}
if(eregi("^[u-z]",$data[company_name][$a]))
{
$tpl->assign(array( UZ_COMPANY_NAME => stripslashes($data[company_name][$a]),
UZ_CONTACT_NAME => "$contact[first_name] $contact[last_name]",
UZ_COMPANY_ID => $data[cdc_id][$a] ));
$tpl->parse("U_Z",".u_z");
}
}
$tpl->parse( MAIN, array( "alpha", "main" ));
$tpl->FastPrint();
exit();
}
// lets get a list of categories
$query = "select name, category_id from $DIR_CATEGORY_NAME
where level = '0'
and category_type in ('COMPANY','ARTICLE')
and brand = '$code' and hide != 'Y' order by position, name";
$data = $dir->mydata($query);
// loop through and start inserting into the columns
/*
for($a=0;$amydata($query);
for($b=0;$b".$sub_data[name][$b]."";
}
if($sub_data[name][$b]!="" && $b=="1")
{
$sub_foo .= ", ".$sub_data[name][$b]."";
}
if($sub_data[name][$b]!="" && $b=="2")
{
$sub_foo .= ", ".$sub_data[name][$b]."... ";
}
}
$tpl->assign( array( NAME_1 => stripslashes($data[name][$a]),
CATEGORY_ID_1 => $data[category_id][$a],
SUB_FOO_1 => $sub_foo ));
unset($sub_foo);
// column 2
// get three sub cats for each category
$query = "select $DIR_CATEGORY_NAME.name, $DIR_CATEGORY_NAME.category_id
from $DIR_CATEGORY_NAME, $DIR_CAT_TO_CAT_ORGANIZATION
where $DIR_CATEGORY_NAME.category_id = $DIR_CAT_TO_CAT_ORGANIZATION.lesser_category_id
and $DIR_CAT_TO_CAT_ORGANIZATION.category_id = '".$data[category_id][$a+1]."'
and $DIR_CATEGORY_NAME.category_type = 'COMPANY'
and $DIR_CAT_TO_CAT_ORGANIZATION.brand = '$code'
order by $DIR_CATEGORY_NAME.name
limit 0,3 ";
$sub_data = $dir->mydata($query);
for($b=0;$b".$sub_data[name][$b]."";
}
if($sub_data[name][$b]!="" && $b=="1")
{
$sub_foo .= ", ".$sub_data[name][$b]."";
}
if($sub_data[name][$b]!="" && $b=="2")
{
$sub_foo .= ", ".$sub_data[name][$b]."... ";
}
}
$tpl->assign( array( NAME_2 => stripslashes($data[name][$a+1]),
CATEGORY_ID_2 => $data[category_id][$a+1],
SUB_FOO_2 => $sub_foo ));
unset($sub_foo);
// column 3
// get three sub cats for each category
$query = "select $DIR_CATEGORY_NAME.name, $DIR_CATEGORY_NAME.category_id
from $DIR_CATEGORY_NAME, $DIR_CAT_TO_CAT_ORGANIZATION
where $DIR_CATEGORY_NAME.category_id = $DIR_CAT_TO_CAT_ORGANIZATION.lesser_category_id
and $DIR_CAT_TO_CAT_ORGANIZATION.category_id = '".$data[category_id][$a+2]."'
and $DIR_CATEGORY_NAME.category_type = 'COMPANY'
and $DIR_CAT_TO_CAT_ORGANIZATION.brand = '$code'
order by $DIR_CATEGORY_NAME.name ";
$sub_data = $dir->mydata($query);
for($b=0;$b".$sub_data[name][$b]."";
}
if($sub_data[name][$b]!="" && $b=="1")
{
$sub_foo .= ", ".$sub_data[name][$b]."";
}
if($sub_data[name][$b]!="" && $b=="2")
{
$sub_foo .= ", ".$sub_data[name][$b]."... ";
}
}
$tpl->assign( array( NAME_3 => stripslashes($data[name][$a+2]),
CATEGORY_ID_3 => $data[category_id][$a+2],
SUB_FOO_3 => $sub_foo ));
unset($sub_foo);
$tpl->parse("COLUMN_1",".column_1");
$tpl->parse("COLUMN_2",".column_2");
$tpl->parse("COLUMN_3",".column_3");
}
*/
for($a=0;$amydata($query);
// and $DIR_CATEGORY_NAME.category_type = 'COMPANY'
$sub_foo = "";
for($b=0;$b".$sub_data[name][$b]."";
// get third level
$query = "select distinct($DIR_CATEGORY_NAME.category_id), $DIR_CATEGORY_NAME.name
from $DIR_CATEGORY_NAME, $DIR_CAT_TO_CAT_ORGANIZATION
where $DIR_CATEGORY_NAME.category_id = $DIR_CAT_TO_CAT_ORGANIZATION.lesser_category_id
and $DIR_CAT_TO_CAT_ORGANIZATION.category_id = '".$sub_data[category_id][$b]."'
and $DIR_CAT_TO_CAT_ORGANIZATION.brand = '$code'
and $DIR_CATEGORY_NAME.hide != 'Y'
order by $DIR_CATEGORY_NAME.name ";
$sub_sub_data = $dir->mydata($query);
// and $DIR_CATEGORY_NAME.category_type = 'COMPANY'
if($sub_sub_data[name][0]!='')
{
$sub_foo .= "";
}
for($c=0;$c ".$sub_sub_data[name][$c]."";
// get fourth level
$query = "select distinct($DIR_CATEGORY_NAME.category_id), $DIR_CATEGORY_NAME.name
from $DIR_CATEGORY_NAME, $DIR_CAT_TO_CAT_ORGANIZATION
where $DIR_CATEGORY_NAME.category_id = $DIR_CAT_TO_CAT_ORGANIZATION.lesser_category_id
and $DIR_CAT_TO_CAT_ORGANIZATION.category_id = '".$sub_sub_data[category_id][$c]."'
and $DIR_CAT_TO_CAT_ORGANIZATION.brand = '$code'
and $DIR_CATEGORY_NAME.hide != 'Y'
order by $DIR_CATEGORY_NAME.name ";
$sub_sub_sub_data = $dir->mydata($query);
// and $DIR_CATEGORY_NAME.category_type = 'COMPANY'
if($sub_sub_sub_data[name][0]!='')
{
$sub_foo .= "";
}
$sub_foo .="";
}
$sub_foo .="";
if($sub_sub_data[name][0]!='')
{
$sub_foo .= "
";
}
$sub_foo .="";
}
$sub_foo .= "
";
$tpl->assign( array( NAME_LONG => stripslashes($data[name][$a]),
CATEGORY_ID_LONG => $data[category_id][$a],
SUB_FOO_LONG => ss($sub_foo) ));
unset($sub_foo);
$tpl->parse("COLUMN_LONG",".column_long");
}
// *************** four column alpha up and down
// devide by four
$count = count($data[name]);
$num_per_column = $count / 4;
$num_per_column = explode(".",$num_per_column);
$num_per_column = $num_per_column[0];
/*
for($a=0;$aassign(array( COL_1 => $data[name][$a],
COL_ID_1 => $data[category_id][$a] ));
$tpl->parse("COL_1",".col_1");
}
if($b <= $num_per_column*2 && $b > $num_per_column*1)
{
$tpl->assign(array( COL_2 => $data[name][$a],
COL_ID_2 => $data[category_id][$a] ));
$tpl->parse("COL_2",".col_2");
}
if($b <= $num_per_column*3 && $b > $num_per_column*2)
{
$tpl->assign(array( COL_3 => $data[name][$a],
COL_ID_3 => $data[category_id][$a] ));
$tpl->parse("COL_3",".col_3");
}
if($b > $num_per_column*3)
{
$tpl->assign(array( COL_4 => $data[name][$a],
COL_ID_4 => $data[category_id][$a] ));
$tpl->parse("COL_4",".col_4");
}
}
*/
$tpl = html_chunks($staging,$tpl,$code,$brnd);
$tpl->parse( MAIN, array( "body", "main" ));
$tpl->FastPrint();
exit();
?>