text:
<?PHP

// classes used for populating results page
class results_pg {
	private $category_list, $subcat_list, $full_cat_list, $sub_count, $sort_array, $parent_cat_cnt = array();
	public $view_all_link, $advert_cnt = 0, $fav_lnk, $zip_array;

	// list categories
	public function list_categories() {
		global $dbh;

		$zip_string = implode(', ',$this->zip_array);
		// set memcached id value
		$listKey = md5($zip_string.'CID'.$_SESSION['city']);
		$list_cat = str_memc($listKey);
		if(empty($list_cat)){
		  $sql_query = "SELECT
						  id
					  FROM
						  categories
					  WHERE
						  parent_category_id = 0
					 AND
					 	  disabled IS NULL
					  ORDER BY sort_order ASC, category_name ASC;";

		  // store cache results in memcached
		  $rows = db_memc_str($sql_query);

		  $cur_row = 1;
		  $list_cat = '';
		  $this->category_list = '';

		  foreach ($rows as $categories) {

			  $this->subcat_list = '';

			  $this->category_listing($categories['id']);

		  }

		  $this->sort_category_list();

		  foreach($this->sort_array as $id => $value) {
			  $list_cat .= '
'.LB;
			  $list_cat .= $this->category_list[$id]['main_cat'];
			  $list_cat .= $this->category_list[$id]['sub_cats'];
			  $list_cat .= '
'.LB;
		  }
		  // store final value in memcached
		  str_memc($listKey, $list_cat);
		}

	return $list_cat;
	}

	// sort pulled category list
	private function sort_category_list() {

		foreach($this->category_list as $id => $value) {
			$count_order[$id] = $value['sub_cat_cnt'];
		}

		arsort($count_order);

		reset($this->category_list);

		$this->sort_array = $count_order;
	}

	// count of items within category
	private function category_count($category_id) {
			global $dbh, $adv_info_tbl;

		$zip_string = implode(', ',$this->zip_array);

		// reset category count
		$category_count = '';

		// reset selected cat array
		$selected_cats = array();

		$sql_query = "SELECT
						ai.id
					 FROM
						advertiser_info ai LEFT JOIN advertiser_alt_locations aal ON ai.id = aal.advertiser_id
						RIGHT JOIN advertiser_categories ac ON ac.advertiser_id = ai.id
					 WHERE
						ac.category_id = '".$category_id."'
					AND ai.account_enabled = 1
					AND ai.approved = 1
					AND ai.update_approval = 1
					AND (ai.zip IN (".$zip_string.")
					OR aal.zip IN (".$zip_string."));";
//	echo $sql_query;
		// store cache results in memcached
		$rows = db_memc_str($sql_query);

		// added to check for payment data entry
		foreach($rows as $cur_row) {
			// added to check level selected and if payment info has been entered
			$adv_info_tbl->get_db_vars($cur_row['id']);
			if ($adv_info_tbl->customer_level != 3) {
			  if(!empty($adv_info_tbl->payment_method)) {
				$selected_cats[] = $cur_row['id'];
			  }
			} else {
				$selected_cats[] = $cur_row['id'];
			}
		}

		// get selected category count
		$category_count = count($selected_cats);

		// set total cat count
		if (count($selected_cats) > 0) {
			foreach($selected_cats as $cur_advertiser) {
				$this->parent_cat_cnt[$cur_advertiser] = $cur_advertiser;
			}
		}

	return $category_count;
	}

	// load category list
	private function category_listing($category_id) {
		global $cats_tbl,$url_nms_tbl,$cities_tbl,$ste_cty_cat_tbl, $api_load;

		$cats_tbl->get_db_vars($category_id);

		// category count
		$this->parent_cat_cnt = array();;
		$cur_count = $this->category_count($cats_tbl->id);
		$this->sub_count = '';

		$link_name = $this->create_link($category_id);

		// parent cat string
		$parent_cat = ''.htmlspecialchars($cats_tbl->category_name);

		$sub_cat_listing = $this->sub_category_listing($category_id);

		$parent_cat_cnt = count($this->parent_cat_cnt);

		// assign cat count val
		$this->advert_cnt += $parent_cat_cnt;

		$this->category_list[] = array(
										'sub_cats' => $sub_cat_listing,
										'main_cat' => $parent_cat.' ('.$parent_cat_cnt.')'.LB,
										'sub_cat_cnt' => $this->sub_count
										);

	}

	// load subcategory list
	private function sub_category_listing($category_id) {
		global $dbh;

		$sql_query = "SELECT
						id
					 FROM
						categories
					WHERE
						parent_category_id = '".$category_id."'
					 AND
					 	  disabled IS NULL
					ORDER BY
						sort_order ASC, category_name ASC;";

		// store cache results in memcached
		$rows = db_memc_str($sql_query);

		if (count($rows)) {

		$this->subcat_list = '
'.LB;

		foreach($rows as $categories) {

			$this->sub_count++;

			$this->subcat_list .= $this->subcat_output($categories['id']);
			$this->sub_category_listing($categories['id']);
		}

		$this->subcat_list .= '
'.LB;

		}

	return $this->subcat_list;
	}
	// sub category output
	private function subcat_output($category_id) {
		global $cats_tbl,$url_nms_tbl,$cities_tbl,$ste_cty_cat_tbl, $api_load;

		$cats_tbl->get_db_vars($category_id);

		$link_name = $this->create_link($category_id);

		$category_list = '
'.htmlspecialchars($cats_tbl->category_name).' ('.$this->category_count($cats_tbl->id).')
'.LB;

	return $category_list;
	}

	// added 12/11/2009 builds link used within listing page
	private function create_link($category_id) {
		global $cats_tbl,$url_nms_tbl,$cities_tbl,$ste_cty_cat_tbl, $api_load;

		$cats_tbl->get_db_vars($category_id);

		if ($cats_tbl->url_name != '') {
			$url_nms_tbl->get_db_vars($cats_tbl->url_name);
		}

		// assign link names
		if (isset($_SESSION['cur_zip'])) {
			if($cats_tbl->url_name > 0) {
				$url_nms_tbl->get_db_vars($cats_tbl->url_name);
				$link_name = htmlspecialchars($url_nms_tbl->url_name).'/';
			} else {
				$link_name = 'sections/category_results.deal?cat='.$category_id;
			}
			$this->view_all_link = 'view-all-results/';
			$this->fav_lnk = 'deals-of-the-month/';
		}
		if (isset($_SESSION['city'])) {

			// pull category city url name
			$ste_cty_cat_tbl->city_category_search($_SESSION['city'],$category_id);

			if($ste_cty_cat_tbl->url_name > 0) {
				$url_nms_tbl->get_db_vars($ste_cty_cat_tbl->url_name);
				$link_name = $url_nms_tbl->url_name.'/';
			} else {
				$link_name = 'sections/category_results.deal?cat='.$category_id.'&city='.$cities_tbl->id;
			}
			$this->view_all_link = 'view-all-results/'. strtolower(preg_replace('/[^a-zA-Z0-9]/', '-', $cities_tbl->city.' '.$cities_tbl->state)).'/'.$cities_tbl->id.'/';
			if($api_load->status != 1) {
			  $this->fav_lnk = 'deals-of-the-month/'. strtolower(preg_replace('/[^a-zA-Z0-9]/', '-', $cities_tbl->city.' '.$cities_tbl->state)).'/'.$cities_tbl->id.'/';
			} else {
			  $this->fav_lnk = '?page=deals-of-the-month&city='.$cities_tbl->id;
			}
		}

		// added 12/11/2009 to write urls for api system
		if ($api_load->status == 1) {

			// pull category city url name
			$ste_cty_cat_tbl->city_category_search($_SESSION['city'],$category_id);

			if($ste_cty_cat_tbl->url_name > 0) {
				$url_nms_tbl->get_db_vars($ste_cty_cat_tbl->url_name);
				$link_name = '?page='.urlencode($url_nms_tbl->url_name);
			} else {
				$link_name = '';
			}
			$this->view_all_link = '?page=view-all&city='.$cities_tbl->id;
		}

	return $link_name;
	}

}

?>


text:
<!DOCTYPE HTML>

		<title>melonJS Template - Step 6</title>
		<link rel="stylesheet" type="text/css" media="screen" href="index.css">
		<meta id="viewport" name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon" href="icons/touch-icon-iphone-60x60.png">
        <link rel="apple-touch-icon" sizes="76x76" href="icons/touch-icon-ipad-76x76.png">
        <link rel="apple-touch-icon" sizes="120x120" href="icons/touch-icon-iphone-retina-120x120.png">
        <link rel="apple-touch-icon" sizes="152x152" href="icons/touch-icon-ipad-retina-152x152.png">

redpajama_set_name: RedPajamaGithub


text:
require 'spree_core'
require 'spree_korean_surface_mail_calculator/engine'