";
if (e_QUERY) {
list($action, $id ) = explode(".", e_QUERY);
}
else
{
$action = FALSE;
$id = "";
}
function getPagerData($numHits, $limit, $page)
{
//Validate function input - avoids division by 0 and other misuse!
$numHits = (int) $numHits;
$limit = max((int) $limit, 1);
$page = (int) $page;
//Calculate number of pages and stated in previous section
$numPages = ceil($numHits / $limit);
//If page number less than 1, set to 1
$page = max($page, 1);
//If page number greater than number of pages, set to number of pages
$page = min($page, $numPages);
//Calculate offset, as stated in previous section
////The reason we subtract 1 is because we are treating 1 as our first page, and not 0.
$offset = ($page - 1) * $limit;
$ret = new stdClass;
//Build up a pretty little object for returning
$ret->offset = $offset;
$ret->limit = $limit;
$ret->numPages = $numPages;
$ret->page = $page;
return $ret;
}
if ($_GET['page'] || ($action=="" && !$_GET['page'])) //set page action
{
//get edit access and delete access form configure setting
$userID = USERID;
if ($userID == "USERID")//NOT LOG IN YET
{
$user_type = e_UC_GUEST;
}
//else it is a member logged up.
else if ($sql -> db_Select('user','*',"user_id='".$userID."'"))
{
$row = $sql->db_Fetch();
$user_admin = $row['user_admin'];
if ($row['user_admin'] == 1) //this user is admin
{
$user_type = e_UC_ADMIN;
}
else
$user_type = e_UC_MEMBER;
}
$editAccess = $pb_prefs['pb_edit_access'];
$flagEditAccess = false;
switch($editAccess)
{
case e_UC_PUBLIC:
case e_UC_GUEST:
$flagEditAccess = true; break;
case e_UC_MEMBER:
if ($user_type == e_UC_MEMBER)
$flagEditAccess = true;
break;
case e_UC_ADMIN:
if ($user_type == e_UC_ADMIN)
$flagEditAccess = true;
break;
case e_UC_NOBODY: break;
}
$deleteAccess = $pb_prefs['pb_delete_access'];
$flagDeleteAccess = false;
switch($deleteAccess)
{
case e_UC_PUBLIC:
case e_UC_GUEST:
$flagDeleteAccess = true; break;
case e_UC_MEMBER:
if ($user_type == e_UC_MEMBER)
$flagDeleteAccess = true;
break;
case e_UC_ADMIN:
if ($user_type == e_UC_ADMIN)
$flagDeleteAccess = true;
break;
case e_UC_NOBODY: break;
}
//----------------------------------------------------------
//handle arg param from Query statement, because browser can't display some characters: ', $...
$transferArg = $_GET['arg'];
mysql_real_escape_string($transferArg); // Help Protect Aginst SQL Inject
$arg = $transferArg;
if ($arg != "")//format first letter of comapny name
{
$where .= "pb_company like '".$arg."%' and ";
$where = substr($where, 0, strlen($where)-strlen(" and "));
$paggingArg = "&arg=$transferArg";
// echo $Swhere;
}
$transferArg2 = $_GET['arg2']; // Search Company
$arg2 = $transferArg2;
mysql_real_escape_string($transferArg2); // Help Protect Aginst SQL Inject
if ($arg2 != "")
{
$where .= "pb_company like '%".$arg2."%' and ";
$where = substr($where, 0, strlen($where)-strlen(" and "));
$paggingArg = "&arg2=$transferArg2";
}
$transferArg3 = $_GET['arg3']; // Search Category
$arg3 = $transferArg3;
mysql_real_escape_string($transferArg3); // Help Protect Aginst SQL Inject
if ($arg3 != "")
{
$where .= "pb_country like '%".$arg3."%' and ";
$where = substr($where, 0, strlen($where)-strlen(" and "));
$paggingArg = "&arg3=$transferArg3";
}
$transferArg4 = $_GET['arg4']; // Search Company
$arg4 = $transferArg4;
mysql_real_escape_string($transferArg4); // Help Protect Aginst SQL Inject
$transferArg5 = $_GET['arg5']; // Search Category
$arg5 = $transferArg5;
mysql_real_escape_string($transferArg5); // Help Protect Aginst SQL Inject
if ($arg4 != "" && $arg5 != "")
{
$where .= "pb_company like '%".$arg4."%' and ";
$where .= "pb_country like '%".$arg5."%' and ";
$where = substr($where, 0, strlen($where)-strlen(" and "));
$paggingArg = "&arg4=$transferArg4&arg5=$transferArg5";
}
$transferArg6 = $_GET['arg6']; // Numeric Search
$arg6 = $transferArg6;
mysql_real_escape_string($transferArg6); // Help Protect Aginst SQL Inject
if ($arg6 != "")
{
$number = "'0%' OR pb_company like '1%' OR pb_company like '2%' OR pb_company like '3%' OR pb_company like '4%' OR pb_company like '5%' OR pb_company like '6%' OR pb_company like '7%' OR pb_company like '8%' OR pb_company like '9%' ";
$where .= "pb_company like ".$number.""; // Used to select first character as a number 1-9
$paggingArg = "&arg6=$transferArg6";
}
$transferArg7 = $_GET['arg7']; // Certificate Program Search
$arg7 = $transferArg7;
mysql_real_escape_string($transferArg7); // Help Protect Aginst SQL Inject
if ($arg7 != "")
{
$where .= "pb_messengerAccName = '".$arg7."'";
$paggingArg = "&arg7=$transferArg7";
}
// // echo $Swhere;
//if ($arg == "")
if ($where == "")
$model = 'no_where';
else
$model = 'default';
$page = $_GET['page'];
$limit = $pb_prefs['pb_record_per_page'];
$total = $sql-> db_Select(TABLE_NAME, '*', $where, $model);
// work out the pager values
$pager = getPagerData($total, $limit, $page);
$offset = $pager->offset;
$limit = $pager->limit;
$page = $pager->page; // current page
// $where .= " order by pb_country limit $offset, $limit ";
$where .= " order by pb_company limit $offset, $limit "; // Changed to pb_country to pb_company for paging to sort corectly
//get and display search result
// Banner Display
if ($arg == "0_9"){$text .= "
{BANNER=Alpha_0_9}
";}
if ($arg == "A"){$text .= "
{BANNER=Alpha_A}
";}
if ($arg == "B"){$text .= "
{BANNER=Alpha_B}
";}
if ($arg == "C"){$text .= "
{BANNER=Alpha_C}
";}
if ($arg == "D"){$text .= "
{BANNER=Alpha_D}
";}
if ($arg == "E"){$text .= "
{BANNER=Alpha_E}
";}
if ($arg == "F"){$text .= "
{BANNER=Alpha_F}
";}
if ($arg == "G"){$text .= "
{BANNER=Alpha_G}
";}
if ($arg == "H"){$text .= "
{BANNER=Alpha_H}
";}
if ($arg == "I"){$text .= "
{BANNER=Alpha_I}
";}
if ($arg == "J"){$text .= "
{BANNER=Alpha_J}
";}
if ($arg == "K"){$text .= "
{BANNER=Alpha_K}
";}
if ($arg == "L"){$text .= "
{BANNER=Alpha_L}
";}
if ($arg == "M"){$text .= "
{BANNER=Alpha_M}
";}
if ($arg == "N"){$text .= "
{BANNER=Alpha_N}
";}
if ($arg == "O"){$text .= "
{BANNER=Alpha_O}
";}
if ($arg == "P"){$text .= "
{BANNER=Alpha_P}
";}
if ($arg == "Q"){$text .= "
{BANNER=Alpha_Q}
";}
if ($arg == "R"){$text .= "
{BANNER=Alpha_R}
";}
if ($arg == "S"){$text .= "
{BANNER=Alpha_S}
";}
if ($arg == "T"){$text .= "
{BANNER=Alpha_T}
";}
if ($arg == "U"){$text .= "
{BANNER=Alpha_U}
";}
if ($arg == "V"){$text .= "
{BANNER=Alpha_V}
";}
if ($arg == "W"){$text .= "
{BANNER=Alpha_W}
";}
if ($arg == "X"){$text .= "
{BANNER=Alpha_X}
";}
if ($arg == "Y"){$text .= "
{BANNER=Alpha_Y}
";}
if ($arg == "Z"){$text .= "
{BANNER=Alpha_Z}
";}
if ($arg3 == "Abstract Companies"){$text .= "
{BANNER=Cat_Abstract Companies}
";}
if ($arg3 == "Accountants"){$text .= "
{BANNER=Cat_Accountants}
";}
if ($arg3 == "Advertising"){$text .= "
{BANNER=Cat_Advertising}
";}
if ($arg3 == "AgriBusiness"){$text .= "
{BANNER=Cat_AgriBusiness}
";}
if ($arg3 == "Animal Shelters"){$text .= "
{BANNER=Cat_Animal Shelters}
";}
if ($arg3 == "Apartments"){$text .= "
{BANNER=Cat_Apartments}
";}
if ($arg3 == "Appliances"){$text .= "
{BANNER=Cat_Appliances}
";}
if ($arg3 == "Artists"){$text .= "
{BANNER=Cat_Artists}
";}
if ($arg3 == "Asphalt Paving"){$text .= "
{BANNER=Cat_Asphalt Paving}
";}
if ($arg3 == "Assisted Living"){$text .= "
{BANNER=Cat_Assisted Living}
";}
if ($arg3 == "Associations"){$text .= "
{BANNER=Cat_Associations}
";}
if ($arg3 == "Attorneys"){$text .= "
{BANNER=Cat_Attorneys}
";}
if ($arg3 == "Auto Dealers"){$text .= "
{BANNER=Cat_Auto Dealers}
";}
if ($arg3 == "Auto Parts"){$text .= "
{BANNER=Cat_Auto Parts}
";}
if ($arg3 == "Auto Recycling"){$text .= "
{BANNER=Cat_Auto Recycling}
";}
if ($arg3 == "Awards & Trophies"){$text .= "
{BANNER=Cat_Awards & Trophies}
";}
if ($arg3 == "Banks"){$text .= "
{BANNER=Cat_Banks}
";}
if ($arg3 == "Beauty Salon/Spa"){$text .= "
{BANNER=Cat_Beauty Salon/Spa}
";}
if ($arg3 == "Beverages-Wholesale"){$text .= "
{BANNER=Cat_Beverages-Wholesale}
";}
if ($arg3 == "Bicycles"){$text .= "
{BANNER=Cat_Bicycles}
";}
if ($arg3 == "Builders"){$text .= "
{BANNER=Cat_Builders}
";}
if ($arg3 == "Butchering"){$text .= "
{BANNER=Cat_Butchering}
";}
if ($arg3 == "Cable TV"){$text .= "
{BANNER=Cat_Cable TV}
";}
if ($arg3 == "Candy"){$text .= "
{BANNER=Cat_Candy}
";}
if ($arg3 == "Carpet Cleaning"){$text .= "
{BANNER=Cat_Carpet Cleaning}
";}
if ($arg3 == "Chiropractors"){$text .= "
{BANNER=Cat_Chiropractors}
";}
if ($arg3 == "Churches"){$text .= "
{BANNER=Cat_Churches}
";}
if ($arg3 == "Cleaning Supplies"){$text .= "
{BANNER=Cat_Cleaning Supplies}
";}
if ($arg3 == "Coins-Commemorative"){$text .= "
{BANNER=Cat_Coins-Commemorative}
";}
if ($arg3 == "Colleges"){$text .= "
{BANNER=Cat_Colleges}
";}
if ($arg3 == "Community Centers"){$text .= "
{BANNER=Cat_Community Centers}
";}
if ($arg3 == "Computers"){$text .= "
{BANNER=Cat_Computers}
";}
if ($arg3 == "Concrete"){$text .= "
{BANNER=Cat_Concrete}
";}
if ($arg3 == "Consignment/Resale"){$text .= "
{BANNER=Cat_Consignment/Resale}
";}
if ($arg3 == "Consulting Services"){$text .= "
{BANNER=Cat_Consulting Services}
";}
if ($arg3 == "Contractors"){$text .= "
{BANNER=Cat_Contractors}
";}
if ($arg3 == "Convenience Stores"){$text .= "
{BANNER=Cat_Convenience Stores}
";}
if ($arg3 == "Credit Unions"){$text .= "
{BANNER=Cat_Credit Unions}
";}
if ($arg3 == "Custom Furniture"){$text .= "
{BANNER=Cat_Custom Furniture}
";}
if ($arg3 == "Delivery Service"){$text .= "
{BANNER=Cat_Delivery Service}
";}
if ($arg3 == "Dentists"){$text .= "
{BANNER=Cat_Dentists}
";}
if ($arg3 == "Department Stores"){$text .= "
{BANNER=Cat_Department Stores}
";}
if ($arg3 == "Doctors"){$text .= "
{BANNER=Cat_Doctors}
";}
if ($arg3 == "Economic Development"){$text .= "
{BANNER=Cat_Economic Development}
";}
if ($arg3 == "Electrical Contractors"){$text .= "
{BANNER=Cat_Electrical Contractors}
";}
if ($arg3 == "Electrical Utilities"){$text .= "
{BANNER=Cat_Electrical Utilities}
";}
if ($arg3 == "Embroidery"){$text .= "
{BANNER=Cat_Embroidery}
";}
if ($arg3 == "Emergency Services"){$text .= "
{BANNER=Cat_Emergency Services}
";}
if ($arg3 == "Employment Agencies"){$text .= "
{BANNER=Cat_Employment Agencies}
";}
if ($arg3 == "Environmental Services"){$text .= "
{BANNER=Cat_Environmental Services}
";}
if ($arg3 == "Equipment Rentals"){$text .= "
{BANNER=Cat_Equipment Rentals}
";}
if ($arg3 == "Excavating"){$text .= "
{BANNER=Cat_Excavating}
";}
if ($arg3 == "Fitness"){$text .= "
{BANNER=Cat_Fitness}
";}
if ($arg3 == "Flooring"){$text .= "
{BANNER=Cat_Flooring}
";}
if ($arg3 == "Florists"){$text .= "
{BANNER=Cat_Florists}
";}
if ($arg3 == "Footcare"){$text .= "
{BANNER=Cat_Footcare}
";}
if ($arg3 == "Foundation-Community"){$text .= "
{BANNER=Cat_Foundation-Community}
";}
if ($arg3 == "Fraternal Organizations"){$text .= "
{BANNER=Cat_Fraternal Organizations}
";}
if ($arg3 == "Funeral Homes"){$text .= "
{BANNER=Cat_Funeral Homes}
";}
if ($arg3 == "Furniture"){$text .= "
{BANNER=Cat_Furniture}
";}
if ($arg3 == "Gasoline-Wholesale"){$text .= "
{BANNER=Cat_Gasoline-Wholesale}
";}
if ($arg3 == "Gifts"){$text .= "
{BANNER=Cat_Gifts}
";}
if ($arg3 == "Golf"){$text .= "
{BANNER=Cat_Golf}
";}
if ($arg3 == "Government"){$text .= "
{BANNER=Cat_Government}
";}
if ($arg3 == "Groceries"){$text .= "
{BANNER=Cat_Groceries}
";}
if ($arg3 == "Hardware/Lumber"){$text .= "
{BANNER=Cat_Hardware/Lumber}
";}
if ($arg3 == "Hearing Aids"){$text .= "
{BANNER=Cat_Hearing Aids}
";}
if ($arg3 == "Heating & Air Conditioning"){$text .= "
{BANNER=Cat_Heating & Air Conditioning}
";}
if ($arg3 == "Historic Sites"){$text .= "
{BANNER=Cat_Historic Sites}
";}
if ($arg3 == "Hospice Care"){$text .= "
{BANNER=Cat_Hospice Care}
";}
if ($arg3 == "Hospitals"){$text .= "
{BANNER=Cat_Hospitals}
";}
if ($arg3 == "Hotel/Motels"){$text .= "
{BANNER=Cat_Hotel/Motels}
";}
if ($arg3 == "Individuals"){$text .= "
{BANNER=Cat_Individuals}
";}
if ($arg3 == "Industries"){$text .= "
{BANNER=Cat_Industries}
";}
if ($arg3 == "Information Technology"){$text .= "
{BANNER=Cat_Information Technology}
";}
if ($arg3 == "Insurance"){$text .= "
{BANNER=Cat_Insurance}
";}
if ($arg3 == "Internet Services"){$text .= "
{BANNER=Cat_Internet Services}
";}
if ($arg3 == "Investment/Securities"){$text .= "
{BANNER=Cat_Investment/Securities}
";}
if ($arg3 == "Janitorial/Custodial"){$text .= "
{BANNER=Cat_Janitorial/Custodial}
";}
if ($arg3 == "Jewelers"){$text .= "
{BANNER=Cat_Jewelers}
";}
if ($arg3 == "Landfill"){$text .= "
{BANNER=Cat_Landfill}
";}
if ($arg3 == "Library"){$text .= "
{BANNER=Cat_Library}
";}
if ($arg3 == "Liquor"){$text .= "
{BANNER=Cat_Liquor}
";}
if ($arg3 == "Loans"){$text .= "
{BANNER=Cat_Loans}
";}
if ($arg3 == "Lumber"){$text .= "
{BANNER=Cat_Lumber}
";}
if ($arg3 == "Magazine Publications"){$text .= "
{BANNER=Cat_Magazine Publications}
";}
if ($arg3 == "Marina"){$text .= "
{BANNER=Cat_Marina}
";}
if ($arg3 == "Meat Processing/Retail"){$text .= "
{BANNER=Cat_Meat Processing/Retail}
";}
if ($arg3 == "Mental Health Services"){$text .= "
{BANNER=Cat_Mental Health Services}
";}
if ($arg3 == "Metal Machining & Fabrication"){$text .= "
{BANNER=Cat_Metal Machining & Fabrication}
";}
if ($arg3 == "Minting"){$text .= "
{BANNER=Cat_Minting}
";}
if ($arg3 == "Monuments"){$text .= "
{BANNER=Cat_Monuments}
";}
if ($arg3 == "Motorcycles"){$text .= "
{BANNER=Cat_Motorcycles}
";}
if ($arg3 == "Movie Theatres"){$text .= "
{BANNER=Cat_Movie Theatres}
";}
if ($arg3 == "Museums"){$text .= "
{BANNER=Cat_Museums}
";}
if ($arg3 == "Natural/Propane Gas"){$text .= "
{BANNER=Cat_Natural/Propane Gas}
";}
if ($arg3 == "Newspaper"){$text .= "
{BANNER=Cat_Newspaper}
";}
if ($arg3 == "Non-Profit Organizations"){$text .= "
{BANNER=Cat_Non-Profit Organizations}
";}
if ($arg3 == "Nursery/Landscape/Lawn Service"){$text .= "
{BANNER=Cat_Nursery/Landscape/Lawn Service}
";}
if ($arg3 == "Nursing Homes"){$text .= "
{BANNER=Cat_Nursing Homes}
";}
if ($arg3 == "Office Equipment & Supplies"){$text .= "
{BANNER=Cat_Office Equipment & Supplies}
";}
if ($arg3 == "Optometrists"){$text .= "
{BANNER=Cat_Optometrists}
";}
if ($arg3 == "Outdoor Sports"){$text .= "
{BANNER=Cat_Outdoor Sports}
";}
if ($arg3 == "Paint"){$text .= "
{BANNER=Cat_Paint}
";}
if ($arg3 == "Pawnbrokers"){$text .= "
{BANNER=Cat_Pawnbrokers}
";}
if ($arg3 == "Performing Arts"){$text .= "
{BANNER=Cat_Performing Arts}
";}
if ($arg3 == "Pharmacies"){$text .= "
{BANNER=Cat_Pharmacies}
";}
if ($arg3 == "Physical Therapy Services"){$text .= "
{BANNER=Cat_Physical Therapy Services}
";}
if ($arg3 == "Physicians"){$text .= "
{BANNER=Cat_Physicians}
";}
if ($arg3 == "Plating"){$text .= "
{BANNER=Cat_Plating}
";}
if ($arg3 == "Plumbing Contractors"){$text .= "
{BANNER=Cat_Plumbing Contractors}
";}
if ($arg3 == "Portable Toilets"){$text .= "
{BANNER=Cat_Portable Toilets}
";}
if ($arg3 == "Printing"){$text .= "
{BANNER=Cat_Printing}
";}
if ($arg3 == "Promotion"){$text .= "
{BANNER=Cat_Promotion}
";}
if ($arg3 == "Public Radio"){$text .= "
{BANNER=Cat_Public Radio}
";}
if ($arg3 == "Purchasing"){$text .= "
{BANNER=Cat_Purchasing}
";}
if ($arg3 == "Radio Stations"){$text .= "
{BANNER=Cat_Radio Stations}
";}
if ($arg3 == "Real Estate"){$text .= "
{BANNER=Cat_Real Estate}
";}
if ($arg3 == "Recycling"){$text .= "
{BANNER=Cat_Recycling}
";}
if ($arg3 == "Rentals"){$text .= "
{BANNER=Cat_Rentals}
";}
if ($arg3 == "Restaurants/Catering"){$text .= "
{BANNER=Cat_Restaurants/Catering}
";}
if ($arg3 == "Schools"){$text .= "
{BANNER=Cat_Schools}
";}
if ($arg3 == "Security"){$text .= "
{BANNER=Cat_Security}
";}
if ($arg3 == "Self Storage"){$text .= "
{BANNER=Cat_Self Storage}
";}
if ($arg3 == "Senior Care"){$text .= "
{BANNER=Cat_Senior Care}
";}
if ($arg3 == "Senior Living"){$text .= "
{BANNER=Cat_Senior Living}
";}
if ($arg3 == "Service Organizations"){$text .= "
{BANNER=Cat_Service Organizations}
";}
if ($arg3 == "Service Stations"){$text .= "
{BANNER=Cat_Service Stations}
";}
if ($arg3 == "Shooting Sports/Hunting Supplies"){$text .= "
{BANNER=Cat_Shooting Sports/Hunting Supplies}
";}
if ($arg3 == "Signs"){$text .= "
{BANNER=Cat_Signs}
";}
if ($arg3 == "Social Services"){$text .= "
{BANNER=Cat_Social Services}
";}
if ($arg3 == "Sportswear"){$text .= "
{BANNER=Cat_Sportswear}
";}
if ($arg3 == "Stone"){$text .= "
{BANNER=Cat_Stone}
";}
if ($arg3 == "Surgeons"){$text .= "
{BANNER=Cat_Surgeons}
";}
if ($arg3 == "Tanning Salons"){$text .= "
{BANNER=Cat_Tanning Salons}
";}
if ($arg3 == "Tax Services"){$text .= "
{BANNER=Cat_Tax Services}
";}
if ($arg3 == "Telephone Service"){$text .= "
{BANNER=Cat_Telephone Service}
";}
if ($arg3 == "Tires & Services"){$text .= "
{BANNER=Cat_Tires & Services}
";}
if ($arg3 == "Tourism"){$text .= "
{BANNER=Cat_Tourism}
";}
if ($arg3 == "Travel Agencies"){$text .= "
{BANNER=Cat_Travel Agencies}
";}
if ($arg3 == "Uniform/Textile Rental"){$text .= "
{BANNER=Cat_Uniform/Textile Rental}
";}
if ($arg3 == "Veterinarian"){$text .= "
{BANNER=Cat_Veterinarian}
";}
if ($arg3 == "Video"){$text .= "
{BANNER=Cat_Video}
";}
if ($arg3 == "Water Conditioning"){$text .= "
{BANNER=Cat_Water Conditioning}
";}
if ($arg3 == "Welding Supplies"){$text .= "
{BANNER=Cat_Welding Supplies}
";}
if ($arg3 == "Womens Apparel"){$text .= "
{BANNER=Cat_Womens Apparel}
";}
if ($sql-> db_Select(TABLE_NAME, '*', $where, $model))
{
// use $result here to output page content
$text .= "
";
}
else
{
$text .= PB_SEARCH_12;
}
$text .="
";
$addAccess = $pb_prefs['pb_add_access'];
$flagAddAccess = false;
switch($addAccess)
{
case e_UC_PUBLIC:
case e_UC_GUEST:
$flagAddAccess = true; break;
case e_UC_MEMBER:
if ($user_type == e_UC_MEMBER)
$flagAddAccess = true;
break;
case e_UC_ADMIN:
if ($user_type == e_UC_ADMIN)
$flagAddAccess = true;
break;
case e_UC_NOBODY: break;
}
if ($flagAddAccess) // allowed to edit
$text .="
";
$text .= "